internal/godoc/dochtml/internal/render: export OneLineNodeDepth

For golang/go#37102

Change-Id: Ifdf3ca6db8667c3d90028301d9526ec2899df2a3
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/288755
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Trust: Julie Qiu <julie@golang.org>
diff --git a/internal/godoc/dochtml/internal/render/render.go b/internal/godoc/dochtml/internal/render/render.go
index a13f6e5..ac5f0c9 100644
--- a/internal/godoc/dochtml/internal/render/render.go
+++ b/internal/godoc/dochtml/internal/render/render.go
@@ -157,7 +157,7 @@
 
 // Synopsis returns a one-line summary of the given input node.
 func (r *Renderer) Synopsis(n ast.Node) string {
-	return oneLineNodeDepth(r.fset, n, 0)
+	return OneLineNodeDepth(r.fset, n, 0)
 }
 
 // DocHTML formats documentation text as HTML.
diff --git a/internal/godoc/dochtml/internal/render/synopsis.go b/internal/godoc/dochtml/internal/render/synopsis.go
index 629ec3d..bd90c20 100644
--- a/internal/godoc/dochtml/internal/render/synopsis.go
+++ b/internal/godoc/dochtml/internal/render/synopsis.go
@@ -13,10 +13,10 @@
 	"strings"
 )
 
-// oneLineNodeDepth returns a one-line summary of the given input node.
+// OneLineNodeDepth returns a one-line summary of the given input node.
 // The depth specifies the current depth when traversing the AST and the
 // function will stop traversing once depth reaches maxSynopsisNodeDepth.
-func oneLineNodeDepth(fset *token.FileSet, node ast.Node, depth int) string {
+func OneLineNodeDepth(fset *token.FileSet, node ast.Node, depth int) string {
 	const dotDotDot = "..."
 	if depth == maxSynopsisNodeDepth {
 		return dotDotDot
@@ -45,20 +45,20 @@
 				// The type name may carry over from a previous specification in the
 				// case of constants and iota.
 				if valueSpec.Type != nil {
-					typ = fmt.Sprintf(" %s", oneLineNodeDepth(fset, valueSpec.Type, depth))
+					typ = fmt.Sprintf(" %s", OneLineNodeDepth(fset, valueSpec.Type, depth))
 				} else if len(valueSpec.Values) > 0 {
 					typ = ""
 				}
 
 				val := ""
 				if i < len(valueSpec.Values) && valueSpec.Values[i] != nil {
-					val = fmt.Sprintf(" = %s", oneLineNodeDepth(fset, valueSpec.Values[i], depth))
+					val = fmt.Sprintf(" = %s", OneLineNodeDepth(fset, valueSpec.Values[i], depth))
 				}
 				return fmt.Sprintf("%s %s%s%s%s", n.Tok, valueSpec.Names[0], typ, val, trailer)
 			}
 		case token.TYPE:
 			if len(n.Specs) > 0 {
-				return oneLineNodeDepth(fset, n.Specs[0], depth) + trailer
+				return OneLineNodeDepth(fset, n.Specs[0], depth) + trailer
 			}
 		case token.IMPORT:
 			if len(n.Specs) > 0 {
@@ -71,11 +71,11 @@
 	case *ast.FuncDecl:
 		// Formats func declarations.
 		name := n.Name.Name
-		recv := oneLineNodeDepth(fset, n.Recv, depth)
+		recv := OneLineNodeDepth(fset, n.Recv, depth)
 		if len(recv) > 0 {
 			recv = "(" + recv + ") "
 		}
-		fnc := oneLineNodeDepth(fset, n.Type, depth)
+		fnc := OneLineNodeDepth(fset, n.Type, depth)
 		if strings.Index(fnc, "func") == 0 {
 			fnc = fnc[4:]
 		}
@@ -86,7 +86,7 @@
 		if n.Assign.IsValid() {
 			sep = " = "
 		}
-		return fmt.Sprintf("type %s%s%s", n.Name.Name, sep, oneLineNodeDepth(fset, n.Type, depth))
+		return fmt.Sprintf("type %s%s%s", n.Name.Name, sep, OneLineNodeDepth(fset, n.Type, depth))
 
 	case *ast.FuncType:
 		var params []string
@@ -137,35 +137,35 @@
 		return dotDotDot
 
 	case *ast.FuncLit:
-		return oneLineNodeDepth(fset, n.Type, depth) + " { ... }"
+		return OneLineNodeDepth(fset, n.Type, depth) + " { ... }"
 
 	case *ast.CompositeLit:
-		typ := oneLineNodeDepth(fset, n.Type, depth)
+		typ := OneLineNodeDepth(fset, n.Type, depth)
 		if len(n.Elts) == 0 {
 			return fmt.Sprintf("%s{}", typ)
 		}
 		return fmt.Sprintf("%s{ %s }", typ, dotDotDot)
 
 	case *ast.ArrayType:
-		length := oneLineNodeDepth(fset, n.Len, depth)
-		element := oneLineNodeDepth(fset, n.Elt, depth)
+		length := OneLineNodeDepth(fset, n.Len, depth)
+		element := OneLineNodeDepth(fset, n.Elt, depth)
 		return fmt.Sprintf("[%s]%s", length, element)
 
 	case *ast.MapType:
-		key := oneLineNodeDepth(fset, n.Key, depth)
-		value := oneLineNodeDepth(fset, n.Value, depth)
+		key := OneLineNodeDepth(fset, n.Key, depth)
+		value := OneLineNodeDepth(fset, n.Value, depth)
 		return fmt.Sprintf("map[%s]%s", key, value)
 
 	case *ast.CallExpr:
-		fnc := oneLineNodeDepth(fset, n.Fun, depth)
+		fnc := OneLineNodeDepth(fset, n.Fun, depth)
 		var args []string
 		for _, arg := range n.Args {
-			args = append(args, oneLineNodeDepth(fset, arg, depth))
+			args = append(args, OneLineNodeDepth(fset, arg, depth))
 		}
 		return fmt.Sprintf("%s(%s)", fnc, joinStrings(args))
 
 	case *ast.UnaryExpr:
-		return fmt.Sprintf("%s%s", n.Op, oneLineNodeDepth(fset, n.X, depth))
+		return fmt.Sprintf("%s%s", n.Op, OneLineNodeDepth(fset, n.X, depth))
 
 	case *ast.Ident:
 		return n.Name
@@ -189,9 +189,9 @@
 		names = append(names, name.Name)
 	}
 	if len(names) == 0 {
-		return oneLineNodeDepth(fset, field.Type, depth)
+		return OneLineNodeDepth(fset, field.Type, depth)
 	}
-	return joinStrings(names) + " " + oneLineNodeDepth(fset, field.Type, depth)
+	return joinStrings(names) + " " + OneLineNodeDepth(fset, field.Type, depth)
 }
 
 // joinStrings formats the input as a comma-separated list,
diff --git a/internal/godoc/dochtml/internal/render/synopsis_test.go b/internal/godoc/dochtml/internal/render/synopsis_test.go
index 29a1470..cbcd17d 100644
--- a/internal/godoc/dochtml/internal/render/synopsis_test.go
+++ b/internal/godoc/dochtml/internal/render/synopsis_test.go
@@ -170,7 +170,7 @@
 
 	// Print the imports from the file's AST.
 	for i, d := range f.Decls {
-		got := oneLineNodeDepth(fset, d, 0)
+		got := OneLineNodeDepth(fset, d, 0)
 		if got != want[i] {
 			t.Errorf("test %d, oneLineNode():\ngot  %s\nwant %s", i, got, want[i])
 		}