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

Functions

function

truncated documentation

_process_script

build_finished

builder_inited

setup

Required Sphinx extension setup function.

Methods

method

truncated documentation

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-position (enum(‘above’, ‘below’, ‘none’)):

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

linenos (bool):

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]

Bases: Directive

has_content = True[source]

May the directive have content?

option_spec = {'linenos': <function BokehPlotDirective.<lambda>>, 'source-position': <function BokehPlotDirective.<lambda>>}[source]

Mapping of option names to validator functions.

optional_arguments = 2[source]

Number of optional arguments after the required arguments.

pyquickhelper.sphinxext.bokeh.bokeh_plot._process_script(source, filename, env, js_name, use_relative_paths=False)[source]
pyquickhelper.sphinxext.bokeh.bokeh_plot.setup(app)[source]

Required Sphinx extension setup function.

source on GitHub