Documentation TestsΒΆ

It is prudent to make sure that bits of code you insert into your documentation correspond to code that actually works. In the Python world, these are called documentation tests or, for short, doctests. Sphinx supports doctests built into the documentation.

Here is an example (the system tests the output or lack of is matched:

>>> from rr.analysis import CER
>>> import numpy
>>> a = numpy.array([0,1])
>>> b = numpy.array([1,1])
>>> CER(a, b)
0.5

Notice that, in the generated HTML, you only see the Python code, properly syntax-highlighted.

Previous topic

Syntax Highlighting

Next topic

Python API

This Page