template package - code.pfad.fr/vanitydoc
import "code.pfad.fr/vanitydoc/template"
package template generates documentation for a given package.
Functions
func Synopsis
func Synopsis(ctx build.Context, modulePath string, packageChain []string) string
Synopsis returns a cleaned version of the first sentence of the documentation
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
DocSite string // defaults to "gemini://godocs.io"
}
GemtextRenderer provides the generation of [gemtext] documentation.
gemtext
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 {
Favicon string
Stylesheets []string
// AdditionalFS and AdditionalPattern can be optionally provided
// to override some components
AdditionalFS fs.FS
AdditionalPatterns []string
BaseURL string
DocSite string // defaults to "https://pkg.go.dev"
}
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.
func (HTMLRenderer) NotFound
func (hr HTMLRenderer) NotFound(out io.Writer, baseURL, modulePath, importPath, ref string) 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
PosText func(start, end token.Pos) ([]byte, error)
TypesInfo *types.Info
ModulePath string
PackageChain []string
Directories []Directory
VCS autodiscovery.VCS
Ref string
// contains filtered or unexported fields
}
TemplateData stores all the data needed to render the documentation templates.
func NewTemplateData
func NewTemplateData(
ctx build.Context,
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) AdjustedImportPath
func (td TemplateData) AdjustedImportPath() string
AdjustedImportPath removes "std/" prefix (for showing the stdlib).
func (TemplateData) Close
func (td TemplateData) Close() error
func (TemplateData) PageName
func (td TemplateData) PageName() string
PageName returns the page name ("*** package" or "*** command" depending on the package name).
Files
ast.go
common.go
gemtext.go
gemtext_comment.go
html.go
Breadcrumb
code.pfad.fr/vanitydoc