Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(708)

Issue 7356043: code review 7356043: cmd/godoc: show examples in text mode (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 1 month ago by volker.dobler
Modified:
11 years, 1 month ago
Reviewers:
CC:
golang-dev, minux1, adg, rsc, gri
Visibility:
Public.

Description

cmd/godoc: show examples in text mode Added the command line flag -ex to godoc to print examples in text output. Samples from the generated output: $ godoc -ex strings Index ... func Index(s, sep string) int Index returns the index of the first instance of sep in s, or -1 if sep is not present in s. Example: fmt.Println(strings.Index("chicken", "ken")) fmt.Println(strings.Index("chicken", "dmr")) // Output: // 4 // -1 ... $ godoc -ex container/heap ... package heap import "container/heap" Package heap provides heap operations for any type that implements heap.Interface. A heap is a tree with the property that each node is the minimum-valued node in its subtree. Example: // This example demonstrates an integer heap built using the heap interface. package heap_test import ( "container/heap" "fmt" ... Example: // This example demonstrates a priority queue built using the heap interface. package heap_test import ( "container/heap" "fmt" ) ... Fixes issue 3587.

Patch Set 1 #

Patch Set 2 : diff -r f30bdd45914c https://code.google.com/p/go/ #

Patch Set 3 : diff -r f30bdd45914c https://code.google.com/p/go/ #

Total comments: 2

Patch Set 4 : diff -r 28f7394b058f https://code.google.com/p/go/ #

Patch Set 5 : diff -r dd18b993ba95 https://code.google.com/p/go/ #

Patch Set 6 : diff -r dd18b993ba95 https://code.google.com/p/go/ #

Total comments: 2

Patch Set 7 : diff -r 3b285c00863b https://code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+51 lines, -3 lines) Patch
M lib/godoc/package.txt View 1 2 3 4 5 3 chunks +8 lines, -3 lines 0 comments Download
M src/cmd/godoc/godoc.go View 1 2 3 4 5 6 3 chunks +43 lines, -0 lines 0 comments Download

Messages

Total messages: 16
volker.dobler
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go/
11 years, 1 month ago (2013-02-18 14:19:36 UTC) #1
minux1
As cmd/godoc already supports generating complete example code for its -play features, i'm wondering if ...
11 years, 1 month ago (2013-02-18 16:34:19 UTC) #2
adg
https://codereview.appspot.com/7356043/diff/3/src/cmd/godoc/godoc.go File src/cmd/godoc/godoc.go (right): https://codereview.appspot.com/7356043/diff/3/src/cmd/godoc/godoc.go#newcode372 src/cmd/godoc/godoc.go:372: header = fmt.Sprintf("\t// ------ Example %s ", example_nameFunc(eg.Name)) can't ...
11 years, 1 month ago (2013-02-19 06:24:07 UTC) #3
volker.dobler
That would be doable. One would have to decide what to output in the following ...
11 years, 1 month ago (2013-02-19 08:33:22 UTC) #4
volker.dobler
PTAL https://codereview.appspot.com/7356043/diff/3/src/cmd/godoc/godoc.go File src/cmd/godoc/godoc.go (right): https://codereview.appspot.com/7356043/diff/3/src/cmd/godoc/godoc.go#newcode372 src/cmd/godoc/godoc.go:372: header = fmt.Sprintf("\t// ------ Example %s ", example_nameFunc(eg.Name)) ...
11 years, 1 month ago (2013-02-19 08:38:27 UTC) #5
rsc
I suggest that as much as possible godoc -ex should mimic godoc -src. That means ...
11 years, 1 month ago (2013-02-19 16:22:10 UTC) #6
adg
On 19 February 2013 19:38, <dr.volker.dobler@gmail.com> wrote: > We can, I tried it. But it ...
11 years, 1 month ago (2013-02-19 23:39:02 UTC) #7
volker.dobler
On Wed, Feb 20, 2013 at 12:38 AM, Andrew Gerrand <adg@golang.org> wrote: > > On ...
11 years, 1 month ago (2013-02-20 00:41:39 UTC) #8
adg
On 20 February 2013 11:41, Volker Dobler <dr.volker.dobler@gmail.com> wrote: > They do, but the don't ...
11 years, 1 month ago (2013-02-20 00:46:41 UTC) #9
volker.dobler
PTAL > What if we pulled out the package comment and displayed > it one ...
11 years, 1 month ago (2013-02-20 10:27:43 UTC) #10
adg
LGTM, but I'd like to wait for gri's signoff.
11 years, 1 month ago (2013-02-21 03:10:00 UTC) #11
gri
This will have to wait for tomorrow. - gri On Wed, Feb 20, 2013 at ...
11 years, 1 month ago (2013-02-21 04:49:23 UTC) #12
gri
LGTM My only concern here is that this ads yet another flag - thus increasing ...
11 years, 1 month ago (2013-02-22 06:55:27 UTC) #13
adg
Will submit after this change: On 2013/02/22 06:55:27, gri wrote: > https://codereview.appspot.com/7356043/diff/20001/src/cmd/godoc/godoc.go > File src/cmd/godoc/godoc.go ...
11 years, 1 month ago (2013-02-24 22:43:58 UTC) #14
volker.dobler
PTAL https://codereview.appspot.com/7356043/diff/20001/src/cmd/godoc/godoc.go File src/cmd/godoc/godoc.go (right): https://codereview.appspot.com/7356043/diff/20001/src/cmd/godoc/godoc.go#newcode346 src/cmd/godoc/godoc.go:346: if first { On 2013/02/22 06:55:27, gri wrote: ...
11 years, 1 month ago (2013-02-24 23:21:56 UTC) #15
adg
11 years, 1 month ago (2013-02-24 23:37:40 UTC) #16
*** Submitted as https://code.google.com/p/go/source/detail?r=33d3e7bbd3ef ***

cmd/godoc: show examples in text mode

Added the command line flag -ex to godoc to print examples in
text output.

Samples from the generated output:

$ godoc -ex strings Index
...
func Index(s, sep string) int
    Index returns the index of the first instance of sep in s, or -1 if sep
    is not present in s.

    Example:
        fmt.Println(strings.Index("chicken", "ken"))
        fmt.Println(strings.Index("chicken", "dmr"))
        // Output:
        // 4
        // -1
...

$ godoc -ex container/heap
...
package heap
    import "container/heap"

    Package heap provides heap operations for any type that implements
    heap.Interface. A heap is a tree with the property that each node is the
    minimum-valued node in its subtree.

    Example:
        // This example demonstrates an integer heap built using the heap
interface.
        package heap_test

        import (
            "container/heap"
            "fmt"
        ...

    Example:
        // This example demonstrates a priority queue built using the heap
interface.
        package heap_test

        import (
            "container/heap"
            "fmt"
        )
...


Fixes issue 3587.

R=golang-dev, minux.ma, adg, rsc, gri
CC=golang-dev
https://codereview.appspot.com/7356043

Committer: Andrew Gerrand <adg@golang.org>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b