LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // The doc package extracts source code documentation from a Go AST. | 5 // The doc package extracts source code documentation from a Go AST. |
6 package doc | 6 package doc |
7 | 7 |
8 import ( | 8 import ( |
9 "container/vector" | 9 "container/vector" |
10 "go/ast" | 10 "go/ast" |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 p.Bugs = makeBugDocs(doc.bugs) | 558 p.Bugs = makeBugDocs(doc.bugs) |
559 return p | 559 return p |
560 } | 560 } |
561 | 561 |
562 | 562 |
563 // ---------------------------------------------------------------------------- | 563 // ---------------------------------------------------------------------------- |
564 // Filtering by name | 564 // Filtering by name |
565 | 565 |
566 // Does s look like a regular expression? | 566 // Does s look like a regular expression? |
567 func isRegexp(s string) bool { | 567 func isRegexp(s string) bool { |
568 » return strings.IndexOfAny(s, ".(|)*+?^$[]") >= 0 | 568 » return strings.IndexAny(s, ".(|)*+?^$[]") >= 0 |
569 } | 569 } |
570 | 570 |
571 | 571 |
572 func match(s string, names []string) bool { | 572 func match(s string, names []string) bool { |
573 for _, t := range names { | 573 for _, t := range names { |
574 if isRegexp(t) { | 574 if isRegexp(t) { |
575 if matched, _ := regexp.MatchString(t, s); matched { | 575 if matched, _ := regexp.MatchString(t, s); matched { |
576 return true | 576 return true |
577 } | 577 } |
578 } | 578 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 // TODO: Recognize "Type.Method" as a name. | 655 // TODO: Recognize "Type.Method" as a name. |
656 // TODO(r): maybe precompile the regexps. | 656 // TODO(r): maybe precompile the regexps. |
657 // | 657 // |
658 func (p *PackageDoc) Filter(names []string) { | 658 func (p *PackageDoc) Filter(names []string) { |
659 p.Consts = filterValueDocs(p.Consts, names) | 659 p.Consts = filterValueDocs(p.Consts, names) |
660 p.Vars = filterValueDocs(p.Vars, names) | 660 p.Vars = filterValueDocs(p.Vars, names) |
661 p.Types = filterTypeDocs(p.Types, names) | 661 p.Types = filterTypeDocs(p.Types, names) |
662 p.Funcs = filterFuncDocs(p.Funcs, names) | 662 p.Funcs = filterFuncDocs(p.Funcs, names) |
663 p.Doc = "" // don't show top-level package doc | 663 p.Doc = "" // don't show top-level package doc |
664 } | 664 } |
LEFT | RIGHT |