summaryrefslogtreecommitdiff
path: root/src/pkg/go/doc/doc.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-09-16 16:56:20 -0700
committerRuss Cox <rsc@golang.org>2009-09-16 16:56:20 -0700
commit2dc7ecf72c238762e9ad3a9375e546c346b8bf8f (patch)
treead2826190b4595d979892df324bc206afce216b8 /src/pkg/go/doc/doc.go
parent3cea70516722c910d12fd28cbeb4aabb9d2873df (diff)
downloadgolang-2dc7ecf72c238762e9ad3a9375e546c346b8bf8f.tar.gz
publish doc.CommentText
R=gri DELTA=29 (10 added, 12 deleted, 7 changed) OCL=34709 CL=34712
Diffstat (limited to 'src/pkg/go/doc/doc.go')
-rw-r--r--src/pkg/go/doc/doc.go22
1 files changed, 5 insertions, 17 deletions
diff --git a/src/pkg/go/doc/doc.go b/src/pkg/go/doc/doc.go
index 0fcb7d860..5f9429bb1 100644
--- a/src/pkg/go/doc/doc.go
+++ b/src/pkg/go/doc/doc.go
@@ -304,18 +304,6 @@ func NewPackageDoc(pkg *ast.Package, importpath string) *PackageDoc {
// ----------------------------------------------------------------------------
// Conversion to external representation
-func astComment(comment *ast.CommentGroup) string {
- if comment != nil {
- text := make([]string, len(comment.List));
- for i, c := range comment.List {
- text[i] = string(c.Text);
- }
- return commentText(text);
- }
- return "";
-}
-
-
// ValueDoc is the documentation for a group of declared
// values, either vars or consts.
//
@@ -363,7 +351,7 @@ func makeValueDocs(v *vector.Vector, tok token.Token) []*ValueDoc {
for i := range d {
decl := v.At(i).(*ast.GenDecl);
if decl.Tok == tok {
- d[n] = &ValueDoc{astComment(decl.Doc), decl, i};
+ d[n] = &ValueDoc{CommentText(decl.Doc), decl, i};
n++;
decl.Doc = nil; // doc consumed - removed from AST
}
@@ -395,7 +383,7 @@ func makeFuncDocs(m map[string] *ast.FuncDecl) []*FuncDoc {
i := 0;
for _, f := range m {
doc := new(FuncDoc);
- doc.Doc = astComment(f.Doc);
+ doc.Doc = CommentText(f.Doc);
f.Doc = nil; // doc consumed - remove from ast.FuncDecl node
if f.Recv != nil {
doc.Recv = f.Recv.Type;
@@ -459,7 +447,7 @@ func (doc *docReader) makeTypeDocs(m map[string] *typeDoc) []*TypeDoc {
doc = decl.Doc;
}
decl.Doc = nil; // doc consumed - remove from ast.Decl node
- t.Doc = astComment(doc);
+ t.Doc = CommentText(doc);
t.Type = typespec;
t.Consts = makeValueDocs(old.values, token.CONST);
t.Vars = makeValueDocs(old.values, token.VAR);
@@ -499,7 +487,7 @@ func (doc *docReader) makeTypeDocs(m map[string] *typeDoc) []*TypeDoc {
func makeBugDocs(v *vector.Vector) []string {
d := make([]string, v.Len());
for i := 0; i < v.Len(); i++ {
- d[i] = astComment(v.At(i).(*ast.CommentGroup));
+ d[i] = CommentText(v.At(i).(*ast.CommentGroup));
}
return d;
}
@@ -530,7 +518,7 @@ func (doc *docReader) newDoc(pkgname, importpath, filepath string, filenames []s
p.FilePath = filepath;
sort.SortStrings(filenames);
p.Filenames = filenames;
- p.Doc = astComment(doc.doc);
+ p.Doc = CommentText(doc.doc);
// makeTypeDocs may extend the list of doc.values and
// doc.funcs and thus must be called before any other
// function consuming those lists