template

package
v0.14.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 29, 2024 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

package template generates documentation for a given package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteCSS

func WriteCSS(w io.Writer) error

WriteCSS writes the default CSS to the given writer.

Types

type Directory

type Directory struct {
	Name     string
	Synopsis string
}

Directory represents the sub-packages of a given package.

type GemtextRenderer

type GemtextRenderer struct {
	BaseURL string
}

GemtextRenderer provides the generation of gemtext documentation.

func (GemtextRenderer) Execute

func (gr GemtextRenderer) Execute(out io.Writer, td TemplateData) error

Execute applies a parsed template to the template data, and writes the output to w.

type HTMLRenderer

type HTMLRenderer struct {
	Stylesheets []string
	// AdditionalFS and AdditionalPattern can be optionally provided
	// to override some components
	AdditionalFS       fs.FS
	AdditionalPatterns []string

	BaseURL string
}

HTMLRenderer provides the generation of HTML documentation.

func (HTMLRenderer) Execute

func (hr HTMLRenderer) Execute(out io.Writer, td TemplateData) error

Execute applies a parsed template to the template data, and writes the output to w.

type TemplateData

type TemplateData struct {
	Package      *doc.Package
	FileSet      *token.FileSet
	ModulePath   string
	PackageChain []string
	Directories  []Directory
	VCS          autodiscovery.VCS
	Ref          string
}

TemplateData stores all the data needed to render the documentation templates.

func NewTemplateData

func NewTemplateData(
	pkgFS fs.FS,
	modulePath string,
	packageChain []string,
	directories []Directory,
	vcs autodiscovery.VCS,
	ref string,
) (TemplateData, error)

NewTemplateData parses the provided pkgFS to prepare the template data.

func (TemplateData) PageName

func (td TemplateData) PageName() string

PageName returns the page name ("*** package" or "*** command" depending on the package name).

Notes

Bugs

  • no idea how build tags should be managed

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL