module sphinxext.bokeh.bokeh_plot

Inheritance diagram of pyquickhelper.sphinxext.bokeh.bokeh_plot

Short summary

module pyquickhelper.sphinxext.bokeh.bokeh_plot

Modified version of bokeh_plot.py, LICENSE.

Include bokeh plots in Sphinx HTML documentation. For other output types, the placeholder text [graph] will be generated. The bokeh-plot directive can be used by either supplying, a path to a source file as the argument to the directive:

.. bokeh-plot:: path/to/plot.py

Classes

class

truncated documentation

BokehPlotDirective

Sphinx directive.

PlotScriptError

Error during script parsing.

PlotScriptParser

This Parser recognizes .py files in the Sphinx source tree, assuming that they contain bokeh examples Note: it …

Functions

function

truncated documentation

_process_script

build_finished

builder_inited

env_before_read_docs

env_purge_doc

Remove local files for a given document.

html_page_context

Add BokehJS to pages that contain plots.

setup

sphinx config variable to scan .py files in provided directories only

Methods

method

truncated documentation

parse

Parse source, write results to document.

run

Documentation

Modified version of bokeh_plot.py, LICENSE.

Include bokeh plots in Sphinx HTML documentation. For other output types, the placeholder text [graph] will be generated. The bokeh-plot directive can be used by either supplying, a path to a source file as the argument to the directive:

.. bokeh-plot:: path/to/plot.py

Note

.py scripts are not scanned automatically! In order to include certain directories into .py scanning process use following directive in sphinx conf.py file: bokeh_plot_pyfile_include_dirs = [“dir1”,”dir2”]

Inline code as the content of the directive:

.. bokeh-plot::

    from bokeh.plotting import figure, output_file, show

    output_file("example.html")

    x = [1, 2, 3, 4, 5]
    y = [6, 7, 6, 4, 5]

    p = figure(title="example", plot_width=300, plot_height=300)
    p.line(x, y, line_width=2)
    p.circle(x, y, size=10, fill_color="white")

    show(p)

This directive also works in conjunction with Sphinx autodoc, when used in docstrings. The bokeh-plot directive accepts the following options:

source-positionenum(‘above’, ‘below’, ‘none’)

Where to locate the the block of formatted source code (if anywhere).

linenosflag

Whether to display line numbers along with the source.

Examples

The inline example code above produces the following output:

from bokeh.plotting import figure, output_file, show

output_file("example.html")

x = [1, 2, 3, 4, 5]
y = [6, 7, 6, 4, 5]

p = figure(title="example", plot_width=300, plot_height=300)
p.line(x, y, line_width=2)
p.circle(x, y, size=10, fill_color="white")

show(p)

source on GitHub

class pyquickhelper.sphinxext.bokeh.bokeh_plot.BokehPlotDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source][source]

Bases: docutils.parsers.rst.Directive

Sphinx directive.

source on GitHub

exception pyquickhelper.sphinxext.bokeh.bokeh_plot.PlotScriptError[source][source]

Bases: sphinx.errors.SphinxError

Error during script parsing.

source on GitHub

class pyquickhelper.sphinxext.bokeh.bokeh_plot.PlotScriptParser(rfc2822=False, inliner=None)[source][source]

Bases: docutils.parsers.rst.Parser

This Parser recognizes .py files in the Sphinx source tree, assuming that they contain bokeh examples

Note: it is important that the .py files are parsed first. This is accomplished by reordering the doc names in the env_before_read_docs callback.

source on GitHub

parse(source, document)[source][source]

Parse source, write results to document.

source on GitHub

pyquickhelper.sphinxext.bokeh.bokeh_plot._process_script(source, filename, auxdir, js_name)[source][source]
pyquickhelper.sphinxext.bokeh.bokeh_plot.env_purge_doc(app, env, docname)[source][source]

Remove local files for a given document.

source on GitHub

pyquickhelper.sphinxext.bokeh.bokeh_plot.html_page_context(app, pagename, templatename, context, doctree)[source][source]

Add BokehJS to pages that contain plots.

source on GitHub

pyquickhelper.sphinxext.bokeh.bokeh_plot.setup(app)[source][source]

sphinx config variable to scan .py files in provided directories only

source on GitHub