Tut is a tool that helps you write tutorial style documentation using Sphinx.
Tutorial style documentation is documentation where sections build on one another, and include code examples along the way. Tut helps you manage the code in the tutorial as you write it, and include the correct segments in your document.
Tut makes it easy to manage tags in a git source repository, and include code from a specific tag (or branch or commit) in your Sphinx document using the built-in literalinclude directive. Tut consists of two pieces: a program to manage tags, and a Sphinx extension to switch tags during the Sphinx build.
Including Code in Sphinx
Sphinx provides the literalinclude directive, which allows you to include source files, or parts of files, in your documentation. Tut allows you to switch to a specific git tag, branch, or commit before processing the inclusion.
To enable Tut, add tut.sphinx to the list of enabled extensions in your Sphinx project’s conf.py file:
extensions = [ # ... 'tut.sphinx', ]
The checkpoint directive takes a single argument, which is the git reference to switch to. For example, the following directive will checkout step_one (either a branch or tag) in the git repository in /src:
.. checkpoint:: step_one :path: /src
The directive doesn’t result in any output, but literalinclude (or other file-system inclusion directives) that come after the checkpoint will use the newly checked-out version.
If your document contains multiple checkpoints, you can specify the path once using the tut directive:
.. tut:: :path: /src
Note that /src is evaluated using the same rules as govern literalinclude. That is, the file name is usually relative to the current file’s path. However, if it is absolute (starting with /), it is relative to the top source directory.
Tut records the starting state of repositories the first time it does a checkout, and restores the initial state after the build completes.
When Sphinx encounters a checkpoint directive, it performs a git checkout in target repository. This means that the repository should not contain uncommitted changes, to avoid errors on checkout.
Release date: 17 March 2013
- Support for switching to tags, branches, etc within Sphinx documents
- Initial implementation of wrapper script
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size tut-0.1.tar.gz (10.9 kB)||File type Source||Python version None||Upload date||Hashes View|