Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(plot_directive): add RST directory option#26099

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
jeertmans wants to merge7 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromjeertmans:patch-1
Open
Changes fromall 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
26 changes: 25 additions & 1 deletionlib/matplotlib/sphinxext/plot_directive.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -151,6 +151,25 @@
The plot_srcset option is incompatible with *singlehtml* builds, and an
error will be raised.

plot_rst_directory
By default, the directory for RST files is automatically determined
from the name of the Python file. This works fine with, e.g., the
``sphinx.ext.autodoc`` extension. However, you may need to modify the
path if RST files are generated in another directory. This is the
case if you use the ``autodoc2`` extension.

For it to work, you need to set the ``plot_rst_directory`` option
in ``conf.py``:

.. code:: python

plot_rst_directory = "source/apidocs/<your_package>/"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Is there a way we can explain the folder situation here? Is this guaranteed to be always under the API docs source dir? I'm thinking of a potential mix between api and narrative docs and where the plots would live for this intermediate state.


.. note::

This currently only supports one directory, and can cause potential
problems if you have multiple packages documented with ``autodoc2``.

Notes on how it works
---------------------

Expand DownExpand Up@@ -307,6 +326,7 @@
app.add_config_value('plot_working_directory', None, True)
app.add_config_value('plot_template', None, True)
app.add_config_value('plot_srcset', [], True)
app.add_config_value('plot_rst_directory', None, True)
app.connect('doctree-read', mark_plot_labels)
app.add_css_file('plot_directive.css')
app.connect('build-finished', _copy_css_file)
Expand DownExpand Up@@ -746,7 +766,11 @@
context_opt = None if not keep_context else options['context']

rst_file = document.attributes['source']
rst_dir = os.path.dirname(rst_file)

if not config.plot_rst_directory:
rst_dir = os.path.dirname(rst_file)
else:
rst_dir = config.plot_rst_directory

Check warning on line 773 in lib/matplotlib/sphinxext/plot_directive.py

View check run for this annotation

Codecov/ codecov/patch

lib/matplotlib/sphinxext/plot_directive.py#L773

Added line #L773 was not covered by tests

if len(arguments):
if not config.plot_basedir:
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp