Documentation ¶
Overview ¶
Package server implements the Go documentation server.
Index ¶
- Constants
- Variables
- type Breadcrumb
- type Config
- type ErrMismatch
- type Example
- type LoadMode
- type Package
- func (p *Package) AllExamples() []*Example
- func (p *Package) DirURL() string
- func (p *Package) FileURL(file string) string
- func (p *Package) IsPackage() bool
- func (p *Package) ModuleTitle() string
- func (p *Package) ObjExamples(obj any) []*Example
- func (p *Package) PackageExamples() []*Example
- func (p *Package) SummaryURL() string
- func (p *Package) Title() string
- type Renderer
- func (r *Renderer) Breadcrumbs(p *Package) []Breadcrumb
- func (r *Renderer) CodeGemini(ex *doc.Example) (string, error)
- func (r *Renderer) CodeHTML(ex *doc.Example) htemp.HTML
- func (r *Renderer) DeclGemini(decl ast.Decl) string
- func (r *Renderer) DeclHTML(decl ast.Decl, typ *doc.Type) htemp.HTML
- func (r *Renderer) DocGemini(text string) string
- func (r *Renderer) DocHTML(text string) htemp.HTML
- func (r *Renderer) ExecuteGemini(t *template.Template, w io.Writer, data any) error
- func (r *Renderer) ExecuteHTML(t *htemp.Template, w http.ResponseWriter, data any) error
- func (r *Renderer) ExecuteHTTP(t *template.Template, w io.Writer, data any) error
- func (r *Renderer) FuncString(decl *ast.FuncDecl) string
- func (r *Renderer) GeminiFuncs() template.FuncMap
- func (r *Renderer) HTMLFuncs() template.FuncMap
- func (r *Renderer) IsInterface(t *doc.Type) bool
- func (r *Renderer) PlayID(ex *Example) string
- func (r *Renderer) Query() string
- func (r *Renderer) SourceLink(p token.Pos, text string) htemp.HTML
- func (r *Renderer) View(importPath, view string) string
- type Server
- type TemplateMap
- func (m TemplateMap) Execute(w io.Writer, name string, data interface{}) error
- func (m TemplateMap) ExecuteHTML(resp http.ResponseWriter, name string, data interface{}) error
- func (m TemplateMap) HTML(name string) *htemp.Template
- func (m TemplateMap) ParseHTML(name string, funcs htemp.FuncMap, fsys fs.FS) error
- func (m TemplateMap) ParseText(name string, funcs ttemp.FuncMap, fsys fs.FS) error
- func (m TemplateMap) Text(name string) *ttemp.Template
Constants ¶
const (
// MaxFileSize is the maximum file size that is allowed for reading.
MaxFileSize = 30 * megabyte
)
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Breadcrumb ¶
Breadcrumb provides a link back to a previous page.
type Config ¶
type Config struct { BrandName string AdminName string AdminEmail string WebsiteIssues string BindHTTP string BindGemini string Hostname string CertsDir string Database string GoProxy string Platform string UserAgent string FetchTimeout time.Duration RequestTimeout time.Duration RefreshInterval time.Duration MaxAge time.Duration }
Server configuration.
type ErrMismatch ¶
ErrMismatch represents the case where the import path is different from the module path in the go.mod file.
func (ErrMismatch) Error ¶
func (e ErrMismatch) Error() string
type Example ¶
type Example struct { *doc.Example ID string Symbol string Suffix string // contains filtered or unexported fields }
Example is a doc.Example with additional information for use in templates.
type LoadMode ¶
type LoadMode int
A LoadMode configures the amount of detail returned when loading a package.
type Package ¶
type Package struct { *internal.Module *doc.Package FileSet *token.FileSet Synopsis string Platform string Directories []database.Synopsis Imported []database.Synopsis Message string // contains filtered or unexported fields }
Package is a doc.Package with additional information for use in templates.
func NewPackage ¶
func NewPackage(mod *internal.Module, platform, importPath string, src *godoc.Package) (*Package, error)
NewPackage returns a new package for use in templates. If src is nil, no package documentation will be displayed.
func (*Package) AllExamples ¶
AllExamples returns a list of all examples.
func (*Package) ModuleTitle ¶
ModuleTitle returns a title for the module.
func (*Package) ObjExamples ¶
ObjExamples returns a list of examples for the given object.
func (*Package) PackageExamples ¶
PackageExamples returns a list of examples associated with the package.
func (*Package) SummaryURL ¶
SummaryURL returns the URL for the project summary.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer provides functions to render Go documentation.
func NewRenderer ¶
NewRenderer returns a new renderer for the given package.
func (*Renderer) Breadcrumbs ¶
func (r *Renderer) Breadcrumbs(p *Package) []Breadcrumb
Breadcrumbs computes breadcrumbs for the given package.
func (*Renderer) CodeGemini ¶
CodeGemini renders example code as Gemini text.
func (*Renderer) DeclGemini ¶
DeclGemini renders a Go declaration as Gemini text.
func (*Renderer) ExecuteGemini ¶
ExecuteGemini executes a Gemini text template.
func (*Renderer) ExecuteHTML ¶
ExecuteHTML executes an HTML template.
func (*Renderer) ExecuteHTTP ¶
ExecuteHTTP executes an HTTP text template.
func (*Renderer) FuncString ¶
FuncString formats a function declaration into a single line.
func (*Renderer) GeminiFuncs ¶
GeminiFuncs returns a template.FuncMap for use in Gemini templates.
func (*Renderer) HTMLFuncs ¶
HTMLFuncs returns a template.FuncMap for use in HTML templates.
func (*Renderer) IsInterface ¶
IsInterface reports whether t is an interface type.
func (*Renderer) SourceLink ¶
SourceLink returns a source link for the given position.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
The Go documentation server.
func (*Server) GeminiHandler ¶
type TemplateMap ¶
func (TemplateMap) Execute ¶
func (m TemplateMap) Execute(w io.Writer, name string, data interface{}) error
func (TemplateMap) ExecuteHTML ¶
func (m TemplateMap) ExecuteHTML(resp http.ResponseWriter, name string, data interface{}) error