Skip to content
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

docs: Add Cobra docs generator and CI to ensure they remain up to date #2336

Merged

Conversation

froblesmartin
Copy link
Contributor

@froblesmartin froblesmartin commented Nov 24, 2024

As discussed at #2263, I think this could be integrated into the project.

If you agree with it, I can also help with #2064 by cleaning up duplicates in this PR or a new one, and referencing the new docs in the repo's main README.

Based in https://github.com/kubernetes/kubernetes/blob/master/cmd/gendocs/gen_kubectl_docs.go

@froblesmartin froblesmartin requested a review from a team as a code owner November 24, 2024 08:24
Copy link

google-cla bot commented Nov 24, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@froblesmartin froblesmartin changed the title Add Cobra docs generator and CI to ensure they remain up to date docs: Add Cobra docs generator and CI to ensure they remain up to date Nov 24, 2024
@froblesmartin froblesmartin force-pushed the docs/cobra-autogen branch 4 times, most recently from 9d9f17a to f2b55eb Compare November 24, 2024 08:49
@jackwotherspoon
Copy link
Collaborator

Thanks for this @froblesmartin! 👏 I will try and take a pass at reviewing the PR sometime this week 😄

os.Exit(1)
}

outDir, err := genutils.OutDir(path)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have created a similar change as this PR for AlloyDB: GoogleCloudPlatform/alloydb-auth-proxy#730.

I was getting govulncheck error when using the genutils library here: https://github.com/GoogleCloudPlatform/alloydb-auth-proxy/actions/runs/12130089556/job/33819727861.

I think we can change this to outDir, err := filepath.Abs(path) instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I saw it has some extra checks, but I think it is not worth it. One less dependency 😄

path := "docs/cmd"
if len(os.Args) == 2 {
path = os.Args[1]
} else if len(os.Args) > 2 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's cleaner to check for valid input first and then proceed with usual operations.

if len(os.Args) > 2 {
    // ... error case
    os.Exit(1)
}

path := "docs/cmd"
if len(os.Args) == 2 {
    // ... etc
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good 😉 Applied

Copy link
Member

@enocom enocom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than a minor nit in the gendocs command, this looks good to me. We took the same change in AlloyDB too. Thanks for sending this!

rhatgadkar-goog added a commit to GoogleCloudPlatform/alloydb-auth-proxy that referenced this pull request Dec 4, 2024
@jackwotherspoon
Copy link
Collaborator

Other than a minor nit in the gendocs command, this looks good to me. We took the same change in AlloyDB too. Thanks for sending this!

+1 @froblesmartin let me know if you need me to take over the two nits otherwise LGTM as well!

@froblesmartin
Copy link
Contributor Author

froblesmartin commented Dec 5, 2024

@enocom @jackwotherspoon @rhatgadkar-goog changes applied 😉 I have also added the same text and link in the README as @rhatgadkar-goog did in the AlloyDB PR to keep it standardised.

EDIT: I have just realised about this 5829a5d. This means, any PR after the last day the docs were updated, will fail, as the new workflow will fail due to the date 🤔 I am going to try to see if that can be avoided from the generator, or if not, omit that in the CI.

EDIT2: Solved with the last commit d26f22e. I have also opened a PR to fix this in the AllowDB repo GoogleCloudPlatform/alloydb-auth-proxy#732

Copy link
Collaborator

@jackwotherspoon jackwotherspoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a ton @froblesmartin this is awesome 👏 🚀

@jackwotherspoon jackwotherspoon merged commit 96e9277 into GoogleCloudPlatform:main Dec 5, 2024
12 checks passed
@froblesmartin
Copy link
Contributor Author

Thanks a ton @froblesmartin this is awesome 👏 🚀

You are welcome! 😃 Thanks for the quick attention!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants