зеркало из https://github.com/golang/gddo.git
Merge pull request #382 from lucidlime/i308
Remove play links for pkgs outside std lib
This commit is contained in:
Коммит
c2293cd10a
|
@ -171,7 +171,7 @@
|
|||
<div class="panel-heading"><a class="accordion-toggle" data-toggle="collapse" href="#ex-{{.ID}}">Example{{with .Example.Name}} ({{.}}){{end}}</a></div>
|
||||
<div id="ex-{{.ID}}" class="panel-collapse collapse"><div class="panel-body">
|
||||
{{with .Example.Doc}}<p>{{.|comment}}{{end}}
|
||||
<p>Code:{{if .Example.Play}}<span class="pull-right"><a href="?play={{.ID}}">play</a> </span>{{end}}
|
||||
<p>Code:{{if .Play}}<span class="pull-right"><a href="?play={{.ID}}">play</a> </span>{{end}}
|
||||
{{code .Example.Code nil}}
|
||||
{{with .Example.Output}}<p>Output:<pre>{{.}}</pre>{{end}}
|
||||
</div></div>
|
||||
|
|
|
@ -85,6 +85,7 @@ type texample struct {
|
|||
ID string
|
||||
Label string
|
||||
Example *doc.Example
|
||||
Play bool
|
||||
obj interface{}
|
||||
}
|
||||
|
||||
|
@ -121,7 +122,14 @@ func (pdoc *tdoc) addExamples(obj interface{}, export, method string, examples [
|
|||
id += "-" + method
|
||||
}
|
||||
for _, e := range examples {
|
||||
te := &texample{Label: label, ID: id, Example: e, obj: obj}
|
||||
te := &texample{
|
||||
Label: label,
|
||||
ID: id,
|
||||
Example: e,
|
||||
obj: obj,
|
||||
// Only show play links for packages within the standard library.
|
||||
Play: e.Play != "" && gosrc.IsGoRepoPath(pdoc.ImportPath),
|
||||
}
|
||||
if e.Name != "" {
|
||||
te.Label += " (" + e.Name + ")"
|
||||
if method == "" {
|
||||
|
|
Загрузка…
Ссылка в новой задаче