earldouglas/codedown

Parse/lint each codeblock separately

plaindocs opened this issue · 5 comments

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?

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

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:

  • validating all code samples in a file separately (for example YAML blocks, not interpreted languages)
  • being able to show output from a single code block (this one is harder I think)

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.

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 👀 the --section feature

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.