Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommentToHTML ¶
func CommentToHTML(gs ...*ast.CommentGroup) (string, error)
CommentToHTML converts the given CommentGroups to HTML. The text content of the CommentGroups is stripped off of the comment markers, joined, and then passed on to TextToHTML. See the TextToHTML documentation for the conversion rules.
func TextToHTML ¶
TextToHTML converts the given text string to HTML. TextToHTML provides support for a tiny subset of Markdown to allow for some formatting.
Conversion rules:
- A span of unindented non-blank lines is converted into a paragraph.
- A span of indented lines is converted into a <pre> block, with the common indent prefix removed.
- Text wrapped in backticks is converted into a <code> element.
- Text wrapped in a pair of single asterisks, i.e. "*foo bar*", is converted into an <em> element.
- Text wrapped in a pair of double asterisks, i.e. "**foo bar**", is converted into a <strong> element.
- URLs are converted into links.
- URLs wrapped in parentheses and preceded by text delimited by square brackets are converted into links with the text being the link. e.g. [an example](http://example.com/) is converted into <a href="http://example.com/">an example</a>. Support for the title attribute is not provided.
Types ¶
type Const ¶
type Const struct { Name string // The constant's identifier. // The constant's documentation formatted as HTML. Desc string Value string // The contant's value. // Source position of the const's declaration. Pos *Position }
Const contains arbitrary information about a const declaration of a specific Go type.
type Field ¶
type Field struct { // The field's identifier. Name string // The field's documentation, if any, formatted as HTML. Desc string // The field's type information. Type Type // The parsed tag string of the field if present, nil otherwise. // If the tag string does no follow the conventional format specified // in Go's reflect package the resulting value is undefined. Tag Tag }
Field contains inforamtion about a struct field.
type Position ¶
type Position struct { Filename string // filename, if any Offset int // offset, starting at 0 Line int // line number, starting at 1 Column int // column number, starting at 1 (byte count) }
NOTE(mkopriva): Position is copied from go/token.Position.
Position describes an arbitrary source position including the file, line, and column location. A Position is valid if the line number is > 0.
type Type ¶
type Type struct { // The type's name, for unnamed or predeclared types Name will be set // to the reflect.Kind's name. Name string // The type's package path, for unnamed or predeclared types PkgPath // will be the empty string. PkgPath string // The type's documentation, if it has any, formatted as HTML. Desc string // If the type is "constable" the Consts field will hold a list of // associated const declarations, otherwise it will be nil. Consts []*Const // If the type is a struct the Fields field will hold a list of // the struct fields, otherwise it will be nil. Fields []*Field // If the type is a "container" for another type i.e. a slice, an array, // a map, or a pointer the Elem field will hold the Type information of // the base element of the container, otherwise it will be nil. // For example if the type is something like [][]*T or map[string][2]**U // Elem would hold the Type info of T and U respectively. Elem *Type // The type's source position of its declaration. Pos *Position // contains filtered or unexported fields }
Type contains arbitrary information about a Go type; e.g. its name, ast expression, documentation, associated const declarations if applicable, source position, etc.