First Changes¶
Sphinx uses the reStructuredText document format, which provides a simple yet powerful text file markup syntax. ReStructuredText can be converted to many different output formats (notably HTML and PDF) while maintaining a legible source. The reStructuredText syntax is similar to wiki markup languages.
Editing the Index¶
Open index.txt in your text editor. The default document contains
an explanatory comment
two sections
the master table of contents tree (“toctree”) that houses your site structure
The default tree is empty.
Exercises¶
Look over the reStructuredText syntax
Look at the source of this page by clicking the source link.
In your site’s index.txt, delete the second section—Indices and tables–along with its content.
Run make html and reload the home page to see your changes.
Add a couple of paragraphs of text. Be sure to include examples of emphasized, strong, and monospaced text.
Add three lists, one of which is a nested list.
One list should be an explicitly numbered list
One list should be a bullet list
One list should be auto numbered
Challenge
Make your auto numbered list start with something other than 1.
Add a hyperlink
Separate your document into sections (and possibly subsections) by adding appropriate headings.
Add an image to your document
Adding a Second Document¶
While Sphinx and reStructuredText are useful for creating standalone documents, the real power of Sphinx stems from its ability to create web sites. Sphinx automates the process of handling navigation and styling through the use of templates and themes. When using Sphinx to create your site, you can focus on the content of the site, creating it from reStructuredText documents which Sphinx weaves together to create the final result.
To create a second document for your site:
Create a text file called about.txt. Populate your new document with some content.
In your site’s index.txt, add a reference to your about document in the toctree:
.. toctree:: :maxdepth: 2 aboutRun make html and reload the home page to see your changes.
Since the navigation links appear in the sidebar on the left, you may wish to remove them from the document content, like this:
.. toctree:: :hidden: about
Adding a Logo¶
Sphinx allows you to add a logo to your site:
Create or find a logo image and save it to your project’s _static folder.
Edit the file conf.py in your text editor, changing the configuration option html_logo to the name of your logo file:
html_logo = 'logo.png'
Next: Playing with Themes