Repository navigation
testing: leading spaces in Example output are dropped from godoc display #4487
Copy link
Copy link
Closed
Labels
FrozenDueToAgeSuggestedIssues that may be good for new contributors looking for work to do.Issues that may be good for new contributors looking for work to do.
Milestone
Description
rsc
opened on Dec 4, 2012
Issue body actions
Reactions are currently unavailable
Activity
This behavior is inherent to the Example parsing in go/doc -- it calls strings.TrimSpace on Output. This seems wrong to me not only for the purposes of displaying the Example but for testing as well. One might well construct a whitespace-sensitive example that doesn't fail as expected; for instance, the following actual outputs are accepted by the right-leaning triangle example output: * ** *** * ** *** The testing documentation isn't explicit about the behavior here. What if the output parsing were changed? Right now, doc.Examples removes all leading/trailing whitespace; what if instead it only removed /^[ ]*\n?/ ? I think that's a more intuitive behavior that works for both the single-line (e.g., '// Output: hi') and multi-line output targets. The trimming of the actual output would have to be adjusted correspondingly. I'm happy to make these changes but wanted some feedback first.* Does an issue having an owner imply "don't work on this"? * According to http://swtch.com/~rsc/go11.html, the 'Suggested' label is "suggested for people looking for work" Thanks for the clarification; this is not covered in http://golang.org/doc/contribute.html.
This is what the docs for (*CommentGroup) Text() in go/ast indicate. "Comment markers (//, /*, and */), the first space of a line comment, and leading and trailing empty lines are removed." Here's an example: http://play.golang.org/p/PWA4tmcnOe
This is merely the result of some over-aggressive trimming. The fix is simple: https://golang.org/cl/7057048/
Status changed to Started.
- addedSuggestedIssues that may be good for new contributors looking for work to do.Issues that may be good for new contributors looking for work to do.
on Jan 7, 2013 - locked and limited conversation to collaborators
on Jun 24, 2016
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeSuggestedIssues that may be good for new contributors looking for work to do.Issues that may be good for new contributors looking for work to do.