Skip to content
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

mkdocs_gallery_expected_error code-block option to show an error #23

Open
smarie opened this issue Feb 3, 2022 · 0 comments
Open

mkdocs_gallery_expected_error code-block option to show an error #23

smarie opened this issue Feb 3, 2022 · 0 comments

Comments

@smarie
Copy link
Owner

smarie commented Feb 3, 2022

Sometimes we write a code block to show that something raises an error.
It is a bit tideous to have to try/catch this error to prevent mkdocs-gallery to fail.
It would be much better to be able to say that we expect it:

"""
Example
=======

The following code raises an error
"""
# mkdocs_gallery_expected_error
1 + "hello"

# %%
# But this works:

1 * "hello"

We could maybe have a mkdocs_gallery_expected_error similar to the mkdocs_gallery_defer_figures configuration.
It could even accept an optional argument (the exception type, as in pytest.raises)

Of course as always let's first ask the sphinx-gallery team to keep aligned.

Existing code-block options are listed at the bottom of https://sphinx-gallery.github.io/stable/configuration.html?highlight=sphinx_gallery_#list-of-config-options

See also https://sphinx-gallery.github.io/stable/configuration.html#dont-fail-exit which is related but does not fit the same purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant