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

x/website: explain "first sentence" in golang.org/doc/comment and go.dev/blog/godoc #59206

Closed
golightlyb opened this issue Mar 23, 2023 · 5 comments
Labels
Documentation help wanted NeedsFix The path to resolution is known, but the work has not been done. website

Comments

@golightlyb
Copy link
Contributor

What did you do?

Wrote a package doc comment such as "Package foo frobulates things e.g. red frobs and green frobs. It can also unfrobulate things." and used (directly, or indirectly e.g. examining output on the pkg website) go/doc.Synopsis to return the first sentence of the text.

What did you expect to see?

go/doc.Synopsis formats this text as "Package foo frobulates things e.g. red frobs and green frobs."

What did you see instead?

go/doc.Synopsis formats this text as "Package foo frobulates things e.g."


The problem is likely not one we want to solve by changing the behaviour of go/doc.Synopsis (see discussion on #59189).

The problem is that the documentation refers to "first sentence", it does so with a specific meaning as defined by go/doc.Synopsis, and not with the meaning a reader would have in mind, of natural language in whatever language the comment is written in. This can be surprising.

The solution should be for the main points of reference for learning how to document Go code to explain this better at the first instance of the phrase "first sentence", perhaps by inserting a footnote.

In https://go.dev/blog/godoc:

When writing package comments of any size, keep in mind that their first sentence[1] will appear in godoc’s package list.

In https://tip.golang.org/doc/comment:

As can be seen in this example, Go doc comments use complete sentences. For a package comment, that means the first sentence[1] begins with “Package”.

With a footnote such as:

1: The meaning of "first sentence" here is specified exactly by [go.doc/Synopsis].

@gopherbot gopherbot added this to the Unreleased milestone Mar 23, 2023
@jamalc jamalc modified the milestones: Unreleased, website/later Mar 24, 2023
@heschi heschi added the NeedsFix The path to resolution is known, but the work has not been done. label Mar 24, 2023
@danicat
Copy link
Contributor

danicat commented Mar 29, 2023

Is anyone working on this? I'm doing a talk tomorrow and I'm looking for a good example to make a very small contribution and this seems perfect for what I want to do. Considering this is just improving the documentation, I suspect we have the consensus that this is the right approach? (LGTM)

Please let me know!

@adonovan
Copy link
Member

Sorry for the delay responding, but we would welcome a CL to make the documentation more clear on this point. Thanks!

@danicat
Copy link
Contributor

danicat commented Mar 31, 2023

No worries, I ended up not having time to do during my talk, but I'll do it over the weekend since now I committed to it :)

I'm just curious about the comment on the first document: "Note, June 2022: For updated guidelines about documenting Go code, see “Go Doc Comments.”

Does this mean that the document is not actively being updated? I still think we should though...

@adonovan
Copy link
Member

adonovan commented Mar 31, 2023

We shouldn't change the wording of the blog post (I don't think they are living documents in quite the same way as most of our others), but it would be fine to add a link from "first sentence" to the doc comment for doc.Synopsis, which already explains in detail what is meant.

@gopherbot
Copy link

Change https://go.dev/cl/496495 mentions this issue: _content: link to definition of "first sentence"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation help wanted NeedsFix The path to resolution is known, but the work has not been done. website
Projects
None yet
Development

No branches or pull requests

7 participants