-
Notifications
You must be signed in to change notification settings - Fork 63
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: Config reference documentation autogeneration #2033
base: main
Are you sure you want to change the base?
Conversation
Test Details: go/deco-tests/12401106836 |
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
bundle/internal/docs/markdown.go
Outdated
md "github.com/nao1215/markdown" | ||
) | ||
|
||
const ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These templates are in this repo temporary to simplify the process of docs updating
This can be further improved by using include
declarations in doc repo so we could generate only meaningful part here and store the wrapper file in docs repo
type annotationHandler struct { | ||
// Annotations read from all annotation files including all overrides | ||
parsedAnnotations annotationFile | ||
parsedAnnotations annotation.File |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved annotations to separate package but yaml files kept as is to avoid messy conflicts. Will move them right before merging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can also be done in a follow-up PR.
@pietern @shreyas-goenka @andrewnester this one is ready for review if anyone want to take a look! More content updates to annotations will be introduced in follow-up PRs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you consider checking in the Markdown output as well?
That can serve as both a check that the contents is OK and that it doesn't inadvertently drift when changes to the schema or annotations are made.
bundle/internal/annotation/main.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main.go
is typically used for a func main()
entry point.
Please rename/split this into file.go
, types.go
, etc, to be more intuitive.
bundle/internal/annotation/main.go
Outdated
* github.com/databricks/cli/bundle/config.Bundle: | ||
* cluster_id: | ||
* description: "Description" | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it is copied, but we use regular line comments also for blocks everywhere else (//
).
bundle/internal/docs/README.md
Outdated
|
||
1. Install [Golang](https://go.dev/doc/install) | ||
2. Run `go mod download` from the repo root | ||
3. Run `make docs` from the repo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The vendor
target can be a dep of make docs
, which removes a step here.
bundle/internal/docs/markdown.go
Outdated
* - [volume](#volume) (<UC>) | ||
- ✓ | ||
- [Volume object](/api/workspace/volumes/create) | ||
` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is a literal, you can include it under a templates
directory and read it directly.
That's easier than working around backticks and quoting issues inline.
Separate question, why is the list of resources not generated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion!
Separate question, why is the list of resources not generated?
There are some custom columns in the table, I decided to keep as is to give some flexibility for intro
for _, node := range nodes { | ||
m = m.LF() | ||
if node.TopLevel { | ||
m = m.H2(node.Title) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the value of this dependency if you can also write output += "## " + node.Title
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was useful for more complex things as tables but then I realised that we use some custom markup
I'll try to remove this dep
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the dependency, added smaller custom renderer with the same interface
bundle/internal/docs/nodes.go
Outdated
return isCustomField | ||
} | ||
|
||
func extractNodes(prefix string, props map[string]*jsonschema.Schema, refs map[string]jsonschema.Schema, customFields map[string]bool) []rootProp { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
bundle/internal/docs/refs.go
Outdated
return true | ||
} | ||
|
||
func resolveAdditionaProperties(v *jsonschema.Schema) *jsonschema.Schema { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo.
type annotationHandler struct { | ||
// Annotations read from all annotation files including all overrides | ||
parsedAnnotations annotationFile | ||
parsedAnnotations annotation.File |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can also be done in a follow-up PR.
go.mod
Outdated
@@ -34,6 +34,8 @@ require ( | |||
gopkg.in/yaml.v3 v3.0.1 | |||
) | |||
|
|||
require github.com/nao1215/markdown v0.6.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deps should have an entry in the NOTICE
file + vetted to be compatible with the license.
Are you sure you want to use it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed extra deps to avoid that
return nodes[i].Title < nodes[j].Title | ||
}) | ||
return nodes | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's very hard to tell what this function does and how it is supposed to work. Please include a few more comments with how you expect it to work, and if possible even a testcase or two to make sure it does work the way you assume. As is we need to run it and check the output to confirm this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added few test cases and re-arranged the code with more comments to highlight important parts
You mean to remove from |
schema: | ||
go run ./bundle/internal/schema ./bundle/internal/schema ./bundle/schema/jsonschema.json | ||
|
||
docs: vendor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs: vendor
We don't add this implicitly anymore to other targets. If you're on CI, you can always specify both with "make vendor docs".
BTW, do you intended to run it on CI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, do you intended to run it on CI?
Currently the only use case of using that tool is to checkout CLI repo and run locally
We don't add this implicitly anymore to other targets
By implicitly you mean using make deps or in general?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean the make entry should be:
docs:
...
no dependency on vendor
schema: | ||
go run ./bundle/internal/schema ./bundle/internal/schema ./bundle/schema/jsonschema.json | ||
|
||
docs: vendor | ||
go run ./bundle/internal/docs ./bundle/internal/schema ./bundle/internal/docs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this part if /bundle/internal/ ?
internal is meant for code that is not meant to be used outside of the package, but this is clearly intended to be used outside the package, that's why it's in Makefile.
How about placing this at top level? /docsgen/ ?
I see you're following existing structure, so it's a more of a question for @pietern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you're following existing structure,
Yes I reused same approach as with json schema generation which is used in .codegen.json
along with other internal scripts
Changes
Documentation autogeneration tool. This tool uses same annotations_*.yml files as in json-schema
Result will go there and there
Tests
Manually