[docs] [issue14865] #doctest: directives removed from doctest chapter examples

Terry J. Reedy report at bugs.python.org
Sun May 20 19:58:14 CEST 2012

New submission from Terry J. Reedy <tjreedy at udel.edu>:

In the doctest section, Option Flags and Directives has examples of using #doctest: directives in the .rst source
An example's doctest directives modify doctest's behavior for that single example.  Use ``+`` to enable the named behavior, or ``-`` to disable it.

For example, this test passes::

   >>> print(list(range(20))) #doctest: +NORMALIZE_WHITESPACE
   [0,   1,  2,  3,  4,  5,  6,  7,  8,  9,
   10,  11, 12, 13, 14, 15, 16, 17, 18, 19]
However, when converted to html or Window's help, the directive is removed. See for example


This was reported on python-list for 2.7 and 3.? (.2 probably) by Steven D'Aprano and verified by me for 3.3.0 Win help. Vincent Vande Vyvre provided quote from 3.? .rst source and I verified it and several more following in 3.3.0.

I presume the problem is that we now use the same directives to help doctest source examples for other modules and sphinx with our customizations does not know to leave these particular directives in the text after using them.

I searched issues for '#doctest' and did not see anything about removal.

assignee: docs at python
components: Documentation
messages: 161220
nosy: docs at python, eric.araujo, ezio.melotti, georg.brandl, terry.reedy
priority: normal
severity: normal
stage: needs patch
status: open
title: #doctest: directives removed from doctest chapter examples
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3

Python tracker <report at bugs.python.org>

More information about the docs mailing list