pkgsite: golang.org/x/pkgsite/internal/fetch/dochtml Index | Files | Directories

package dochtml

import "golang.org/x/pkgsite/internal/fetch/dochtml"

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.

Index

Package Files

dochtml.go io.go template.go

Variables

var (
    // ErrTooLarge represents an error where the rendered documentation HTML
    // size exceeded the specified limit. See the RenderOptions.Limit field.
    ErrTooLarge = errors.New("rendered documentation HTML size exceeded the specified limit")
)

func Render Uses

func Render(ctx context.Context, fset *token.FileSet, p *doc.Package, opt RenderOptions) (safehtml.HTML, error)

Render renders package documentation HTML for the provided file set and package.

If the rendered documentation HTML size exceeds the specified limit, an error with ErrTooLarge in its chain will be returned.

func WalkExamples Uses

func WalkExamples(p *doc.Package, fn func(id string, ex *doc.Example))

WalkExamples calls fn for each Example in p, setting id to the name of the parent structure.

type ModuleInfo Uses

type ModuleInfo struct {
    ModulePath      string
    ResolvedVersion string
    // ModulePackages is the set of all full package paths in the module.
    ModulePackages map[string]bool
}

ModuleInfo contains all the information a package needs about the module it belongs to in order to render its documentation.

type RenderOptions Uses

type RenderOptions struct {
    // 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.
    FileLinkFunc   func(file string) (url string)
    SourceLinkFunc func(ast.Node) string
    // ModInfo optionally specifies information about the module the package
    // belongs to in order to render module-related documentation.
    ModInfo *ModuleInfo
    Limit   int64 // If zero, a default limit of 10 megabytes is used.
}

RenderOptions are options for Render.

Directories

PathSynopsis
internal/renderPackage render formats Go documentation as HTML.

Package dochtml imports 18 packages (graph) and is imported by 2 packages. Updated 2020-08-05. Refresh now. Tools for package owners.