This project provides a template Python project for using distutils for distribution and Sphinx for documentation. It saves you work by setting a number of things up for you, including project directory structure, a basic Distutils setup script, Sphinx configuration with the Flask theme, and a project metadata setup which applies to the Distutils script, Sphinx configuration, and can also be used inside your project.
This will be the README for your project. For now, follow these instructions to get this project template setup correctly. Then, come back an replace the contents of this README with contents specific to your project.
Edit the metadata file
my_module/metadata.pyto correctly describe your project.Correct the docstring in
my_module/__init__.pyto the correct name of your module.Rename the
my_moduledirectory to the name of your module:mv my_module my_new_module
Edit
setup.pyto import from your module and edit theclassifiers,packages, andscriptskeywords as necessary.Edit
scripts/my_module_runneras necessary or remove it if you don't need any scripts.Now we need to setup the documentation. This has a few steps. First, go into the documentation source directory:
cd docs/source
Edit
conf.pyby changing the module import to correctly import from your module.Rename
conf.pyso we can runsphinx-quickstart:mv conf.py conf.py.old cd .. sphinx-quickstart
For the answers to the questions, not too much matters since we will be replacing most of with our own configuration. Make sure to say yes to separate build and source directories, and make sure that the title you input is consistent with the one you used in the metadata. The reason it must be consistent is that
sphinx-quickstartuses project-specific names in itsMakefilefor a number of different targets. I have not found a way around this.Rename
conf.py.oldback to the correct name:cd source mv conf.py.old conf.py
Tell Sphinx to pull docstrings out of your module:
sphinx-apidoc -o . ../../my_new_module
It will be necessary to re-run this every time a new module is added to your package. You must delete the old files as
sphinx-apidocwill not overwrite them.This will produce
modules.rstandmy_new_module.rst. Now, inindex.rst, add the modules document to the table of contents.Generate the documentation:
cd .. make html
Now come back and replace this README with your own text.
If you'd like to use ReportLab to generate your documentation, please see instructions for using rst2pdf with Sphinx. The section in
conf.pyhas already been added, but you must add the sections to your generateMakefileandmake.batmanually.
my_module is used as the generic name for your Python module throughout the
skeleton. You should replace it with your module name. The instructions should
guide you through most of the necessary renames. However, to make sure there are
no instances left, you can run this command in your project root:
grep -F --recursive my_module .