Update #2: As of 2018-12-17, these instructions have been superseded by the Developer Guide, which takes precedence. (Added by @swinbank)
Update: be sure to read the later instructions for how to continue doing numpydoc work after this hack day.
These are some rough notes for those working on Pipelines package documentation at the JTM 2018 hack day.
The goal for the hack day is to get packages configured with the new doc/ directory infrastructure, and begin to migrate docstrings over as well.
The coordination page is https://confluence.lsstcorp.org/pages/viewpage.action?pageId=73573930
For the hack day, we won’t be using JIRA tickets to track earned value. We’ll use user branches, like:
u/username/sphinx-docs
To claim a package to work on, add your name to the Notes column on the Confluence page.
The goal is not to get a package fully converted to Numpydoc today. As soon as you have a Sphinx-buildable doc/ directory (see below), feel free to merge your work. Lets not leave too many branches open after today.
Set up
In your set up stack environment, install documenteer:
pip install documenteer[pipelines]
(run with pip install --user ... if you’re on lsst-dev01).
This package brings in documentation dependencies, and includes our own Sphinx customizations.
Install the new doc/ infrastructure
The first step is to install some boilerplate files in the package’s doc/ directory. Refer to these:
-
Templates: https://github.com/lsst/templates/tree/master/project_templates/stack_package/{{cookiecutter.package_name}}/doc Note that these use the Jinja2 template format. Text wrapped in
{{ ... }}are your cues to add a customization. - Example: https://github.com/lsst/templates/tree/master/project_templates/stack_package/example/doc
The files you need to add are:
.gitignoreconf.pymanifest.yamlindex.rst-
package_name/index.rst(package_nameis the EUPS package name) -
lsst.module.name/index.rst(lsst.module.nameis the namespace of the Python package. For example,lsst.pipe.base, orlsst.afw.table)
All of these files, except for the .gitignore need to be customized.
conf.py
Set your package’s name and import the version module.
index.rst
Set the package title and set the paths in the toctree to the index.rst files in the lsst.module.name and package_name directories.
index.rst in the module and package subdirectories
Customize the titles of these pages and the anchor links.
Fill in the introductory paragraph you see from the template. Don’t worry about making it completely awesome.
For the package_name/index.rst, it shows a place to add the JIRA component. It’s hard to look up the JIRA component at the moment, so just put the name of the component there in plain text, like this:
JIRA component
``ap_association``
We’ll clean this up later.
manifest.yaml
In manifest.yaml, you’ll set the EUPS package name and the Python package name (or names, for situations like afw).
Here’s an example manifest.yaml from pipe_base: https://github.com/lsst/pipe_base/blob/master/doc/manifest.yaml
Build the package documentation locally
Once the boilerplate is added, you can try to build the package’s documentation locally.
First, make sure you’ve setup the package and run scons as usual. Since the package is being imported, any pybind11 wrappers need to be built first.
Then from the doc/ directory:
sphinx-build . _build/html
The root of the built HTML is _build/html/index.html.
Note that this is a single-package build. This is useful for building a package’s docs without building the entire pipelines.lsst.io site. Of course, at some point, there may be broken cross-package hyperlinks, but this is useful as a preview tool.
Beginning the Numpydoc conversion, one module at a time
You’ll find it easiest if you migrate docstrings one module (Python file) at a time, and rebuild the Sphinx site frequently to test for syntax issues.
Guidelines for writing Numpydoc docstrings are at https://developer.lsst.io/python/numpydoc.html
Once you think you’ve got a module documented, go to the doc/lsst.module.name/index.rst file and add a .. automodapi directive to the “Python API reference” section.
For example, if the namespace of the module is lsst.module.name.exampleA, the directive should be:
.. automodapi:: lsst.module.name.exampleA
For each module you convert, add an additional automodapi directive:
.. automodapi:: lsst.module.name.exampleA
.. automodapi:: lsst.module.name.exampleB
Eventually, once all modules are converted, you should consolidate all the individual automodapi statements to point to just the public module namespace of the package. For example, if the __init__.py at lsst.module.name imports exampleA and exampleB, then their public-facing namespace is lsst.module.name. The consolidated automodapi directive is:
.. automodapi:: lsst.module.name
Integrated builds
It’s not necessary for the initial package hacks, but if you’re curious, you can preview your package within the integrated pipelines.lsst.io site.
This involves using the tickets/DM-11216 branch of the pipelines_lsst_io repo. If you’d like you can create a temporary branch from tickets/DM-11216, but keep in mind that tickets/DM-11216 itself may be rebased at some point.
tickets/DM-11216 will be merged to master once the new-style documentation becomes the default and is fully supported with a Jenkins workflow.
Building the integrated pipelines documentation
These are the steps to build the integrated docs at the moment:
git clone https://github.com/lsst/pipelines_lsst_io
cd pipelines_lsst_io
git checkout tickets/DM-11216
setup -r .
build-stack-docs -d .
Adding your package
To test your package’s documentation in the integrated build, you’ll need to make the following changes to the pipelines_lsst_io repo:
- Add your package to
ups/pipelines_lsst_io.table - Add the
lsst.module.name/indexof your module to the “Python modules”toctreein thepipelines_lsst_ioindex.rst. - Add the
package_name/index.rstof the EUPS package to the “Packages” toctree inpipelines_lsst_io
Then try to rebuild the documentation with the build-stack-docs command.
I (@jsick ) will take care of adding packages to the DM-11216 branch as their upgrades land on master.