Comments (18)
I think I've got a reasonable amount of this done already on master...skip_improvements
Can you have a look and let me know what you think?
from sybil.
@sscherfke - last call on this, I'm planning a 6.0.0 release sometime in the next day or few...
from sybil.
No, but you're right that it's missing and I've implemented in 89d3eee
Could you have a look at master
now and see if that meets all your needs?
from sybil.
I am happy now (and healthy again). :-)
Thanks a lot for your efforts! <3
from sybil.
I skimmed through the changes.
They seem to fix my requirements 1–3 (parse :key: value
options from myst/rest directive and add them to the lexemes).
The evaluator stack seems to solve my requirements for 5: I can instantiate a CodeBlockParser
for console
or toml
(or the PythonCodeBlockParser
) and push an evaluator that looks for :caption: file.ext
and raises a NotEvaluated
if it's not there, which would cause the default evaluators (e.g., doctest evaluator for PythonCodeBlock
) to kick in. Is that correct?
from sybil.
So, coming back to this testfixtures supports what you're after but with different spelling. It's a great library, but then I'm biased since I'm its author ;-)
I think master supports what you're after, but I'm not sure I'd use the evaluator stack, just a specialised CodeBlockParser
.
Can you have a look at current master and let me know if you still feel anything is missing?
from sybil.
I’ll try to test the new changes and give you feedback, but had no time for this yet.
from sybil.
Wasn't there directive option parsing for the MyST lexers, too, in the feature branch skip_improvements
? In the current master
, it's only there for ReST.
It would be cool if that feature was also available for Myst. This is the regex I am currently using:
MYST_START_PATTERN = (
r"^(?P<prefix>[ \t]*)"
r"```\{(?P<directive>code-block)}\s*"
r"(?P<arguments>[\w-]+\b)$\n"
r"(?P<options>(?:\s*\:[\w-]+\:.*\n)*)?"
)
from sybil.
@sscherfke - I'll take the thumbs up as "all good now", please let me know if you spot anything else and we can re-open this.
from sybil.
It's a thumbs up for "I’ll test it and report back" ;-)
from sybil.
Okay, I found two issues:
- I think the options need to be forwared to the
Region
so that they are accessible in a parser. It needs to be added here: https://github.com/simplistix/sybil/blob/master/sybil/parsers/abstract/codeblock.py#L56
Like this (but as an actual class attribute ;-)):r = Region(lexed.start, lexed.end, lexed.lexemes['source'], self.evaluate) r.options = lexed.lexemes.get("options", {}) yield r
- The options in myst blocks must be enclosed with
---
, but the MyST docs seem recommend options without---
: https://myst-parser.readthedocs.io/en/latest/syntax/roles-and-directives.html – I posted a regex that is able to parse this above.
from sybil.
I can provide a PR as base, if you like :)
from sybil.
- Both styles are already supported:
sybil/tests/samples/myst-lexing-directives.md
Lines 21 to 38 in 93eb470
from sybil.
- f6d8772 shows how I'd currently do the kind of thing you're after, but I'm now wondering in
LexedRegion
actually needs to exist...
from sybil.
- I need to access the options in
self.evaluate()
, so overridingself.__call__()
as in that test example does not work for me, I guess: https://gitlab.com/sscherfke/typed-settings/-/blob/main/conftest.py?ref_type=heads#L213 - You're right. A mistake on my side :)
from sybil.
I'm not sure doing what you're doing in self.evaluate()
is right here; you're essentially picking between two evaluators based on an option in the ReST or MyST directive, so you should code it as such rather than trying to do both in a since evaluate
method.
However, as of 59045ff I think you can do either. Let me know what you think.
from sybil.
Hi Chris, I got sick last week. Will try your changes asap and provide feedback.
from sybil.
Very sorry to hear that, hope you're feeling better soon! 6.0.0 is out now with all the changes in it, so please give it a spin and it me know how it goes :-)
from sybil.
Related Issues (20)
- `skip: next` now seems to require an empty line after it HOT 2
- Pytest 8 error: FixtureManager.getfixtureclosure() missing 1 required positional argument: 'ignore_args' HOT 14
- Support for `testcode` and `testoutput` in `DocTestDirectiveParser`s HOT 6
- MyST lexer can't handle code fences with additional backticks HOT 5
- sdist is missing some files needed for testing HOT 3
- Regression: Fails handling triple backquotes with lang tag HOT 13
- pytest: `IndexError: list index out of range` when filtering traceback at `tb_entry = tb[1]` HOT 5
- Codeblock Lexer pattern doesn't work if codeblock ends with close comment (end of input to the lexer) HOT 2
- Markdown forces an empty line at the end HOT 9
- tests/helpers.py not in PyPI tarball HOT 1
- Allow test setup/cleanup HOT 6
- Have a badge HOT 1
- Doesn't work with namespace packages HOT 3
- Unhelpful error with missing final linefeed HOT 4
- Warnings on Python 3.12 about ast.Str HOT 2
- Feature request: Add type hints HOT 3
- ModuleNotFoundError if pytest is not installed HOT 5
- Support GitHub Flavored Markdown (GFM)
- Request: Add test which fails if `self.evaluator = None` is removed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sybil.