encoding/json: indentation of raw strings in examples looks suboptimal in godoc #21026
Closed
1 of 5 tasks
Labels
Documentation
Issues describing a change to documentation.
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
Suggested
Issues that may be good for new contributors looking for work to do.
Motivation
There are two ways a Go example can be read:
godoc
command or the web interface it provides.In most cases, examples look equally good in both interfaces. However, in some cases, there may be two alternative ways to write an example, such that one of them looks better inside source code, and the other looks better in the godoc interface.
My understanding is that it's better to prioritize the godoc interface over the source code, since most people will be reading examples via godoc (be it locally, or via https://godoc.org, or https://golang.org/pkg/). If that is not correct, the rest of this issue is not valid.
Issue
I found that there are 5 examples in
encoding/json
package that have raw strings with indentation which is suboptimal when seen via the godoc interface.They are:
https://tip.golang.org/pkg/encoding/json/#example_Decoder:
https://tip.golang.org/pkg/encoding/json/#example_Decoder_Decode_stream:
(Resolved by CL 48910.)
https://tip.golang.org/pkg/encoding/json/#example_Decoder_Token:
https://tip.golang.org/pkg/encoding/json/#example_Unmarshal:
https://tip.golang.org/pkg/encoding/json/#example_RawMessage_unmarshal:
Their readability in godoc interface can be improved by dedenting the contents of the raw string by 1 tab.
The text was updated successfully, but these errors were encountered: