News for hackers. Stuff that matters.
Re:Technical documentation that just works by jillesvangurp on Thursday May 27, 2021 @04:38AM (#27300654)
This tool seems like it is a nice markdown based CMS but I don't see too many features related to the more difficult parts of doing technical documentation. Like having working code samples.

I attempted a Kotlin centric documentation framework a while ago to address this: https://github.com/jillesvangurp/kotlin4example

I mainly use it to generate the documentation for my Elasticsearch Kotlin Client (jillesvangurp/es-kotlin-client). The idea there is that all examples and source samples are correctly compiling Kotlin code that I can get the output of when they run (e.g. a println). Running the tests, actually generates the documentation markdown. Using a dsl and multiline strings, I can mix lambda code blocks, markdown, or markdown inside files. For the lambda blocks, it figures out the source and line numbers using reflection. But it can also grab source samples based on comment markers. For bigger blobs of markdown, it's easier to grab the content from markdown files. For smaller sections of markdown, I can use inline multi line strings or a Kotlin DSL.

The main benefit of this is that my examples update as I change and refactor the code base. Also, since it runs as part of my tests, I know when examples break.

Re:Technical documentation that just works by oprypin on Thursday May 27, 2021 @05:30AM (#27300920)
MkDocs has a good plugin system, and it's definitely possible to add a plugin to check each code block according to some rules. I know because I made one :)

https://oprypin.github.io/mkdocs-code-validator/ https://github.com/crystal-lang/crystal-book/pull/503

Re:Technical documentation that just works by kxc42 on Thursday May 27, 2021 @06:20PM (#27309293)
Basically you have three approaches to tackle code samples in markdown files:

1. run the code with some kind of plugin as part of your doc pipeline

2. generate documentation from your code

3. take some kind of hybrid approach

I went for 3., annotate snippet "areas" in the source code of a project (mainly in tests) and extract the snippets to a folder, e.g. into the mkdocs folder. I commit them to the (docs) repo. If the project changes, usually I fix the tests and update the snippets in mkdocs. This way I can be sure that the code in the documentation is actually working and people can copy&paste it. To scratch my own itch, I (surprise, surprise) created a script and even packaged it[1].

[1]: https://pypi.org/project/snex/

Re:Technical documentation that just works by squidfunk on Thursday May 27, 2021 @04:42AM (#27300682)
True, Material for MkDocs doesn't have a working out-of-the-box solution for working code examples, as it's a language-agnostic theme for documentation, but it shouldn't be too difficult to integrate [1].

[1]: https://dev.to/yysun/make-code-run-in-your-docs-4800

Re:Technical documentation that just works by agumonkey on Thursday May 27, 2021 @09:04AM (#27302578)
same, and with the trend like replit or small interpreter (graalvm or else) I kinda foresee a potential wave of notebook like docs

live snippets (brett victor hello) or even ability to try permutations of inputs to get a feel

and maybe .. metalevel generated live tests.