Add embed_code_links parameter#1410
Conversation
lucyleeow
left a comment
There was a problem hiding this comment.
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
|
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 htmlI 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: |
|
giving up |
see #1409