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

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

Merged
merged 8 commits into from Sep 15, 2020
Merged

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

merged 8 commits into from Sep 15, 2020

Conversation

tbpg
Copy link
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
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
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
Contributor Author

Choose a reason for hiding this comment

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

Done.

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

module := pkgs[0].Module
Copy link
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
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.

third_party/internal/godocfx/parse.go Outdated Show resolved Hide resolved
internal/godocfx/go.mod Outdated Show resolved Hide resolved
Copy link
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.

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
Contributor Author

Choose a reason for hiding this comment

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

Done.

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

module := pkgs[0].Module
Copy link
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.

third_party/internal/godocfx/parse.go Outdated Show resolved Hide resolved
@dmitshur
Copy link

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
Contributor Author

tbpg commented Sep 14, 2020

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

Copy link
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.

None yet

4 participants