Open ptgott opened 2 years ago
At the risk of bike-shedding, I'd like to propose that we start tackling this issue by auto-generating partial files for each section of the config file based on service type, as well as a partial file for the base parameters required for all service types. Once generated, these partials could be used to break up docs/reference/config
into separate pages.
I'd also like to discuss the possibility/feasibility of generating documentation around our schema versioning.
During the operator's CRD build process, we already build JSON schema from Teleport protofiles. We're using the Kubernetes' lib, but the whole thing should be able to generate a valid JSON schema AFAIK. We already maintain the conversion logic from our custom types and wrappers to standard props; it would be a shame to develop this again.
I had excellent experiences in the past hijacking Kube tools. apimachinery's source parsing libs have a robust and extensible marker mechanism allowing to attach custom information to types (e.g. which config versions support this field). Elastic's crd rendering tool could be better, but any output format can be supported with a couple of gotemplates.
During the operator's CRD build process, we already build JSON schema from Teleport protofiles. We're using the Kubernetes' lib, but the whole thing should be able to generate a valid JSON schema AFAIK. We already maintain the conversion logic from our custom types and wrappers to standard props; it would be a shame to develop this again.
I'm going to see if I can extract the JSON schema generation logic from operator/crdgen/schemagen.go
into a Go module that we can share between the crdgen
plugin and a new plugin for generating the configuration resource reference. That way, the new plugin will only need to execute Go templates with data from the JSON schema.
Details
This is a long-term tracking issue for creating
make
targets (or other scripts) to automatically generate our reference documentation.Auto-generated reference docs are more accurate and easier to maintain than manually written ones, since there's less of a risk of forgetting a configuration resource, field name, possible flag value, etc. They also encourage well-written comments and help text in the source code, which has its own benefits.
However, we would also need to make sure that our auto-generated pages include all of the content we want to preserve in our current, hand-typed pages, e.g., usage examples and caveats.
Here is a table we can use to track issues related to auto-generating our reference docs. The table only includes pages from the current
setup/reference/
section of the docs (we'll need to update the table when we reorganize this section). Since protocol-specific sections include their own references, we can consider generating pages for each protocol as well (e.g., see https://github.com/gravitational/teleport/issues/10846).docs/setup/reference
that we could probably generate automaticallyast
andastutil
packages to extract comments from the struct fields inFileConfig
and its fields and use those comments, plus the fields' tags, to generate a reference config file.kingpin
package we use for the CLI supports custom output formatting (per #3568).ast
/astutil
packages here. Audit events implement an interface, and are emitted by theEmitAuditEvent
function.We can either:
- Run a
teleport
binary so that the Prometheus metrics are registered, then output their texts via working with the*Desc
s returned byCollector.Describe
(i.e., this would be ateleport
subcommand that generates metrics docs)- Use Go's AST packages (
ast
,astutil
) to search for instances where we callNewGauge
,NewCounter
, etc., and extract the name and help text from each options struct passed to the functionCategory