This lesson is still being designed and assembled (Pre-Alpha version)

Building Documentation with Sphinx

Overview

Teaching: 0 min
Exercises: 0 min
Questions
  • How can I make my documentation more accessible

Objectives
  • Build a documentation website with sphinx

  • Add overview documentation

  • Distribute a sphinx documentation site

Sphinx is a tool for building documentation.

What does sphinx produce?

Exercise

In a group, have each member open one of the following packages’ documentation

Discuss what the common components are, what is helpful about these documentation sites, how they address the general concepts on documentation, how they’re similar and how they’re different.

Solution

these all use sphinx to generate them?

Sphinx quickstart

Install Sphinx if you haven’t done so already:

pip install sphinx

Move into the directory that is to store your documentation:

cd docs

Start the interactive Sphinx quickstart wizard, which creates a Sphinx config file, conf.py, using your preferences.

sphinx-quickstart

Suggested responses to the wizard’s questions:

This will create:

You should now be able to build and serve this basic documentation site using:

make html
python3 -m http.server -d build/html

When you browse to the URL shown in the output of the second command you can see your HTML documentation site but it’s looking fairly bare! Let’s learn a little more about reStructuredText then start adding some content to our documentation site.

Adding literal documentation

FIXME: RST overview

FIXME: adding pages

API Documentation

Add an api line to the index.rst so that it has a link to it.

The create an API.rst file:

API documentation
==================


Key Points

  • Building documentation into a website is a common way of distributing it

  • Sphinx will auto build a website from plain text files and your docstrings