Repository navigation
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jeertmans
wants to merge
7
commits into
matplotlib:main
Choose a base branch
from
jeertmans:patch-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0d9e6c1
feat(plot_directive): add RST directory option
jeertmans fb04730
chore(lint): remove whitespaces
jeertmans afe63c8
Update lib/matplotlib/sphinxext/plot_directive.py
jeertmans 9c99e19
Update lib/matplotlib/sphinxext/plot_directive.py
jeertmans 7a9bbad
Update lib/matplotlib/sphinxext/plot_directive.py
jeertmans ed04772
Merge branch 'matplotlib:main' into patch-1
jeertmans 210149c
Merge branch 'matplotlib:main' into patch-1
jeertmans File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,6 +151,24 @@ | |
| 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 to: | ||
|
|
||
| .. code:: python | ||
|
|
||
| plot_rst_directory = "source/apidocs/<your_package>/" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
|
||
| .. node:: | ||
|
jeertmans marked this conversation as resolved.
Resolved
|
||
|
|
||
| This currently only support one directory, and can cause potential | ||
|
jeertmans marked this conversation as resolved.
Resolved
|
||
| problems if you have multiple packages documented with ``autodoc2``. | ||
|
|
||
| Notes on how it works | ||
| --------------------- | ||
|
|
||
|
|
@@ -307,6 +325,7 @@ def setup(app): | |
| 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) | ||
|
|
@@ -746,7 +765,11 @@ def run(arguments, content, options, state_machine, state, lineno): | |
| 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 | ||
|
|
||
| if len(arguments): | ||
| if not config.plot_basedir: | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.