Merge pull request #382 from lucidlime/i308

Remove play links for pkgs outside std lib
This commit is contained in:
Andrew Gerrand 2016-03-07 14:44:02 +11:00
Родитель 54beb575c6 7eb2cbafe8
Коммит c2293cd10a
2 изменённых файлов: 10 добавлений и 2 удалений

Просмотреть файл

@ -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>&nbsp;</span>{{end}}
<p>Code:{{if .Play}}<span class="pull-right"><a href="?play={{.ID}}">play</a>&nbsp;</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 == "" {