pawamoy / pawamoy/markdown-exec

feature: Raise `PluginError` on expected failed code execution

Open
#75 6 comments 0 reactions 1 assignee View on GitHub

@pawamoy is already working on this.

Since Feb 20, 2025.

feature insiders
Dominant language
Python
Stars
174
Forks
21
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.