earldouglas / codedown

Extract code blocks from Markdown files
MIT License
79 stars 5 forks source link

Parse/lint each codeblock separately #9

Open plaindocs opened 4 years ago

plaindocs commented 4 years ago

Is there a way to easily pass each codeblock to the external parser / linter instead of passing all codeblocks from a file in one go?

earldouglas commented 3 years ago

Interesting; this sounds useful. Can you describe how you would use it?

plaindocs commented 3 years ago

I often work with doc sets with multiple code blocks in a single page. There are a few use cases that spring to mind (and I may be slightly rusty with the capabilities of codedown), mostly from a "non-literate" point of view:

earldouglas commented 8 months ago

What would the interaction with Codedown look like? Are you thinking of using this as a library, or from the command line? If the CLI, would this simply be multiple invocations of codedown with different arguments?

I'm wondering if we can build on the new --section feature here.

plaindocs commented 8 months ago

I think I'd mostly be using this in CI. If you could add a config section with a commandline to pipe each each code block type to that would do most of the lifting for the first point. A do this for all .py samples and that for all YAML samples?

Possibly with a way to override in the docs with a comment for a specific blog (but that might run into security issues)

Yeah, I see how referencing specific outputs is tricky, unless you can only show the output from the previous blog, but that would also be a good starting point.

I'll go :eyes: the --section feature

earldouglas commented 8 months ago

You should be achieve this today by invoking Codedown multiple times with different language and section arguments.

If Codedown were to somehow expose the complete parse tree of the document, this could enable some more advanced/programmatic features. This reminds me of jq.