-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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/tools/cmd/godoc: request for richer formatting #16666
Comments
Where do you generally go to find documentation for the standard library? E.g., if you wanted to look at documentation for "fmt"? |
https://godoc.org/-/go and google |
I see. Have you ever clicked the "Packages" link at the top of golang.org? If so, did you think to click it at the top of localhost:6060? |
Related: #4953 There are docs on Go's formatting rules at https://golang.org/pkg/go/doc/#ToHTML It's not much, but it's something. We've decided against HTML and Markdown in the past and I don't think anything has changed. |
Yes I know it exists but for some reason I didn't notice the I can't think of any other documentation generator that is harder to use than:
With godoc, I have to:
|
I see. Thanks.
I didn't mean to imply it should be. I was asking genuine questions to understand your thought process and why the packages list was not more discoverable. |
Thanks for the link @bradfitz , I sumbled on it some time ago when randomly googling for the godoc syntax. It would be great to have that linked somewhere. In all honesty, I think that the decision should be rethought, and it looks like I'm not the only one. The go toolchain is superb, why ship a, imho inferior, documentation tool? It doesn't have to be HTML or Markdown either, as long as it is possible to write better docs. If the decision changes, I would love to help with this. I regularly catch myself avoiding godoc/golang.org and jump in the code instead, because I find it hard to read and find things. This has been the cause of me overlooking important details like closing response bodies ;) |
Ok, I misinterpreted that, sorry :) |
Always linking to the godoc.org partially solves the problem if it is not private. I don't seriously care clicking on the links during the development. But this is a pain for private repos without a private deployment of godoc.org.
You can escape code if you indent in godoc. Like DoSometing at https://godoc.org/golang.org/x/net/context. Are you mentioning another type of inlining? |
I do, because I want to know if my links work ;)
I don't know (well I do, because lists in godoc aren't lists, they are paragraphs which need a blank line):
Yes, I'm talking about |
This is what a list (actually paragraphs) look like in godoc. Needless to say that this doesn't look pretty with larger text as identation is missing.
On a side node: Thanks for being so super responsive all :) |
Another option: you can also use any UTF-8 in godoc, so you can format it as: • Item 1 • Item 2 • Item 3 Where the bullet (•) is just an actual Unicode bullet (U+2022). |
Or if you care about formatting, you indent it like code, and it ends up looking like:
|
So how would I format that using e.g. CSS? I think it's great that godoc supports UTF-8, but imho it's questionable if these type of workarounds are: a. user/developer friendly Plus, this is not only about lists, it's about more things that are missing imo. GitHub has made writing documentation great, why not take the good parts of this process every developer today is used to and introduce them to go? |
There are several different ideas here. I don't know which are more important. Something like "support markdown in godoc" should go through the proposal process. It will require somebody to implement it. |
The vision should be to improve the process of writing documentation in Go. Weighting features and discussing what people need or don't need should be an essential part of it. A proposal is a good idea, unless this means that the issue will just be pushed back until forever. I would gladly contribute to this and I'm sure other gophers will too. |
I like that Go documentation doesn't interpret markdown. It makes the documentation easier to read with go doc pkgname. I don't miss |
Then again, |
Most of the time I read the documentation in a text editor along with the code. So many things like images, links, emphasis, etc cannot be displayed. These features might make HTML version of the documentation better looking but the text version might become harder to read. One case when readability of HTML documentation is inferior to the text version is list formatting (#7873). I would love to see it fixed. |
Please accept my apologies for the mail spam created by replying to this thread; I have some interest / experience in this area having developed and used a formatting markup of my own devising for 8 years now. Before I even talk about possible syntax to use; a policy you could adopt is to introduce formatting syntax only one, complete instance at a time (each Go release for example) -- allowing time for discussion and seeing what happens to it out in the wild. My own markup system was developed specifically to look best as raw text as I would primarily be editing it in a text editor. I won't recommend my own syntax as-is, but I can provide some lessons learnt.
A markup syntax should communicate the programmer's voice rather than force them to micro-manage semantics; such as being forced to apply markup for all Proper Names they desire to be interlinked. Where possible of course, If I had to provide a solution with the noted concern of burdening documentation writers the world over, then these are the two solutions I propose:
Most all markup syntaxes don't include Definition Lists, and this is very sad! :(
I provide this as an alternative to consider too:
I have spent a long time sweating details over plain-text presentation of markup syntax as I was not content to accept existing systems that lean to heavy on being languages of their own; I can understand very much why Google wanted to keep documentation comments as natural as possible. My ideas on this issue are forever evolving. If you're interested in seeing more of my markup syntax, please browse over the following two guides: Again, sorry if this comes across as spam, but I feel like this is an area of design that I can really contribute to. Kind regards, |
Don't worry, I'd rather have 100 mails of GitHub notifications regarding discussion / ideas / contributions to a topic than none. :) |
Aside note: I have notice Google itself uses Markdown in their godoc. :D https://pkg.go.dev/google.golang.org/genproto/googleapis/api/annotations?tab=doc#HttpRule |
Hi, can we do something for this? Any pointers on where to start? |
I am not that qualified to work on this, but maybe start on looking into As for Markdown parsing and rendering, I can recommend using https://github.com/yuin/goldmark which is now used by Hugo and is CommonMark compliant. (Markdown is really tricky to parse!) |
Maybe it, however, needs to go through go proposals first, and I have no idea how does that work. |
IMHO, an important thing is to highlight in some way (
This helps a lot to read the docs and to understand what a param does. |
Are there any plans to have a markdown-like syntax in the future? |
closing for new syntax in go.dev/doc/comment |
Documenting Go code is not fun. At all. That this benefits bad behaviour (:= no/little docs) is obvious.
It's not clear in which path your documentation will be available when running
godoc -http=:6060
. I had to ask in slack to find out it'slocalhost:6060/pkg/github.com/foo/bar
. I tried variations likelocalhost:6060/github.com/foo/bar
orlocalhost:6060/src/github.com/foo/bar
which obviously didn't work.Not having lists around is a real pain. How am I supposed to do something like this:
It's not clear (to me) how to link from package a to package b and get that working in both godoc.org and with
godoc
.I can't link text.
I can't load images.
There is no emphasis, I overread important things all the time because I'm too lazy concentrating on 10 lines of plain text when a simple Note: Don't do this if XYZ would most certainly solve that.
There is no instruction for inheritance, for example when implementing interfaces.
No inline
code
.Probably more stuff (feel free to extend) but it's late and I'm tired and frustrated.
My suggestion is to have markdown or simple HTML, it would solve almost all of the problems above and a godoc command that actually does what it says: serving the docs of the cwd (and optionally other GOPATH packages too).
The issue number (it's a sign) gives me hope that documenting go code will get better soon.
The text was updated successfully, but these errors were encountered: