mirror of https://github.com/golang/go.git
godoc: Output "No match found" only if there is no ast or docs included in info.
Fixes golang/go#7499. R=minux.ma CC=golang-codereviews https://golang.org/cl/75400043
This commit is contained in:
parent
7c69950f7f
commit
a81074af88
|
|
@ -16,32 +16,42 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var godocTests = []struct {
|
var godocTests = []struct {
|
||||||
args []string
|
args []string
|
||||||
matches []string // regular expressions
|
matches []string // regular expressions
|
||||||
|
dontmatch []string // regular expressions
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
[]string{"fmt"},
|
args: []string{"fmt"},
|
||||||
[]string{
|
matches: []string{
|
||||||
`import "fmt"`,
|
`import "fmt"`,
|
||||||
`Package fmt implements formatted I/O`,
|
`Package fmt implements formatted I/O`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[]string{"io", "WriteString"},
|
args: []string{"io", "WriteString"},
|
||||||
[]string{
|
matches: []string{
|
||||||
`func WriteString\(`,
|
`func WriteString\(`,
|
||||||
`WriteString writes the contents of the string s to w`,
|
`WriteString writes the contents of the string s to w`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[]string{"nonexistingpkg"},
|
args: []string{"nonexistingpkg"},
|
||||||
[]string{
|
matches: []string{
|
||||||
`no such file or directory|does not exist`,
|
`no such file or directory|does not exist`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[]string{"fmt", "NonexistentSymbol"},
|
args: []string{"fmt", "NonexistentSymbol"},
|
||||||
[]string{
|
matches: []string{
|
||||||
|
`No match found\.`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
args: []string{"-src", "syscall", "Open"},
|
||||||
|
matches: []string{
|
||||||
|
`func Open\(`,
|
||||||
|
},
|
||||||
|
dontmatch: []string{
|
||||||
`No match found\.`,
|
`No match found\.`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -78,5 +88,11 @@ func TestGodoc(t *testing.T) {
|
||||||
t.Errorf("godoc %v =\n%s\nwanted /%v/", strings.Join(test.args, " "), out, pat)
|
t.Errorf("godoc %v =\n%s\nwanted /%v/", strings.Join(test.args, " "), out, pat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for _, pat := range test.dontmatch {
|
||||||
|
re := regexp.MustCompile(pat)
|
||||||
|
if re.Match(out) {
|
||||||
|
t.Errorf("godoc %v =\n%s\ndid not want /%v/", strings.Join(test.args, " "), out, pat)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
*/}}{{if and $filtered (not .PDoc)}}No match found.
|
*/}}{{if and $filtered (not (or .PDoc .PAst))}}No match found.
|
||||||
{{end}}{{with .PDoc}}{{if $.IsMain}}COMMAND DOCUMENTATION
|
{{end}}{{with .PDoc}}{{if $.IsMain}}COMMAND DOCUMENTATION
|
||||||
|
|
||||||
{{comment_text .Doc " " "\t"}}
|
{{comment_text .Doc " " "\t"}}
|
||||||
|
|
@ -111,4 +111,4 @@ package {{.Name}}
|
||||||
*/}}{{end}}{{/*
|
*/}}{{end}}{{/*
|
||||||
Make sure there is no newline at the end of this file.
|
Make sure there is no newline at the end of this file.
|
||||||
perl -i -pe 'chomp if eof' package.txt
|
perl -i -pe 'chomp if eof' package.txt
|
||||||
*/}}
|
*/}}
|
||||||
|
|
|
||||||
|
|
@ -762,7 +762,7 @@ $(document).ready(function() {
|
||||||
|
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
*/}}{{if and $filtered (not .PDoc)}}No match found.
|
*/}}{{if and $filtered (not (or .PDoc .PAst))}}No match found.
|
||||||
{{end}}{{with .PDoc}}{{if $.IsMain}}COMMAND DOCUMENTATION
|
{{end}}{{with .PDoc}}{{if $.IsMain}}COMMAND DOCUMENTATION
|
||||||
|
|
||||||
{{comment_text .Doc " " "\t"}}
|
{{comment_text .Doc " " "\t"}}
|
||||||
|
|
@ -866,7 +866,8 @@ package {{.Name}}
|
||||||
*/}}{{end}}{{/*
|
*/}}{{end}}{{/*
|
||||||
Make sure there is no newline at the end of this file.
|
Make sure there is no newline at the end of this file.
|
||||||
perl -i -pe 'chomp if eof' package.txt
|
perl -i -pe 'chomp if eof' package.txt
|
||||||
*/}}`,
|
*/}}
|
||||||
|
`,
|
||||||
"play.js": `// Copyright 2012 The Go Authors. All rights reserved.
|
"play.js": `// Copyright 2012 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue