1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
"""
autogen_config.py
Create config_options.rst, a Sphinx documentation source file.
Documents the options that may be set in nbconvert's configuration file,
jupyter_nbconvert_config.py.
"""
import os.path
from nbconvert.nbconvertapp import NbConvertApp
header = """\
.. This is an automatically generated file.
.. do not modify by hand.
Configuration options
=====================
Configuration options may be set in a file, ``~/.jupyter/jupyter_nbconvert_config.py``,
or at the command line when starting nbconvert, i.e. ``jupyter nbconvert --Application.log_level=10``.
The most specific setting will always be used. For example, the LatexExporter
and the HTMLExporter both inherit from TemplateExporter. With the following config
.. code-block:: python
c.TemplateExporter.exclude_input_prompt = False # The default
c.PDFExporter.exclude_input_prompt = True
input prompts will not appear when converting to PDF, but they will appear when
exporting to HTML.
CLI Flags and Aliases
---------------------
The dynamic loading of exporters can be disabled by setting the environment
variable ``NBCONVERT_DISABLE_CONFIG_EXPORTERS``. This causes all exporters
to be loaded regardless of the value of their ``enabled`` attribute.
When using Nbconvert from the command line, a number of aliases and flags are
defined as shortcuts to configuration options for convenience.
"""
try:
indir = os.path.dirname(__file__)
except NameError:
indir = os.path.dirname(os.getcwd())
destination = os.path.join(indir, "source/config_options.rst")
with open(destination, "w") as f:
app = NbConvertApp()
f.write(header)
f.write(app.document_flag_help())
f.write(app.document_alias_help())
f.write(app.document_config_options())
# Workaround until https://github.com/jupyter/nbclient/pull/216 is released
with open(destination) as f:
data = f.read()
data = data.replace("`CellExecutionError`", "``CellExecutionError``")
data = data.replace("`cell`", "``cell``")
data = data.replace("`cell_index`", "``cell_index``")
data = data.replace("`cell_allows_errors`", "``cell_allows_errors``")
data = data.replace("`notebook`", "``notebook``")
with open(destination, "w") as f:
f.write(data)
|