rst
Table of contents
In conf.py
add 'sphinxcontrib_session'
to the list of extensions as shown below (note the underscore);
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.githubpages',
'sphinxcontrib_session',
]
pycon
>>> h = 'hello' >>> print('hello') hello >>> for i in hello: ... print(i) h e l l o >>>
The .. session::
directive should be a drop in replacement for the .. code-block::
directive and support the same set of options.
https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-code-block
.. session:: [language]
<statements>
https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive:option-code-block-linenos :linenos:
is supported but generally doesn't make much sense. https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive:option-code-block-lineno-start
In theory any 'session' lexer supported by Pygments should work.
The tested sessions are:
BashSessionLexer
https://pygments.org/docs/lexers/#pygments.lexers.shell.BashSessionLexer - also known as console and shell-session.MSDOSSessionLexer
https://pygments.org/docs/lexers/#pygments.lexers.shell.MSDOSSessionLexer - also known as doscon.PowerShellSessionLexer
https://pygments.org/docs/lexers/#pygments.lexers.shell.PowerShellSessionLexer - also known as ps1con.TcshSessionLexer
https://pygments.org/docs/lexers/#pygments.lexers.shell.TcshSessionLexer - also known as tcshcon- https://pygments.org/docs/lexers/#pygments.lexers.python.PythonConsoleLexer
- https://pygments.org/docs/lexers/#pygments.lexers.r.RConsoleLexer
- https://pygments.org/docs/lexers/#pygments.lexers.sql.PostgresConsoleLexer
- https://pygments.org/docs/lexers/#pygments.lexers.sql.SqliteConsoleLexer
- https://pygments.org/docs/lexers/#pygments.lexers.ruby.RubyConsoleLexer
Lexers are wanted for;
- GDB debugging session.
- TCL script session.