wiki:ReviewingDocumentation

Version 9 (modified by PyWebEU, 11 months ago) (diff)

--

Reviewing and Adding Documentation

Some reasons the documentation need help include if:

  • the explanations are unclear
  • the examples don't work or have become outdated
  • the overall structure or the order in which information is presented is unintuitive
  • examples for major concepts are missing

Note that the example and howto documentation on the website may be outdated, as they are only updated from trunk on releases.

Editing example and howto documentation

  1. if you haven't already, check out a copy of the Twisted svn repository

svn checkout svn://svn.twistedmatrix.com/svn/Twisted/trunk ~/my-code-dir/Twisted/trunk

  1. make sure you have the latest version of the code

cd ~/my-code-dir/Twisted/trunk

svn update

  1. Edit away!

The documentation lives in xhtml files in subdirectories of trunk/doc/. Twisted uses the document generator lore to generate the html files you see on the web from these xhtml files. After adding your changes to an xhtml file, it's important to review your changes for correctness and to preview how they will look on the website.

  1. Previewing with lore

For example, if I made changes to trunk/doc/core/howto/choosing-reactor.xhtml, I should

cd ~/my-code-dir/Twisted/trunk/doc/core/howto

lore choosing-reactor.xhtml

lore expects a template file in the directory from which you execute the command. If there isn't a template.tpl file in your directory, copy one from a directory that does have one, like doc/core/howto, or run lore from a directory that does have one.

This generates choosing-reactor.html, which you can view in a web browser via the URL

file:///path/to/my-code-dir/Twisted/trunk/doc/core/howto/choosing-reactor.html

If everything looks good, submit a patch to the xhtml as described here.

Editing API Docs

The API docs are generated from the doc strings in the code by pydoctor, so to update what will be displayed in the API docs just update the doc strings. After making your changes, generate a test set of API docs to preview how they will look.

  1. if you haven't already, check out a copy of the Twisted svn repository

svn checkout svn://svn.twistedmatrix.com/svn/Twisted/trunk ~/my-code-dir/Twisted/trunk

  1. make sure you have the latest version of the code

cd ~/my-code-dir/Twisted/trunk

svn update

  1. Edit away! Be sure to adhere to the docstring guidelines in the Twisted coding standard.
  1. Preview your changes

To generate API docs you need to have installed:

  • pydoctor - API documentation tool for Python written to be used with Twisted
  • Epydoc - an API documentation tool on which pydoctor depends
  • nevow - pydoctor's HTML generation side uses Nevow templates

Once everything is installed, generate the docs with the build-apidocs admin script like so:

bin/admin/build-apidocs /path/to/my-code-dir/Twisted/trunk apidocs

The above produces a folder called apidocs in your current working directory. You can then browse from the entry points to the docs in a web browser via the URL

file:///path/to/apidocs/index.html

If everything looks good, submit a patch as described here.

Editing man pages

Twisted man pages live in doc/<subproject>/man. The man pages are lore'd as part of a release to generate html files, so if you are reviewing man pages you should make sure they generate valid html through lore. The easiest way to do this is to steal from twisted.python._release. To, for example, generate xhtml from the troff files in doc/core/man:

from twisted.python.filepath import FilePath
dir = FilePath('doc/core/man')
from twisted.python._release import ManBuilder
m = ManBuilder()
m.build(dir)

you can then lore the resulting xhtml files as described above to generate html.

More

see also DocumentationAnalysis from an old Twisted documentation sprint.