Involved Source Files
Package dochtml renders Go package documentation into HTML.
This package and its API are under development (see golang.org/issue/39883).
The plan is to iterate on the development internally for x/pkgsite
needs first, before factoring it out somewhere non-internal where its
API can no longer be easily modified.
io.gosymbol.gotemplate.go
Package-Level Type Names (total 9, in which 3 are exported)
RenderOptions are options for Render.
FileLinkFunc optionally specifies a function that
returns a URL where file should be linked to.
file is the name component of a .go file in the package,
including the .go qualifier.
As a special case, FileLinkFunc may return the empty
string to indicate that a given file should not be linked.
// If zero, a default limit of 10 megabytes is used.
ModInfo optionally specifies information about the module the package
belongs to in order to render module-related documentation.
SinceVersionFuncfunc(name string) stringSourceLinkFuncfunc(ast.Node) string
func golang.org/x/pkgsite/internal/godoc.(*Package).renderOptions(innerPath string, sourceInfo *source.Info, modInfo *godoc.ModuleInfo, nameToVersion map[string]string) RenderOptions
func Render(ctx context.Context, fset *token.FileSet, p *doc.Package, opt RenderOptions) (_ *Parts, err error)
func renderInfo(ctx context.Context, fset *token.FileSet, p *doc.Package, opt RenderOptions) (map[string]interface{}, templateData, func() []render.Link)
example is an internal representation of a single example.
Example*doc.ExampleExample.Comments[]*ast.CommentGroup
// example function doc string
// expect empty output
// name of the item being exemplified (including optional suffix)
// original source code order
// expected output
// a whole program version of the example
Example.Unorderedbool
// ID of example
// ID of top-level declaration this example is attached to
// optional suffix name in title case
Code returns an printer.CommentedNode if ex.Comments is non-nil,
otherwise it returns ex.Code as is.
func funcsToItems(fs []*doc.Func, hclass, typeName string, exmap map[string][]*example) []*item
func packageToItems(p *doc.Package, exmap map[string][]*example) (consts, vars, funcs, types []*item)
func typeToItem(t *doc.Type, exmap map[string][]*example) *item
examples is an internal representation of all package examples.
// sorted by ParentID
// keyed by top-level ID (e.g., "NewRing" or "PubSub.Receive") or empty string for package examples
func collectExamples(p *doc.Package) *examples
An item is rendered as one piece of documentation. It is essentially a union
of the Value, Type and Func types from internal/doc, along with additional
information for HTML rendering, like class names.
// for types
// GenDecl for consts, vars and types; FuncDecl for functions
Docstring
// for types and functions; empty for vars and consts
// for methods, the type name + "." + Name; else same as Name
// for types
// class for header
// text of header, before source link
IsDeprecatedbool
HTML-specific values, for types and functions
// for data-kind attribute
// for types
// for types and functions; empty for consts and vars
// for types
func funcsToItems(fs []*doc.Func, hclass, typeName string, exmap map[string][]*example) []*item
func packageToItems(p *doc.Package, exmap map[string][]*example) (consts, vars, funcs, types []*item)
func typeToItem(t *doc.Type, exmap map[string][]*example) *item
func valuesToItems(vs []*doc.Value) []*item
func valueToItem(v *doc.Value) *item
limitBuffer is designed to apply a limit on the number of bytes
that are allowed to be written to a *bytes.Buffer.
As long as Remain is a non-negative value, writes to limitBuffer
are passed through to the underlying buffer B, decreasing Remain
by the number of bytes written.
If more than Remain bytes have been attempted to be written to B,
Remain becomes a negative value, and limitBuffer.Write starts to
always return io.ErrShortWrite without writing to B.
// Underlying buffer.
// Until writes fail. Negative value means went beyond limit.
Write implements io.Writer.
*T : github.com/go-git/go-git/v5/plumbing/protocol/packp/sideband.Progress
*T : github.com/jbenet/go-context/io.Writer
*T : io.Writer
Package-Level Functions (total 26, in which 4 are exported)
GetSymbols renders package documentation HTML for the
provided file set and package, in separate parts.
If any of the rendered documentation part HTML sizes exceeds the specified
limit, an error with ErrTooLarge in its chain will be returned.
LoadTemplates reads and parses the templates used to generate documentation.
Render renders package documentation HTML for the
provided file set and package, in separate parts.
If any of the rendered documentation part HTML sizes exceeds the specified limit,
an error with ErrTooLarge in its chain will be returned.
WalkExamples calls fn for each Example in p,
setting id to the name of the parent structure.
buildNoteHeaders constructs note headers from note markers.
It returns a map from each marker to its corresponding noteHeader.
collectExamples extracts examples from p
into the internal examples representation.
linkHTML returns an HTML-formatted name linked to the given URL.
The class argument is the class of the 'a' tag.
If url is the empty string, the name is not linked.
versionedPkgPath transforms package paths to contain the same version as the
current module if the package belongs to the module. As a special case,
versionedPkgPath will not add versions to standard library packages.
Package-Level Variables (total 6, in which 1 are exported)
ErrTooLarge represents an error where the rendered documentation HTML
size exceeded the specified limit. See the RenderOptions.Limit field.
TODO(golang.org/issue/5060): finalize URL scheme and design for notes,
then it becomes more viable to factor out inline CSS style.
The pages are generated with Goldsv0.3.2-preview. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.