Skip to content

[installer] add doc generator for Config #9165

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

Merged
merged 1 commit into from
Apr 27, 2022
Merged

[installer] add doc generator for Config #9165

merged 1 commit into from
Apr 27, 2022

Conversation

nandajavarma
Copy link
Contributor

@nandajavarma nandajavarma commented Apr 6, 2022

Description

This PR adds a small script that can be invoked from the Makefile that will create a Markdown document from the definition of the Config struct

This is a proposal to add extra tags and/or comments to the struct definition that will get by this newly added script. You can try running the script with:

go run ./scripts/structtag.go --version "v1" # "v1" is the default value

This script will basically look for the Config struct in a file ./pkg/config/v1/config.go(or whichever version you choose). Following are the info the script is hoping to extract:

  • Doc about the Config structure itself
  • Name of all the fields specified in the json tag
  • Information about if the field is required or not from the validate tag
  • A one liner description to be read from a new tag called doc
  • Extra notes about the field to be read from a comment to the field

For example:

// Config is the struct we care about
type Config struct {
      // Kind is a field we care about
      // it is very nice. we can use it a lot in `code`
     kind                string             `json:"kind" validate:"required"  doc: "for the kind hearted"`
     domain              string             `json:"kind" doc:"domain to register"`
}

The above struct will produce the following output in ./pkg/config/v1/config.md:


Config

Config is the struct we care about

Supported parameters

Property Required Description Notes
kind Y for the kind hearted Kind is a field we care about it is very nice. we can use it a lot in code
domain N domain to register

Other than the json tag, every other tag is optional.

Related Issue(s)

Fixes #8441

How to test

To test immediately, one can simply run:

$ go run ./scripts/structtag.go # default version is `v1`

You can see the output in the file ./pkg/config/v1/config.md.

To see a more elaborate doc created, add Doc comments(the ones that are given in the line above to the code) and doc tags to the Config fields and re-run the above command.

Release Notes

NONE

Documentation

/werft no-preview

@nandajavarma nandajavarma requested a review from a team April 6, 2022 23:18
@nandajavarma nandajavarma marked this pull request as draft April 6, 2022 23:18
@github-actions github-actions bot added team: delivery Issue belongs to the self-hosted team and removed size/L labels Apr 6, 2022
@nandajavarma nandajavarma changed the title [installer] add doc generator for Config [wip]installer] add doc generator for Config Apr 7, 2022
@nandajavarma nandajavarma changed the title [wip]installer] add doc generator for Config [wip][installer] add doc generator for Config Apr 7, 2022
@nandajavarma nandajavarma changed the title [wip][installer] add doc generator for Config [installer] add doc generator for Config Apr 7, 2022
@nandajavarma
Copy link
Contributor Author

nandajavarma commented Apr 11, 2022

/werft run

👍 started the job as gitpod-build-nvn-config-doc.5

@roboquat roboquat added size/XL and removed size/L labels Apr 20, 2022
@nandajavarma nandajavarma marked this pull request as ready for review April 21, 2022 12:16
@corneliusludmann
Copy link
Contributor

corneliusludmann commented Apr 21, 2022

(took the liberty to add /werft no-preview to the description since this change does not have any effect on a preview environment so that we can speed up the werft build by skipping deploying the preview env—hope that is ok)

@corneliusludmann
Copy link
Contributor

@nandajavarma You need to run leeway run components:update-license-header to add the missing license header. Otherwise, it looks like a really cool first step which I'm looking forward to merge! 🛹

@nandajavarma nandajavarma force-pushed the nvn/config-doc branch 2 times, most recently from c285c4e to 5f62a35 Compare April 26, 2022 06:56
@roboquat roboquat merged commit 926e792 into main Apr 27, 2022
@roboquat roboquat deleted the nvn/config-doc branch April 27, 2022 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none size/XL team: delivery Issue belongs to the self-hosted team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

installer: generate documentation for configuration
3 participants