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/pkgsite,go/doc: examples can have trailing newlines inside the block #72098

Open
alirezaarzehgar opened this issue Mar 4, 2025 · 5 comments
Assignees
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@alirezaarzehgar
Copy link
Contributor

I found a problem in the example functions across the entire codebase while exploring the Go website. Many Go examples have an unnecessary newline between the end of their code blocks and the output comment. This results in extra newlines on the Go website and pkgsite.

For example, check the source code and the example on the website.

What is the best approach for this?

  • Fix it on pkgsite and trim all the code examples.
  • Remove unnecessary newlines from the entire codebase.
  • Everything is fine, and those extra newlines don't affect the cleanliness and quality of the documentation.
@gopherbot gopherbot added the Documentation Issues describing a change to documentation. label Mar 4, 2025
@alirezaarzehgar alirezaarzehgar changed the title all: unnecessary newline end of many Go Example in documentations all: unnecessary newline end of many Go examples in pkgsite documentations Mar 4, 2025
@randall77
Copy link
Contributor

I think the newlines are fine in the source code.

It is annoying in pkgsite that there's a scrollbar whose sole purpose is to let us see that one extra blank line (at least, I suspect the causation works that way). So I would say, let's fix it there.

@golang/pkgsite

@seankhliao seankhliao changed the title all: unnecessary newline end of many Go examples in pkgsite documentations x/pkgsite,go/doc: examples can have trailing newlines inside the block Mar 4, 2025
@gopherbot gopherbot added this to the Unreleased milestone Mar 4, 2025
@seankhliao
Copy link
Member

I believe the example extraction is in go/doc rather than pkgsite https://go.googlesource.com/go/+/4f45b2b7e079fc03d3444642e8a33ce6f959c6a6/src/go/doc/example.go#580

@seankhliao seankhliao added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed Documentation Issues describing a change to documentation. labels Mar 4, 2025
@alirezaarzehgar
Copy link
Contributor Author

@randall77 @seankhliao

Thank you for your replies.

Can I be an assignee in this issue?

I'm a beginner and need time to explore source code to find a solution.

@gabyhelp
Copy link

gabyhelp commented Mar 4, 2025

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@gabyhelp gabyhelp added the Documentation Issues describing a change to documentation. label Mar 4, 2025
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/655115 mentions this issue: go/doc: fix trailing newlines in examples

@seankhliao seankhliao removed the Documentation Issues describing a change to documentation. label Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants