smithy-lang / smithy

Smithy is a protocol-agnostic interface definition language and set of tools for generating clients, servers, and documentation for any programming language.
https://smithy.io
Apache License 2.0
1.75k stars 205 forks source link

Automatically lint documentation examples #298

Closed JordonPhillips closed 1 month ago

JordonPhillips commented 4 years ago

Right now there is nothing to enforce that documentation examples are actually valid Smithy models. While somebody might run an example through validation when they initially commit it, things can skew over time. Case in point: #295. Ideally we should have a linter, run by CI, that extracts all those examples and runs them through validation. It should also find examples that have IDL and AST formats side by side and assert that they're equal.

There is a minor downside here in that examples will need to be a little more verbose. Right now we exclude parts that don't matter for the purpose of the example, but that often results in something that isn't a valid model by itself.

This might be a bit tricky to implement depending on the availability of a good Java rst parser.

tripplilley commented 1 year ago

This might be a bit tricky to implement depending on the availability of a good Java rst parser.

A Sphinx extension would be a more idiomatically correct way to do this. Sphinx's included doctest extension is a good starting place. Writing Sphinx Extensions will give context.

I realize it's Python and y'all are a Java shop, but... ❤️