modal-labs / pytest-markdown-docs

Run pytest on markdown code fence blocks
MIT License
57 stars 7 forks source link

Add support for `pycon` format #16

Closed durandtibo closed 1 month ago

durandtibo commented 1 year ago

This PR proposes to add support for the pycon format. As shown for example in blacken-docs, one of the code block formats is pycon which is not supported by the current implementation. I think it would be great to add support to this format as it seems the changes are very small. The PR also adds some tests to check the new pycon format.

Issue: N/A

freider commented 9 months ago

Thanks for the contribution, and sorry for the slow reply - I've been away and haven't paid close attention to this project, but should be more responsive going forward.

I didn't quite understand at first how this worked since we don't handle the "console prefixes" (>>>) anywhere. This made me find a pretty nasty bug where the plugin silently passes all tests that have syntax errors 🤯 Fix for that is coming here: https://github.com/modal-labs/pytest-markdown-docs/pull/21

To get this PR in working order, it would need to somehow handle the console prefixes (I assume there may be other features of the "pycon language" too to consider?) - it resembles doctest a lot to me

freider commented 1 month ago

I'm closing this for now because of inactivity, but feel free to reopen a new PR w/ actual implementation of pycon syntax parsing if this is something that you still want to contribute :)