Skip to content

Third party directive example #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 19, 2021
Merged
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
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sphinx==4.2.0
sphinx-rtd-theme==1.0.0
docutils==0.16
matplotlib==3.4.3
7 changes: 7 additions & 0 deletions docs/src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"sphinx.ext.extlinks",
"sphinx_rtd_theme",
"sphinx_codeautolink",
"matplotlib.sphinxext.plot_directive"
]

# Builtin options
Expand All @@ -40,6 +41,12 @@
extlinks = {
'issue': ('https://github.com/felix-hilden/sphinx-codeautolink/issues/%s', '#'),
}
# Copy plot directive options from Seaborn
# Include the example source for plots in API docs
plot_include_source = True
plot_formats = [("png", 90)]
plot_html_show_formats = False
plot_html_show_source_link = False


def setup(app):
Expand Down
15 changes: 15 additions & 0 deletions docs/src/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,18 @@ Please specify a ``type`` in :rst:dir:`autolink-examples`::

.. autolink-examples:: numpy.linspace
:type: func

Third-party code blocks
-----------------------
It also integrates with third-party code blocks.
The code block below uses matplotlib's
:mod:`~matplotlib.sphinxext.plot_directive` to automatically
run the code and include the output plot in the documentation:

.. plot::

import numpy as np
from matplotlib import pyplot as plt

x = np.linspace(0, 2 * np.pi, 100)
plt.plot(x, np.cos(x))
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
],
"docs": [
"sphinx-rtd-theme",
"matplotlib"
],
"tests": [
"pytest>=6",
Expand Down