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

proposal: go/doc: Support for bulleted lists #7873

Open
robfig opened this issue Apr 26, 2014 · 44 comments
Open

proposal: go/doc: Support for bulleted lists #7873

robfig opened this issue Apr 26, 2014 · 44 comments

Comments

@robfig
Copy link
Contributor

@robfig robfig commented Apr 26, 2014

Presently, the best practice when enumerating something in godoc is to use a
pre-formatted section.  For example:

"""
This library has the following caveats:
  * It requires the caller to invoke the method
    only on odd-numbered days
  * It may crash your computer.
"""

I think it would improve godoc (HTML) readability to recognize and format bulleted lists
as <ul>'s instead.  The recognition could be narrowly defined to avoid mistakenly
formatting blocks that were not intended to be lists.

I propose a list is recognized as:
- An indented (pre-formatted) block, 
- .. that consists of 2 or more list items
- .. and that consists only of list items

and a list item is defined as:
- Consecutive lines
- .. where the first line begins with "- " or "* "
- .. that terminate on blank lines.

This can be implemented with minimal disruption to the existing code.  Here is a CL:
https://golang.org/cl/91830044

Here are some before/after examples from popular package docs: 

http://godoc.org/code.google.com/p/gorilla/mux
http://192.241.149.161:8080/pkg/code.google.com/p/gorilla/mux

http://godoc.org/code.google.com/p/gorilla/sessions
http://192.241.149.161:8080/pkg/code.google.com/p/gorilla/sessions

http://godoc.org/code.google.com/p/gorilla/schema
http://192.241.149.161:8080/pkg/code.google.com/p/gorilla/schema

http://godoc.org/code.google.com/p/gogoprotobuf/gogoproto
http://192.241.149.161:8080/pkg/code.google.com/p/gogoprotobuf/gogoproto

http://godoc.org/github.com/davecgh/go-spew/spew
http://192.241.149.161:8080/pkg/github.com/davecgh/go-spew/spew

http://godoc.org/code.google.com/p/go.text/collate/colltab#pkg-constants
http://192.241.149.161:8080/pkg/code.google.com/p/go.text/collate/colltab#pkg-constants
@bradfitz

This comment has been minimized.

Copy link
Member

@bradfitz bradfitz commented Apr 26, 2014

Comment 1:

Previous proposals similar to this have been rejected on grounds that it's a slippery
slope from this to Markdown or worse.
@robfig

This comment has been minimized.

Copy link
Contributor Author

@robfig robfig commented Apr 26, 2014

Comment 2:

I agree wholeheartedly with comments as plain text, free of presentation markup. 
This CL reflects how developers are already writing documentation and is a strict
improvement in the presentation of it.  I don't believe it has any cost to in-code
comment readability.
@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented May 9, 2014

Comment 3:

The way to discuss a proposal like this is to raise it on the public lists.  Especially
if you have a patch.  See http://golang.org/doc/contribute.html .  Thanks.

Labels changed: added repo-main, release-none.

@frankandrobot

This comment has been minimized.

Copy link

@frankandrobot frankandrobot commented Sep 27, 2016

Are you kidding me? You guys have an issue with markdown?

@bradfitz

This comment has been minimized.

Copy link
Member

@bradfitz bradfitz commented Sep 27, 2016

@frankandrobot, that is not a constructive comment. We happily use Markdown on Github and elsewhere. We just don't want it to be Go's documentation format.

@frankandrobot

This comment has been minimized.

Copy link

@frankandrobot frankandrobot commented Sep 28, 2016

@bradfitz i'm surprised that you guys decided to go with plain text. In practice in a large, complex app, you'll end up approximating a markup language for readability anyway (ex: caps for sections), and well you might as well pick a markup language for comments.

Alternatively, since you guys hate markdown, is there the ability to pick whatever markup you want (like a plugin for markdown)?

@bronger

This comment has been minimized.

Copy link

@bronger bronger commented Sep 28, 2016

While I sympathise with not supporting Markdown in godoc, I also think that bulleted lists are important enough to have them properly displayed in godoc. A PR is still welcome? Or has this been rejected somewhere else already?

@bradfitz

This comment has been minimized.

Copy link
Member

@bradfitz bradfitz commented Sep 28, 2016

I think @adg and @robpike want to see a design before code.

@robpike

This comment has been minimized.

Copy link
Contributor

@robpike robpike commented Sep 28, 2016

And @griesemer.

@theherk

This comment has been minimized.

Copy link

@theherk theherk commented Mar 1, 2017

I understand and support the strive for simplicity. In this case, it seems, simplicity could be improved going either direction. Either have it be plain text or support a preexisting parser. To do it the way it is currently seems unnecessarily complex. As it stands, a simple parser is implemented (to heading sections and for preformatted text; documented here).

It seems that just supporting an already existing parser, or at least parser specification like Markdown, would be duck soup. Maybe it would hurt the elegance of the output, but a list is a key ingredient of documentation.

@griesemer griesemer modified the milestones: Go1.9Maybe, Unplanned Mar 1, 2017
@griesemer

This comment has been minimized.

Copy link
Contributor

@griesemer griesemer commented Mar 1, 2017

Moving to 1.9Maybe to raise visibility. No guarantee we're getting to it for 1.9, though.

@awnumar

This comment has been minimized.

Copy link
Contributor

@awnumar awnumar commented Mar 19, 2017

@bradfitz

Previous proposals similar to this have been rejected on grounds that it's a slippery slope from this to Markdown or worse.

This is an example of the slippery-slope fallacy and is not a valid argument.

@bradfitz

This comment has been minimized.

Copy link
Member

@bradfitz bradfitz commented Mar 19, 2017

@libeclipse, thanks.

@bradfitz bradfitz modified the milestones: Go1.10, Go1.9Maybe Jun 28, 2017
@KernelDeimos

This comment has been minimized.

Copy link

@KernelDeimos KernelDeimos commented Jun 29, 2017

In case anybody is interested, I made a modified version of Godoc that adds ordered and unordered lists with a fast and simple custom parser I wrote called slippery-slope-markdown.

Here's a link to my modified version: godoc-custom-fork

Admittedly, the way I threw it in there is kinda hacky, but it could be a starting point.

The parser follows this convention:

  • A line starting with - and a space is a list item
  • Any non-blank line following a list item belongs to that list item
  • A blank line terminates the list

A similar convention is applied to ordered lists. As an aside, it also allows bold text.

@dsnet

This comment has been minimized.

Copy link
Member

@dsnet dsnet commented Nov 1, 2017

I hacked up an implementation of this (~25 lines of change on top of CL/72890) and I feel more strongly now that lists be preceded by indents since there are some cases where users have preceding "1. " or "* " where their intention is not to have a list, but rather a heading (which is a separate concept from what this issue is about).

Secondly, lists are typically rendered with an intent themselves, thus, it is natural to expect that how they appear in the comment also be indented.

@theherk

This comment has been minimized.

Copy link

@theherk theherk commented Nov 2, 2017

If their intent is to have a heading, they should have the span be a single line, begin with a capital letter, and contain no punctuation. Indentation has a meaning already, <pre>; no reason to confuse that. How lists are commonly rendered seems irrelevant. How are they most intuitively read and written in plain text?

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented May 20, 2018

Change https://golang.org/cl/113915 mentions this issue: crypto/x509: reformat template members in docs

gopherbot pushed a commit that referenced this issue May 22, 2018
It's easier to skim a list of items visually when the
items are each on a separate line. Separate lines also
help reduce diff size when items are added/removed.

The list is indented so that it's displayed preformatted
in HTML output as godoc doesn't support formatting lists
natively yet (see #7873).

Change-Id: Ibf9e92437e4b464ba58ea3ccef579e8df4745d75
Reviewed-on: https://go-review.googlesource.com/113915
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@gopherbot gopherbot modified the milestones: Go1.11, Unplanned May 23, 2018
navytux added a commit to navytux/go123 that referenced this issue Jul 10, 2018
Until golang/go#7873 is fixed/implemented,
let's follow the currently advised scheme to indent lists and this way
put them as pre-formatted text.

We already do so mostly everywhere, but 2 of the places were not
following it and thus all items there were rendered as one line.
@cespare cespare added the Proposal label Aug 2, 2018
@cespare

This comment has been minimized.

Copy link
Contributor

@cespare cespare commented Aug 2, 2018

I previously discussed turning this into a proposal but never did. Adding the label now, so that this gets discussed.

Current proposal is to go with @dsnet's suggestions in #7873 (comment) and #7873 (comment). Essentially, we'll take the current "standard" workaround for bulleted lists (indent so as to create a code block) and recognize it, turning it into a nice bullet list in HTML. We could optionally do something special for text (go doc) output but it's okay to leave that alone for now.

@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Aug 2, 2018

we'll take the current "standard" workaround for bulleted lists (indent so as to create a code block) and recognize it

In addition to the asterisks in @dsnet's sketch, we should probably also accept at least Unicode bullets (because they express clear semantic intent) and hyphen-minus characters (because that's what we use throughout the Go codebase) as the leading symbol to recognize a list.

@mwmahlberg

This comment has been minimized.

Copy link

@mwmahlberg mwmahlberg commented Dec 17, 2018

We think those comments can be ordinary text, and so far we're willing to stick to that.

Isn't that the whole point of markdown? That it can be read both as ordinary text but can also be rendered to a more eye-friendly form? I can see some problems here, for example on how to deal with markdown links (both of the hyper and image flavor), but those could be easily circumvented, couldn't it?

I personally would love to have markdown in my comments, since that would basically prevent me from redoing myself having both godoc comments and a more detailed explanation elsewhere. So basically, all documentation could be dealt with and would be present in one place.

@cespare cespare changed the title go/doc: Support for bulleted lists proposal: go/doc: Support for bulleted lists Dec 17, 2018
@cespare

This comment has been minimized.

Copy link
Contributor

@cespare cespare commented Dec 17, 2018

@mwmahlberg in the past year this thread has been converging on a small, concrete proposal for adding lists. That's also the title of the issue. It previously devolved into a markdown discussion, but I'd like for it to stay focused on just lists at this point in hopes that it will finally be reviewed and approved.

At this point, let's put new requests for markdown into a new issue or else add details to #16666. Thanks.

@cespare

This comment has been minimized.

Copy link
Contributor

@cespare cespare commented Dec 17, 2018

@golang/proposal-review is there something more to be done to move this along? (I understand that I can't expect much at this point during the last few weeks of the year, but I added the proposal label in August.)

@mwmahlberg

This comment has been minimized.

Copy link

@mwmahlberg mwmahlberg commented Dec 18, 2018

@cespare I understand that and did not mean to escalate the topic at hand. But my point of view is that the question at hand is basically a landmark decision: Open up for more formatted godocs or not? Because when it is started, more feature requests will come in: named links, tables, etc. Therefor, the reluctance is understandable. What I was trying to bring across that markdown|rst|foobar markup could be seen as a language feature with quite some value (DRY) for developers.

@rsc

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Dec 19, 2018

Generally, we'd like to allow writing lists in docs. Deciding the exact syntax is still unresolved. It's not a high priority right now.

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Mar 13, 2019

Change https://golang.org/cl/167403 mentions this issue: builtin: make len's godoc less ambiguous

gopherbot pushed a commit that referenced this issue Mar 13, 2019
The len godoc uses a blockquote to list the rules for its semantics.

The item that describes channels is a bit long, so it's split in two
lines. However, the first line ends with a semicolon, and the second
line can be read as a sentence of its own, so it's easy to misinterpret
that the two lines are separate.

Making that easy mistake would lead to an incorrect understanding of
len:

	if v is nil, len(v) is zero.

This could lead us to think that len(nil) is valid and should return
zero. When in fact, that statement only applies to nil channels.

To make this less ambiguous, add a bit of indentation to the follow-up
line, to align with the channel body. If lists are added to godoc in the
future via #7873, perhaps this text can be simplified.

Fixes #30349.

Change-Id: I84226edc812d429493137bcc65c332e92d4e6c87
Reviewed-on: https://go-review.googlesource.com/c/go/+/167403
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@rsc rsc added this to Hold in Proposals Dec 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
You can’t perform that action at this time.