-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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(godocfx): create Go DocFX YAML generator #2854
Conversation
third_party/internal/godocfx/main.go
Outdated
outDir := flag.String("out", "obj/api", "Output directory (default obj/api)") | ||
flag.Parse() | ||
if flag.NArg() != 1 { | ||
log.Fatalf("%s expected 1 arg, got %d", os.Args[0], flag.NArg()) |
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.
Nit: could this error message be improved? %s missing required argument: module path
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.
Done.
pages := map[string]*page{} | ||
toc := tableOfContents{} | ||
|
||
module := pkgs[0].Module |
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.
Will at least one pkg always exist?
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.
Yes. len(pkgs) == 0
is checked above.
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.
Thanks! Please take another look.
third_party/internal/godocfx/main.go
Outdated
outDir := flag.String("out", "obj/api", "Output directory (default obj/api)") | ||
flag.Parse() | ||
if flag.NArg() != 1 { | ||
log.Fatalf("%s expected 1 arg, got %d", os.Args[0], flag.NArg()) |
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.
Done.
pages := map[string]*page{} | ||
toc := tableOfContents{} | ||
|
||
module := pkgs[0].Module |
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.
Yes. len(pkgs) == 0
is checked above.
FYI, there is a tracking issue golang/go#39883 for making that API available to for external use; mentioning it here so that this use case can be considered as part of that work. You may also want to leave a 👍 reaction and/or subscribe to it. |
Thanks! I gave a 👍 to golang/go#39883. |
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.
LGTM
There is a some code copied from https://github.com/golang/pkgsite for getting type/function synopses. Because of those license headers, I put the code in
third_party
.I included a script we can hopefully use from a Kokoro job. That shows how the generator is intended to be used.
Eventually, we may publish this as a standalone tool. We may end up wanting to publish docs for other modules (outside google-cloud-go). It's also possible others in the community would be interested.
cc @dmitshur @julieqiu @JustinBeckwith @spf13 @SurferJeffAtGoogle @jskeet