question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible to ignore a file with sphinx-gallery?

See original GitHub issue

I’m trying to get SG set up with a project that needs an __init__.py file inside of the examples folder. This is giving sphinx-gallery issues because if there’s no docstring it will error, and if I add a docstring then I get an empty image in the gallery for the init file. Is there a way to tell SG to totally ignore a file (e.g., with a regex or something?)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:18 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
lestevecommented, Dec 12, 2017

I am in favour of allowing to ignore completely a file based on a regex (based on re.search applied to the full absolute path). It does not seem too hard to do, I am guessing we can just skip files when we walk the examples folders. I may even be in favour of skipping __init__.py files by default.

1reaction
lestevecommented, Dec 8, 2017

@nicain if you just want to run the examples in the CI, you just need to do something like:

python setup.py install
cd doc
make html

You will get a non-zero exit code if at least one of the example does not run so your CI will fail. Look at https://github.com/sphinx-gallery/sphinx-gallery/blob/master/.travis.yml for how we do it in sphinx-gallery. This is how examples are tested in all the sphinx-gallery usages I know of, scikit-learn, mne-python, matplotlib, etc …

FWIW, I found out the reason that the initial package includes init.py in their examples folder. It’s because they want users to be able to do from mypackage.examples import plot_example; plot_example()

@choldgraf it would make sense to have an additional variable to completely exclude files from the gallery. I would not say this is very high priority though. I don’t see a good reason what you gain from having the examples inside the package. In particular it feels like from mypackage.examples.some_example import plot_example; plot_example() is kind of the same as ipython mypackage/examples/some_example.py. Do you have a link for the project you are mentioning out of curiosity?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration — Sphinx-Gallery 0.11.1-git documentation
Configuration and customization of Sphinx-Gallery is done primarily with a dictionary specified in your conf.py file. A list of the possible keys are...
Read more >
Configuration - Sphinx documentation
'library/xml*' – ignores all files and directories starting with library/xml. '**/.svn' – ignores all .svn directories.
Read more >
gallery - Jupyter Notebook - MyBinder
However, you can also create your own CSS styles if you prefer (then you don't need to install Sphinx-Gallery). You can load your...
Read more >
Writing documentation — Matplotlib 2.2.5 documentation
Don't directly edit the .rst files in docs/gallery and ... The configuration file for Sphinx is doc/conf.py . ... Some possible uses:.
Read more >
python - Can sphinx link to documents that are not located in ...
It the README has images or similar that have relative paths that aren't valid within the directory index.rst is in, how do you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found