markdown-exec
markdown-exec copied to clipboard
feature: Raise `PluginError` on expected failed code execution
Is your feature request related to a problem? Please describe.
I would like to use the docs build execution as a way to check that the code in the docs is staying up to date with the underlying python library. For this to work the docs build must fail when the code raises an exception. That is, a code block containing raise ValueError should stop the docs build with a non-zero returncode.
Describe the solution you'd like
When a code block raises a value error unexpectedly (i.e. not indicated by the returncode option) throw a PluginError
I think this would amount to (maybe optionally) adding a line to this block:
https://github.com/pawamoy/markdown-exec/blob/36db197b05e9076d968b723ab039e3bb4763adf5/src/markdown_exec/formatters/base.py#L145-L155
Describe alternatives you've considered
I don't think there is an alternative method for this plugin.
Additional context
I think this could be configurable, even opt in. And it should still be possible to have errors, in the same way the shell code works.
I'm happy to make a PR implementing this if that's helpful