simplistix / sybil

Automated testing for the examples in your documentation.
https://sybil.readthedocs.io/en/latest/
Other
74 stars 14 forks source link

Enable running skips with custom marker #138

Closed adamtheturtle closed 1 month ago

adamtheturtle commented 1 month ago

I want to have two Sybils, and for a code block to be skipped only for one of those Sybils. This is my attempt to get that working.

cjw296 commented 1 month ago

Hmm, not sure how I feel about this... it introduces quite a lot of documentation complexity for what's quite a niche use case.

How about this for an idea: Sybils now have names, can you think of any reason the Sybil shouldn't be added to the namespace of the document, which would then show up in the example's namespace, and I think that means you should be able to use the existing "skip if" functionality, right?

adamtheturtle commented 1 month ago

Thank you for looking at this.

I can't think of a reason why your suggestion wouldn't be suitable but I don't feel I have a lot of knowledge.

The use case for me is already covered by CustomDirectiveSkipParser in my sybil-extras library which covers the extensions to Sybil which don't belong here. I thought it best to propose this upstream, but no requirement from me if you don't want it here.

cjw296 commented 1 month ago

Here's where I'd add self, which is a Sybil, to document.namespace: https://github.com/simplistix/sybil/blob/fd98b3bed8fa6a53078a8945c19b22d37aebd810/sybil/sybil.py#L153

I'd add a test similar to this one, below it, which had two named sybils and a skip-if based on sybil.name == 'something': https://github.com/simplistix/sybil/blob/fd98b3bed8fa6a53078a8945c19b22d37aebd810/tests/test_functional.py#L383

I'll close this for now as it sounds like you have a working solution, and I don't think I want this complexity around the skip parser.