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

The sphinx plot directive does not find files relative to the document that contains them. #10350

Open
Labels
@183amir

Description

@183amir

Bug report

Bug summary

According to the documentation when plot_basedir is empty or None. The source-code files are found relative to the document that contains them:

plot_basedir
Base directory, to which plot:: file names are relative to. (If None or empty, file names are relative to the directory where the file containing the directive is.)

but this is not true in the source code and filenames are found relative toconf.py instead:

rst_file=document.attributes['source']
rst_dir=os.path.dirname(rst_file)
iflen(arguments):
ifnotconfig.plot_basedir:
source_file_name=os.path.join(setup.app.builder.srcdir,
directives.uri(arguments[0]))
else:
source_file_name=os.path.join(setup.confdir,config.plot_basedir,
directives.uri(arguments[0]))

On line 689, I believerst_dir must be used instead ofsetup.app.builder.srcdir (which points to the folder ofconf.py).

Code for reproduction

The minimal example to reproduce this is here:
minimal.zip
Here is how the folder structure looks like:

minimal└── source    ├── conf.py    ├── index.rst    ├── plots    │   ├── plot.py    │   └── plot.rst

where theconf.py contains (besides what is in template):

extensions= ['matplotlib.sphinxext.plot_directive']

andplot.rst contains:

..plot::plot.py

andindex.rst contains:

..toctree:::maxdepth:2:caption:Contents:   plots/plot.rst

Runningmake html on this minimal example fails with:

Running Sphinx v1.6.6making output directory...loading pickled environment... not yet createdbuilding [mo]: targets for 0 po files that are out of datebuilding [html]: targets for 2 source files that are out of dateupdating environment: 2 added, 0 changed, 0 removed/tmp/minimal/source/index.rst:9: WARNING: Error in "toctree" directive:                                                                                                             invalid option block... toctree::   :maxdepth: 2   :caption: Contents:   plots/plot.rstException occurred:  File "/usr/lib/python3.6/site-packages/matplotlib/sphinxext/plot_directive.py", line 708, in run    with io.open(source_file_name, 'r', encoding='utf-8') as fd:FileNotFoundError: [Errno 2] No such file or directory: '/tmp/minimal/source/plot.py'The full traceback has been saved in /tmp/sphinx-err-36njex0o.log, if you want to report the issue to the developers.Please also report this if it was a user error, so that a better error message can be provided next time.A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!

Expected outcome

I expect the resolved paths to the Python file to be relative to the .rst file per documentation.
('/tmp/minimal/source/plots/plot.py' in the example above).

Matplotlib version

  • Operating system: Arch Linux
  • Matplotlib version: 2.1.2
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.6
  • Other libraries: Sphinx v1.6.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp