Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/doc/en/installation/source-distro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -993,10 +993,6 @@ Environment variables controlling the documentation build
- add ``--no-plot`` to this variable to avoid building the graphics coming from
the ``.. PLOT`` directive within the documentation,

- add ``--no-preparsed-examples`` to only show the original Sage code of
"EXAMPLES" blocks, suppressing the tab with the preparsed, plain Python
version, or

- add ``--include-tests-blocks`` to include all "TESTS" blocks in the reference
manual.

Expand Down
7 changes: 0 additions & 7 deletions src/sage_docbuild/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
-j, --mathjax, --jsmath
ignored for backwards compatibility
--no-plot do not include graphics auto-generated using the '.. plot' markup
--no-preparsed-examples
do not show preparsed versions of EXAMPLES blocks
--include-tests-blocks
include TESTS blocks in the reference manual
--no-pdf-links do not include PDF links in DOCUMENT 'website';
Expand Down Expand Up @@ -297,9 +295,6 @@ def setup_parser():
standard.add_argument("--no-plot", dest="no_plot",
action="store_true",
help="do not include graphics auto-generated using the '.. plot' markup")
standard.add_argument("--no-preparsed-examples", dest="no_preparsed_examples",
action="store_true",
help="do not show preparsed versions of EXAMPLES blocks")
standard.add_argument("--include-tests-blocks", dest="skip_tests", default=True,
action="store_false",
help="include TESTS blocks in the reference manual")
Expand Down Expand Up @@ -513,8 +508,6 @@ def excepthook(*exc_info):
build_options.ALLSPHINXOPTS += "-n "
if args.no_plot:
os.environ['SAGE_SKIP_PLOT_DIRECTIVE'] = 'yes'
if args.no_preparsed_examples:
os.environ['SAGE_PREPARSED_DOC'] = 'no'
if args.live_doc:
os.environ['SAGE_LIVE_DOC'] = 'yes'
if args.skip_tests:
Expand Down
70 changes: 34 additions & 36 deletions src/sage_docbuild/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
# ---------------------

SAGE_LIVE_DOC = os.environ.get('SAGE_LIVE_DOC', 'no')
SAGE_PREPARSED_DOC = os.environ.get('SAGE_PREPARSED_DOC', 'yes')

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
Expand Down Expand Up @@ -993,40 +992,40 @@ def apply(self):
if isinstance(prev_node, nodes.paragraph):
prev_node['classes'].append('with-sage-tab')

if SAGE_PREPARSED_DOC == 'yes':
# Tab for preparsed version
from sage.repl.preparse import preparse
container = TabContainer("", type="tab", new_set=False)
textnodes = [Text('Python')]
label = Label("", "", *textnodes)
container += label
content = Container("", is_div=True, classes=["tab-content"])
example_lines = []
preparsed_lines = ['>>> from sage.all import *']
for line in node.rawsource.splitlines() + ['']: # one extra to process last example
newline = line.lstrip()
if newline.startswith('....: '):
# Tab for preparsed version
from sage.repl.preparse import preparse
container = TabContainer("", type="tab", new_set=False)
textnodes = [Text('Python')]
label = Label("", "", *textnodes)
container += label
content = Container("", is_div=True, classes=["tab-content"])
example_lines = []
preparsed_lines = ['>>> from sage.all import *']
for line in node.rawsource.splitlines() + ['']: # one extra to process last example
newline = line.lstrip()
if newline.startswith('....: '):
example_lines.append(newline[6:])
else:
if example_lines:
preparsed_example = preparse('\n'.join(example_lines))
prompt = '>>> '
for preparsed_line in preparsed_example.splitlines():
preparsed_lines.append(prompt + preparsed_line)
prompt = '... '
example_lines = []
if newline.startswith('sage: '):
example_lines.append(newline[6:])
else:
if example_lines:
preparsed_example = preparse('\n'.join(example_lines))
prompt = '>>> '
for preparsed_line in preparsed_example.splitlines():
preparsed_lines.append(prompt + preparsed_line)
prompt = '... '
example_lines = []
if newline.startswith('sage: '):
example_lines.append(newline[6:])
else:
preparsed_lines.append(line)
preparsed = '\n'.join(preparsed_lines)
preparsed_node = LiteralBlock(preparsed, preparsed, language='ipycon')
content += preparsed_node
container += content
parent.insert(index, container)
index += 1
if isinstance(prev_node, nodes.paragraph):
prev_node['classes'].append('with-python-tab')
preparsed_lines.append(line)
preparsed = '\n'.join(preparsed_lines)
preparsed_node = LiteralBlock(preparsed, preparsed, language='ipycon')
content += preparsed_node
container += content
parent.insert(index, container)
index += 1
if isinstance(prev_node, nodes.paragraph):
prev_node['classes'].append('with-python-tab')

if SAGE_LIVE_DOC == 'yes':
# Tab for Jupyter-sphinx cell
from jupyter_sphinx.ast import CellInputNode, JupyterCellNode
Expand Down Expand Up @@ -1084,9 +1083,8 @@ def setup(app):
app.connect('autodoc-process-docstring', skip_TESTS_block)
app.connect('autodoc-skip-member', skip_member)
app.add_transform(SagemathTransform)
if SAGE_LIVE_DOC == 'yes' or SAGE_PREPARSED_DOC == 'yes':
app.add_transform(SagecodeTransform)
else:
app.add_transform(SagecodeTransform)
if SAGE_LIVE_DOC != 'yes':
app.add_directive("jupyter-execute", Ignore)
app.add_directive("jupyter-kernel", Ignore)
app.add_directive("jupyter-input", Ignore)
Expand Down
Loading