6 The following examples illustrate use cases for "literate programming with
9 Generally, the literate source will not substitute a user guide, but can
10 serve as base documentation as well as reference.
12 The text parts can be used to structure the document, for additional
13 explanations, documentation of variants and discussion why a specific
29 Typically, most of a Python module's documentation is in docstrings.
30 Currently, docstrings are treated as code parts by PyLit.
32 However, literate comments can be used to add structure and documentation
33 that is not intended for the end user of a module but for people trying to
34 maintain or extend it (including the original author).
46 Python's `doctest`_ module runs tests on usage examples.
47 However, running ``doctest`` on the code source will only run doctests
48 within docstrings. In contrast, ``pylit --doctest`` will detect all
49 doctests, in docstrings as well as in text blocks.
51 This way, the docstrings can be kept concise while comprehensive tests can
52 be placed in the code file without taking up precious resources and loading
53 time (as they will be stripped from the byte-compiled module).
62 .. _doctest: http://docs.python.org/library/doctest.html
67 Test suites are a good example for the advantages of literate programming.
68 Documenting the rationale and design as well as test considerations can help
69 a lot when maintaining and extending the tests.
71 The following unit test modules are tested using the nose_ unit
72 test discovery & execution framework. (They should be compatible to
75 .. _nose: http://somethingaboutorange.com/mrl/projects/nose/
76 .. _py.test: https://docs.pytest.org
84 iterqueue_speed_test.py
87 Articles and Tutorials
88 ----------------------
90 This survey of the various options and attempts to extend an iterator with
91 methods for `peek`, `pushback` or `test of emptiness` is also a Python
92 module defining several examples of such rich iterators.
103 The "orthogonal" syntax of reStructuredText and LaTeX makes the documentation
104 of a LaTeX package in the source document far more readable than using LaTeX
110 listings-python-options.sty
111 listings-tex-options.sty
112 palatino-helvetica-courier.sty
114 * isomath_ (PDF__): Math for scientists
116 + LaTeX package for typesetting math according to International
117 Standard ISO 31 `Quantities and units`.
119 __ ftp://dante.ctan.org/tex-archive/macros/latex/contrib/isomath/isomath.sty.pdf
123 * listings-python-options.sty_, listings-tex-options.sty_,
124 palatino-helvetica-courier.sty_
125 * isomath.sty_, isomath.sty.txt_.
127 .. _listings-python-options.sty:
128 http://docutils.sf.net/sandbox/stylesheets/listings-python-options.sty
129 .. _listings-tex-options.sty:
130 http://docutils.sf.net/sandbox/stylesheets/listings-tex-options.sty
131 .. _palatino-helvetica-courier.sty:
132 http://docutils.sf.net/sandbox/stylesheets/palatino-helvetica-courier.sty
134 http://dante.ctan.org/CTAN/macros/latex/contrib/isomath/isomath.sty.html
136 ftp://dante.ctan.org/tex-archive/macros/latex/contrib/isomath/isomath.sty
138 ftp://dante.ctan.org/tex-archive/macros/latex/contrib/isomath/isomath.sty.txt
144 Also cascading style sheets can gain from being made literate documents.
155 Generating a template as well as user documentation from the same
156 source helps to keep them synchronised: