File tree Expand file tree Collapse file tree
astropy_helpers/sphinx/ext Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ astropy-helpers Changelog
3434 it could not work as intended. Add new function ``add_exclude_packages `` to
3535 provide intended behavior. [#331]
3636
37+ - Allow custom Sphinx doctest extension to recognize and process standard
38+ doctest directives ``testsetup `` and ``doctest ``. [#335]
39+
37402.0.1 (2017-07-28)
3841------------------
3942
Original file line number Diff line number Diff line change @@ -26,6 +26,14 @@ def run(self):
2626 return [literal_block (code , code )]
2727
2828
29+ class DoctestOmitDirective (Directive ):
30+ has_content = True
31+
32+ def run (self ):
33+ # Simply do not add any content when this directive is encountered
34+ return []
35+
36+
2937class DoctestRequiresDirective (DoctestSkipDirective ):
3038 # This is silly, but we really support an unbounded number of
3139 # optional arguments
@@ -37,6 +45,12 @@ def setup(app):
3745 app .add_directive ('doctest-requires' , DoctestRequiresDirective )
3846 app .add_directive ('doctest-skip' , DoctestSkipDirective )
3947 app .add_directive ('doctest-skip-all' , DoctestSkipDirective )
48+ app .add_directive ('doctest' , DoctestSkipDirective )
49+ # Code blocks that use this directive will not appear in the generated
50+ # documentation. This is intended to hide boilerplate code that is only
51+ # useful for testing documentation using doctest, but does not actually
52+ # belong in the documentation itself.
53+ app .add_directive ('testsetup' , DoctestOmitDirective )
4054
4155 return {'parallel_read_safe' : True ,
4256 'parallel_write_safe' : True }
You can’t perform that action at this time.
0 commit comments