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: x/tools/godoc: add the ability to customize example_text #24862
Comments
Looking at the patch: https://github.com/golang/tools/pull/33/files I'm still a little confused about what you're proposing. Do you have screenshots maybe or a URL that contains a concrete example? |
IIUC, you want to import IMO, this is shoe-horning the code base to satisfy a different purpose. If you look at the code change without external context, it is very hard to reason why this is being done, which is for external code to be able to generate markdown. While I am not against generating markdown, this seems to be the incorrect approach. One should not have to import the godoc package at all to generate markdown. I would expect there to be a button in the package page which can be clicked and a .md file gets downloaded. |
The idea was to be able to have the
It just sounded dumb to me to have to rewrite a big function when the change I'd need to do in the core library would be really small. The need of godoc is there because what is generated is the go documentation of the package. It's just in another format than the ones currently available. |
You can already import go/doc and get a doc.Example and format it however you like. That seems like a clearer path forward than making godoc extensible in a way that it doesn't need. I would expect a godoc2md to use go/doc this way too. Don't do it by rewriting godoc itself. |
Version / OS / Processor:
go version go1.10rc2 linux/amd64
(Debian)Does this issue reproduce with the latest release?
Yes.
What did you do?
While working on a PR for godoc2md I needed to customize the example_text function to make it available as markdown text: davecheney/godoc2md#20
To do that I had to copy/paste quite big chunks of code for very minimal changes.
In fact I had a PR open on tool/godoc to add a new function that would allow people to change the example's title and add text surrounding the example code: golang/tools#33
This would impact any of the existing functionnalities and would allow people to avoid having to create custom code for these kind of usage (can be reused for generating doc in languages like asciidoc, rst, etc).
The text was updated successfully, but these errors were encountered: