-
Notifications
You must be signed in to change notification settings - Fork 15
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
feat(comments): parser #13
base: master
Are you sure you want to change the base?
Conversation
Introduces a comment parser that extracts docsonnet data from specially formed comments
Ooooo interesting |
The downside here is that you are putting the burden of making compatible comments on the user without the benefits of such things like autocomplete, or linting, since a comment is still a comment, yet it is evaluated like code. I'm not sure that's actually valuable |
@ghostsquad Docsonnet follows the idea of structured documentation, which is similar to how tools like jsdoc work. By parsing a small DSL out of comments, it can present pretty powerful and information rich docs. I experienced this to be more powerful than the ultra minimal approach done by godoc. Things like autocomplete, syntax highlighting, etc., could definitely be added once we get to actually building editor tooling |
ya, ok, you convinced me. I'm wondering if we can reduce the syntax burden at all without painting ourselves into a corner. Example: before
after
arg 1: type this would unfortunately be a bit more difficult to code, but maybe it's easier to read and write? |
This is really interesting indeed. I would have expected a minimal version like godoc. However, Jsonnet libs don't have a predefined structure so it makes sense to leave this up to the author and DSL they use. Please excuse my ignorance but what is the output structure? |
What do you mean by "output structure"? This PR as I understand it converts comments to plain Jsonnet docsonnet, e.g.:
From there, Docsonnet itself can generate HTML docs, e.g. as seen here. |
Ah. I didn't know that bit was already there. |
Introduces a comment parser that extracts docsonnet data from specially formed comments, by leveraging as much of Jsonnet as possible:
@<name>
functions are defined indsl.libsonnet
as locals, so that using a bit of string replacement the comments can actually be evaluated. This keeps them compatible with Jsonnet syntax and avoids writing a custom parser :^)A new
cmd/cparse
currently exposes the functionality of parsing such Jsonnet:TODO:
docsonnet
binary/cc @sbarzowski @ghostsquad