Skip to content

feat(godocfx): create Go DocFX YAML generator#2854

Merged
tbpg merged 8 commits intomasterfrom
godocfx
Sep 15, 2020
Merged

feat(godocfx): create Go DocFX YAML generator#2854
tbpg merged 8 commits intomasterfrom
godocfx

Conversation

@tbpg
Copy link
Copy Markdown
Contributor

@tbpg tbpg commented Sep 14, 2020

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

@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Sep 14, 2020
Comment thread 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())
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread third_party/internal/godocfx/main.go
Comment thread third_party/internal/godocfx/main.go
Comment thread third_party/internal/godocfx/parse.go Outdated
Comment thread third_party/internal/godocfx/parse.go
pages := map[string]*page{}
toc := tableOfContents{}

module := pkgs[0].Module
Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Contributor Author

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.

Comment thread third_party/internal/godocfx/parse.go
Comment thread internal/godocfx/go.mod Outdated
Copy link
Copy Markdown
Contributor Author

@tbpg tbpg left a 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.

Comment thread 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())
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread third_party/internal/godocfx/main.go
Comment thread third_party/internal/godocfx/main.go
Comment thread third_party/internal/godocfx/parse.go Outdated
Comment thread third_party/internal/godocfx/parse.go
pages := map[string]*page{}
toc := tableOfContents{}

module := pkgs[0].Module
Copy link
Copy Markdown
Contributor Author

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.

Comment thread third_party/internal/godocfx/parse.go
@dmitshur
Copy link
Copy Markdown

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.

@tbpg
Copy link
Copy Markdown
Contributor Author

tbpg commented Sep 14, 2020

Thanks! I gave a 👍 to golang/go#39883.

@tbpg tbpg requested review from codyoss and noahdietz September 15, 2020 11:28
Copy link
Copy Markdown
Member

@codyoss codyoss left a comment

Choose a reason for hiding this comment

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

LGTM

@tbpg tbpg merged commit 37c70ac into master Sep 15, 2020
@tbpg tbpg deleted the godocfx branch September 15, 2020 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants