-
Notifications
You must be signed in to change notification settings - Fork 206
Add embed_code_links parameter #1410
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
base: master
Are you sure you want to change the base?
Conversation
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.
Seems reasonable.
I would add a _bool_eval
check in _fill_gallery_conf_defaults
for the new config.
I think we could add a test in test_gen_gallery.py
, using @pytest.mark.add_conf
to set the config. Note that the tests here use sphinx_app_wrapper
which builds the docs in sphinx_gallery/tests/testconfs/src
done |
81ad8c3
to
5827ea8
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.
I think you can add a test that reads in the generated html file and ensure no links are being added.
(For an example, I think test_minigallery_sort_order_callable
reads a generated file)
Another note to myself - I should improve the documentation. I did not realise text block links are added by sphinx and are thus dictated by sphinx intersphinx config. We only add the code block links and by default will add for all modules in intersphinx, but check modules in |
5827ea8
to
1469be4
Compare
I think I need help to write a test |
From #1409 (comment) also instead of a pure boolean I wonder if we should let this be a regex string with default |
I had a quick play and something like this should work: @pytest.mark.add_conf(
content=r"""
import sys
intersphinx_mapping = {
"python": (f"https://docs.python.org/{sys.version_info.major}", None),
}
sphinx_gallery_conf = {
'examples_dirs': 'src',
'gallery_dirs': 'ex',
'embed_code_links': True,
}"""
)
def test_embed_code_links(sphinx_app_wrapper):
"""Check `embed_code_links` works."""
sphinx_app = sphinx_app_wrapper.build_sphinx_app()
built_example = Path(sphinx_app.outdir, "ex", "plot_1.html")
with open(built_example, "r", encoding="utf-8") as fid:
html = fid.read()
print(html) # Check link has/has not been added in html I thought that since I added python to intersphinx, |
1469be4
to
a9d681b
Compare
5c2a1b9
to
2b6958b
Compare
thanks @lucyleeow I added all in one commit |
@jschueller sorry not sure what you added? AFAICT the test still is just a Also I think @larsoner 's suggestion of having the config be more flexible with a regex would be nice: |
see #1409