-
Notifications
You must be signed in to change notification settings - Fork 617
Generate CLI docs from Go code #1696
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
base: main
Are you sure you want to change the base?
Conversation
Possibly useful prior art mentioned by @marcusmartins: |
ff993c8
to
077efdf
Compare
@@ -0,0 +1,40 @@ | |||
#!/bin/sh |
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.
This script is a bit heinous. Would love to make it all happen more glamorously in a single Go script, but I'm not a good enough gopher to make that happen.
Halp!?
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 think it would make sense to move the docs generation to a dedicated command (see comment above) and add the steps here to the command so it's self container.
I can take a stab at it later today.
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.
Agreed that a separate generate-docs
command, in a similar sense to autocompletion
scripts would work well here. There's inspiration from the cobra docs themselves. a la https://www.emmanuelgautier.com/blog/snippets/go-cobra-docgen
This is ready for eyes! It works, but there a few outstanding issues to get it over the finish line. Could use some help from someone with Gopher skills and knowledge of where this new docs build process should slot into the dev/release cycle. |
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.
Left a few comments. I am happy to look into it today.
err = doc.GenMarkdownTree(cmd, "./docs/tmp") | ||
if err != nil { | ||
log.Fatal(err) | ||
} |
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.
This should be moved to a separate command. Otherwise, it creates the docs everytime the main get invoked
@@ -0,0 +1,40 @@ | |||
#!/bin/sh |
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 think it would make sense to move the docs generation to a dedicated command (see comment above) and add the steps here to the command so it's self container.
I can take a stab at it later today.
@@ -165,6 +166,7 @@ require ( | |||
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect | |||
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect | |||
github.com/rivo/uniseg v0.2.0 // indirect | |||
github.com/russross/blackfriday/v2 v2.1.0 // indirect |
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.
Are you still using the new dependencies here?
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'm actually not sure.. I didn't add them manually. Maybe they got added by cobra/doc?
Converting this back to a draft. Still worth pursuing, but not a high priority. |
Asking kindly for someone to push this across the finish line. As a newbie to |
Removing @replicate/cog as the reviewers for the moment as this currently shows up in the review reminders and is non-actionable. |
This PR generate CLI reference docs programmatically from the Go source code using cobra/doc.
View the docs
https://github.com/replicate/cog/blob/077efdfda59d207ed58601c2b4513e33cda10e00/docs/cli.md
Generate the docs
To Do
long
andexample
docs in Go commandsmkdocs.yml
to include CLI docs in https://cog.run site navdocs/cli.md
is an artifact of the build process. How do we get it checked into the repo?Resolves #433