aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-04-15 18:53:43 -0700
committerRuss Cox <rsc@golang.org>2009-04-15 18:53:43 -0700
commit1605176e25fd5f7d2136e52797a0b2fa6e1f8947 (patch)
tree2c7a9ef080f170e080594da4e8674f54a8aa44dd /src/lib
parentbafd1787fe683f33a893e558e57b1d005af2bbca (diff)
downloadgo-1605176e25fd5f7d2136e52797a0b2fa6e1f8947.tar.xz
godoc: use data-driven templates for html, text generation
R=gri DELTA=1341 (668 added, 282 deleted, 391 changed) OCL=27485 CL=27526
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/go/ast.go32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/lib/go/ast.go b/src/lib/go/ast.go
index 9ee88c3696..beaa743ac4 100644
--- a/src/lib/go/ast.go
+++ b/src/lib/go/ast.go
@@ -7,7 +7,11 @@
//
package ast
-import "token"
+import (
+ "token";
+ "unicode";
+ "utf8";
+)
// ----------------------------------------------------------------------------
@@ -45,7 +49,7 @@ type Expr interface {
// visitor v invokes the node-specific DoX function of the visitor.
//
Visit(v ExprVisitor);
-
+
// Pos returns the (beginning) position of the expression.
Pos() token.Position;
}
@@ -57,7 +61,7 @@ type Stmt interface {
// visitor v invokes the node-specific DoX function of the visitor.
//
Visit(v StmtVisitor);
-
+
// Pos returns the (beginning) position of the statement.
Pos() token.Position;
}
@@ -69,7 +73,7 @@ type Decl interface {
// visitor v invokes the node-specific DoX function of the visitor.
//
Visit(v DeclVisitor);
-
+
// Pos returns the (beginning) position of the declaration.
Pos() token.Position;
}
@@ -419,6 +423,24 @@ func (x *MapType) Visit(v ExprVisitor) { v.DoMapType(x); }
func (x *ChanType) Visit(v ExprVisitor) { v.DoChanType(x); }
+// IsExported returns whether name is an exported Go symbol
+// (i.e., whether it begins with an uppercase letter).
+func IsExported(name string) bool {
+ ch, len := utf8.DecodeRuneInString(name, 0);
+ return unicode.IsUpper(ch);
+}
+
+// IsExported returns whether name is an exported Go symbol
+// (i.e., whether it begins with an uppercase letter).
+func (name *ast.Ident) IsExported() bool {
+ return IsExported(name.Value);
+}
+
+func (name *ast.Ident) String() string {
+ return name.Value;
+}
+
+
// ----------------------------------------------------------------------------
// Statements
@@ -688,7 +710,7 @@ type (
// A declaration is represented by one of the following declaration nodes.
//
-type (
+type (
// A BadDecl node is a placeholder for declarations containing
// syntax errors for which no correct declaration nodes can be
// created.