Closed agriyakhetarpal closed 8 months ago
I'm not sure this should be classified as a bug. I think it can be separated into a documentation issue, that it's not well documented that try_examples_global_x
only applies to automatically inserted instances of the directive, and a request for an enhancement to have global_enable_try_examples
find all instances of the directive that are already there and insert the global config options when config options are not supplied directly.
I agree. It's not completely a bug, but as a feature it would be really useful! I'm happy to write a PR to do both things: update the documentation about this, and also let .. try_examples::
percolate these global config options (I would appreciate some pointers on the latter!)
Description
When using the
try_examples_global_button_text
configuration value to customise the text displayed on every button, the text is used on buttons for docstring-based examples present in the API documentation for a library. However, buttons that are manually created/enabled using the.. try_examples::
directive on code snippets outside of docstrings (such as those written in-line in.rst
files, rather than.py
files) do not respect this configuration and use the placeholder text "Try it with Jupyterliteinstead of the
try_examples_global_button_textvalue set in
conf.py`.It is to be noted that a
:button_text
option is available in order to customise the text for the granularity of a specific button, but doing this for documentation websites where such buttons might be several in number might not make sense.Reproduce
In a standard documentation deployment provided with Sphinx, please follow these steps to reproduce:
try_examples_global_button_text = "Your text here"
toconf.py
.rst
file tracked by Sphinx for inclusion in the built docs, like this:A simple reproducer is available on a PR preview on Read the Docs for the PyWavelets documentation, as follows:
The example mentioned in the
pywt.families()
docstring has the button with the "Try it in your browser" text, as intended:However, on the same page, code snippets coming from
wavelets.rst
, i.e., those not from.. autofunction::
directives:don't have the correct text as mentioned above.
Here is a link to the specified page: https://pywavelets--728.org.readthedocs.build/en/728/ref/wavelets.html
xref: https://github.com/PyWavelets/pywt/pull/728
Expected behavior
The expected behaviour here, IMO, is that
.. try_examples::
, in the absence of an:button_text:
option, should use the value added totry_examples_global_button_text
instead of the "Try it with Jupyterlite" boilerplate/placeholder text (it is a global value, after all, as noted in its name!)Therefore, a summary is as follows:
try_examples_global_button_text
is notNone
, apply it for all examples and.. try_examples::
directives.. try_examples::
directive placed somewhere has a custom:button_text:
, use that instead, overridingtry_examples_global_button_text
Context
jupyterlite-core
(0.2.3
),jupyterlite-sphinx
(0.12.0
)