##// END OF EJS Templates
ipython_directive: Adjust doc examples for reproducibility....
ipython_directive: Adjust doc examples for reproducibility. Before this change, building the documentation twice in a row in an environment configured for reproducible bulids would result in discrepancies such as: diff -ru /gnu/store/...-python-ipython-documentation-8.2.0/share/doc/python-ipython-documentation-8.2.0/html/sphinxext.html /gnu/store/...-python-ipython-documentation-8.2.0-check/share/doc/python-ipython-documentation-8.2.0/html/sphinxext.html --- /gnu/store/...-python-ipython-documentation-8.2.0/share/doc/python-ipython-documentation-8.2.0/html/sphinxext.html 1969-12-31 19:00:01.000000000 -0500 +++ /gnu/store/...-python-ipython-documentation-8.2.0-check/share/doc/python-ipython-documentation-8.2.0/html/sphinxext.html 1969-12-31 19:00:01.000000000 -0500 @@ -682,7 +682,7 @@ <span class="gp">In [2]: </span><span class="kn">import</span> <span class="nn">datetime</span> <span class="gp"> ...: </span><span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span> <span class="gp"> ...: </span> -<span class="gh">Out[2]: </span><span class="go">datetime.datetime(2022, 4, 17, 3, 21, 14, 978155)</span> +<span class="gh">Out[2]: </span><span class="go">datetime.datetime(2022, 4, 17, 3, 37, 37, 115081)</span> </pre></div> </div> <p>It supports IPython construct that plain @@ -690,7 +690,7 @@ <div class="highlight-ipython notranslate"><div class="highlight"><pre><span></span><span class="gp">In [3]: </span><span class="kn">import</span> <span class="nn">time</span> <span class="gp">In [4]: </span><span class="o">%</span><span class="k">timeit</span> time.sleep(0.05) -<span class="go">50.2 ms +- 104 us per loop (mean +- std. dev. of 7 runs, 10 loops each)</span> +<span class="go">50.1 ms +- 8.86 us per loop (mean +- std. dev. of 7 runs, 10 loops each)</span> </pre></div> </div> <p>This will also support top-level async when using IPython 7.0+</p> * IPython/sphinxext/ipython_directive.py: Use a fixed date string in the datetime example, and replace the %timeit example by %pdoc, whole output is static.

File last commit:

r27139:919f313f
r27687:71d665c4
Show More
autogen_api.py
80 lines | 2.9 KiB | text/x-python | PythonLexer
#!/usr/bin/env python
"""Script to auto-generate our API docs.
"""
import os
import sys
pjoin = os.path.join
here = os.path.abspath(os.path.dirname(__file__))
sys.path.append(pjoin(os.path.abspath(here), 'sphinxext'))
from apigen import ApiDocWriter
source = pjoin(here, 'source')
#*****************************************************************************
if __name__ == '__main__':
package = 'IPython'
outdir = pjoin(source, 'api', 'generated')
docwriter = ApiDocWriter(package,rst_extension='.rst')
# You have to escape the . here because . is a special char for regexps.
# You must do make clean if you change this!
docwriter.package_skip_patterns += [r'\.external$',
# Extensions are documented elsewhere.
r'\.extensions',
# Magics are documented separately
r'\.core\.magics',
# This isn't API
r'\.sphinxext',
# Shims
r'\.kernel',
r'\.terminal\.pt_inputhooks',
]
# The inputhook* modules often cause problems on import, such as trying to
# load incompatible Qt bindings. It's easiest to leave them all out. The
docwriter.module_skip_patterns += [
r"\.lib\.inputhook.+",
r"\.ipdoctest",
r"\.testing\.plugin",
# Backwards compat import for lib.lexers
r"\.nbconvert\.utils\.lexers",
# We document this manually.
r"\.utils\.py3compat",
# These are exposed in display
r"\.core\.display",
r"\.lib\.display",
# Shims
r"\.config",
r"\.consoleapp",
r"\.frontend$",
r"\.html",
r"\.nbconvert",
r"\.nbformat",
r"\.parallel",
r"\.qt",
# this is deprecated.
r"\.utils\.version",
# Private APIs (there should be a lot more here)
r"\.terminal\.ptutils",
]
# main API is in the inputhook module, which is documented.
# These modules import functions and classes from other places to expose
# them as part of the public API. They must have __all__ defined. The
# non-API modules they import from should be excluded by the skip patterns
# above.
docwriter.names_from__all__.update({
'IPython.display',
})
# Now, generate the outputs
docwriter.write_api_docs(outdir)
# Write index with .txt extension - we can include it, but Sphinx won't try
# to compile it
docwriter.write_index(outdir, 'gen.txt',
relative_to = pjoin(source, 'api')
)
print ('%d files written' % len(docwriter.written_modules))