-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to evaluate separate code-blocks together. #275
Comments
Thank you @rmorshea . How might you want this to work in your document? That is, how would you want to say "these code blocks are linked, and these other ones are not"? |
I don't know how you're parsing things under the hood, or how this would play with MyST, but with CommonMark more generally it should be valid to put any text you want on the line with fence opening. Given that, you could support something like: ```language { "group": 1 } ... ``` On the implementation side you could |
Thank you @rmorshea . This is an issue I have hit and worked around myself and I would be very happy to find a good solution. There are a few other things to keep in mind here. How to merge the two code blocks
Each has trade-offs:
In place changesRunning a formatter, e.g.
|
If linting and formatting are treated separately then I don't think this is true since, in my estimation, formatters have no need for code block grouping - it's only linters that need extra context from prior blocks on occasion. |
I see that you're using Sybil under the hood. From my reading of their docs here it seems that they provide some doc test tooling that makes is possible for code blocks to be interpreted as one concatenated program unless broken up with a namespace clearing directive. With that in mind, you ought to be able to implement a linter that behaves similarly. Formatters, as mentioned above, can be handled differently since they don't do any static analysis. |
This is currently not the case. That is not to say that it can't become the case! |
So, I gave this a think and realized that |
I'm gonna close this since, for the most part, just ignoring errors in docs is good enough. Feel free to re-open if you'd like. |
Thanks @rmorshea . I'm going to re-open this as a prompt in the future - maybe something can be done |
It would be great if you could group code-blocks so they could be evaluated together.
I often find that I'll split up code blocks to make things easier to digest for the reader even when they ought to work when run together. For example:
This works linguistically but linters might complain because
my_add_func
does not exist in the same code block.The text was updated successfully, but these errors were encountered: