-
Notifications
You must be signed in to change notification settings - Fork 200
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
[MRG] Documentation Auto API #151
Conversation
I am a bit worried about those backward incompatible changes. We now have a sizeable number of packages who use us, and we are going to break their documentation build the minute we release. Is there any way to have a depreciation cycle? Could we have step by step instructions to migrate from the old way to the new way? |
I would also like to make a deprecation cycle. Maybe I can leave the old default value and put a warning that I'll now require the variable to be configured. The migration is just set up the value, the complete goal of this to make the user more aware of this configuration as it is error prone see #126 (comment), many places have to be configured coherently. This PR is mostly a documentation change to deal with the confusion of setting up the sphinx-autodoc and sphinx-autosummary to work with sphinx gallery backreferences, read #126. My approach to it was to force the user to become conscious of this process, as I don't see a way to automate this process, see #126 (comment). |
Some conflicts to fix here. |
a1b578b
to
60c6f51
Compare
Rebased to master. New docs on the backreferences configuration. Proof reading required. |
4c8dc4a
to
bf0b830
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When building MNE docs (without making any changes to it) on this branch, I get an error:
...
Generating gallery
/home/larsoner/custombuilds/sphinx-gallery/sphinx_gallery/gen_gallery.py:91: UserWarning:
=========
Sphinx Gallery now requires you to set the configuration variable
'backreferences_dir' in your config to activate the
backreferences. Read how to update in the online documentation
http://sphinx-gallery.readthedocs.io/en/latest/advanced_configuration.html#references-to-examples
warnings.warn(backreferences_warning)
/home/larsoner/custombuilds/sphinx-gallery/sphinx_gallery/gen_gallery.py:95: UserWarning:
using old default 'backreferences_dir':'modules/generated'
gallery_conf['backreferences_dir']))
Exception occurred:
File "/home/larsoner/custombuilds/sphinx-gallery/sphinx_gallery/gen_gallery.py", line 99, in parse_config
+ backreferences_warning)
ValueError: Old configuration for backreferences detected
using the configuration variable `mod_example_dir`
=========
Sphinx Gallery now requires you to set the configuration variable
'backreferences_dir' in your config to activate the
backreferences. Read how to update in the online documentation
http://sphinx-gallery.readthedocs.io/en/latest/advanced_configuration.html#references-to-examples
The full traceback has been saved in /tmp/sphinx-err-S6YABC.log, if you want to report the issue to the developers.
And the log basically just has the ValueError
traceback. Is this intentional? I expected a warning, but successful build.
doc/advanced_configuration.rst
Outdated
like this: | ||
Sphinx-Gallery enables you, when documenting your modules, to | ||
reference to the examples that use a particular function. For example | ||
if we are documenting the ``numpy.exp`` function its possible to embed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:func:`numpy.exp`
This should work with sphinx crossref
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not addressed
I can confirm that this change gets everything working for MNE:
And the changes make sense to me. |
Also, having both config values (old and new) I get the same error:
If both are present, I think the new one should be used and no warning issued. That way I can just update MNE to have redundant old and new keys, it will work for people with old and new sphinx_gallery installs, and somewhere down the line I'll clean up the |
I seem to remember a discussion about this but I can't find it. IMHO warnings are easily ignored especially in the middle of a noisy output like the one sphinx + sphinx-gallery produces. In principle, I would rather have an error saying that something is very likely configured wrong somewhere and please read the doc or remove this line. What I suspect is that nobody has this setting right, but (lucky) people using exactly the same setup as scikit-learn and @Eric89GXL who asked about the warnings he was getting and thanks to @Titan-C managed to set everything correctly. Having said that, if we think it is better to warn for a few releases and then have an error I am fine with this as well. Most importantly what I think is important is that the warning/error message clearly states:
From this I am guessing that you don't have sphinx-gallery bundled in externals (the latter is what most projects do AFAIK). If that is the case would you consider requiring a recent enough version of sphinx_gallery in your conf.py (once sphinx-gallery 0.1.8 is released) ? |
We could do that, sure. Allowing the old value to seems like a reasonable low-cost way to maintain better backward compatibility/transition with this change, but it probably (hopefully) won't affect too many people anyway. |
Deprecationwarning on mod_examples_dir new of default
- Fixes to Sphinx Headers Apparently Sphinx does not like the overline for the headers. Especially when using the auto docs. Also it does not look good in the Jupyter notebooks. Removing the overline does not have any negative effect on the html heading. - Fixes to level documentation
Default to None example back-references Move examples backreferences sources
doc rewrite
reviewed and rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, on MNE (working with master
) on this PR I get:
Generating gallery
/Users/larsoner/python/sphinx-gallery/sphinx_gallery/gen_gallery.py:99: UserWarning:
=========
Sphinx Gallery now requires you to set the configuration variable
'backreferences_dir' in your config to activate the
backreferences. That is mini galleries clustered by the functions used
in the example script. Have a look at it in sphinx-gallery
http://sphinx-gallery.readthedocs.io/en/stable/index.html#examples-using-numpy-linspace
If you don't care about this features set
in your conf.py
'backreferences_dir':
False
warnings.warn(backreferences_warning + no_care_msg)
/Users/larsoner/python/sphinx-gallery/sphinx_gallery/gen_gallery.py:103: UserWarning:
using old default 'backreferences_dir':'modules/generated'. This will be disabled in future releases
gallery_conf['backreferences_dir']))
Exception occurred:
File "/Users/larsoner/python/sphinx-gallery/sphinx_gallery/gen_gallery.py", line 113, in parse_config
+ backreferences_warning)
ValueError: Old configuration for backreferences detected
using the configuration variable `mod_example_dir`
=========
Sphinx Gallery now requires you to set the configuration variable
'backreferences_dir' in your config to activate the
backreferences. That is mini galleries clustered by the functions used
in the example script. Have a look at it in sphinx-gallery
http://sphinx-gallery.readthedocs.io/en/stable/index.html#examples-using-numpy-linspace
The full traceback has been saved in /var/folders/76/jtmt9q4j18b96prw86rb_17c0000gn/T/sphinx-err-enD3sE.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!
make: *** [html_dev-noplot] Error 1
If I add both config entries, it still doesn't work:
Generating gallery
Exception occurred:
File "/Users/larsoner/python/sphinx-gallery/sphinx_gallery/gen_gallery.py", line 113, in parse_config
+ backreferences_warning)
ValueError: Old configuration for backreferences detected
using the configuration variable `mod_example_dir`
=========
Sphinx Gallery now requires you to set the configuration variable
'backreferences_dir' in your config to activate the
backreferences. That is mini galleries clustered by the functions used
in the example script. Have a look at it in sphinx-gallery
http://sphinx-gallery.readthedocs.io/en/stable/index.html#examples-using-numpy-linspace
The full traceback has been saved in /var/folders/76/jtmt9q4j18b96prw86rb_17c0000gn/T/sphinx-err-KyRh7H.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!
make: *** [html_dev-noplot] Error 1
It would be nice if one or both of these worked so that users with legacy sphinx_gallery
aren't stuck.
doc/advanced_configuration.rst
Outdated
like this: | ||
Sphinx-Gallery enables you, when documenting your modules, to | ||
reference to the examples that use a particular function. For example | ||
if we are documenting the ``numpy.exp`` function its possible to embed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not addressed
doc/advanced_configuration.rst
Outdated
@@ -173,20 +182,48 @@ it with the standard sphinx extensions `autodoc | |||
... | |||
'sphinx.ext.autodoc', | |||
'sphinx.ext.autosummary', | |||
'sphinx_gallery.gen_gallery', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the line above (184) is not lined up properly
sphinx_gallery/backreferences.py
Outdated
Backreferences Generator | ||
======================== | ||
|
||
Reviews generated example files in order to keep track of used modules | ||
Parses example files code in order to keep track of used functions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"example file code" reads better
print('Generating gallery') | ||
def parse_config(app): | ||
"""Process the Sphinx Gallery configuration""" | ||
# TODO: Test this behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to add such tests as part of this PR, or save for later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This goes for the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Titan-C sorry I don't have time to review this PR in detail so feel free to merge it.
It does not have to happen in this PR but tests for the both old and new configuration are a must. It is very easy to break this kind of things without realizing and the impact on the user that encounters the regression is very bad IMO.
The backreferences configurations will now only issue warnings. Old and new configurations should work. |
Now with both config entries present, I get a warning about using the new config value, which we can live with for a while to get people migrated to the newer version. LGTM, thanks @Titan-C |
This PR improves the documentation on getting Sphinx gallery backreferences into auto documented API. Closes #126
There are some incompatible changes. The backreferences are disabled by default. The user must activate them manually by specifying the directory where to save them.