package server
import "git.sr.ht/~sircmpwn/gddo/internal/server"
Package server implements the Go documentation server.
Index ¶
- Constants
- Variables
- type Breadcrumb
- type Config
- type ErrMismatch
- type Example
- type LoadMode
- type Package
- func NewPackage(mod *internal.Module, platform, importPath string, src *godoc.Package) (*Package, error)
- 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 NewRenderer(p *Package, cfg *Config) *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
- func New(cfg *Config) (*Server, error)
- func (s *Server) GeminiHandler() (gemini.Handler, error)
- func (s *Server) HTTPHandler() (http.Handler, error)
- func (s *Server) Refresh(ctx context.Context)
- 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 ¶
var ( ErrBlocked = errors.New("blocked import path") ErrNoPackages = errors.New("no packages found") ErrFetching = errors.New("fetch in progress") ErrInvalidPlatform = errors.New("invalid platform") )
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.
func (*Config) FlagSet ¶
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) DirURL ¶
DirURL returns the URL for the package directory.
func (*Package) FileURL ¶
FileURL returns the URL for the given file.
func (*Package) IsPackage ¶
IsPackage reports whether p is a regular package.
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.
func (*Package) Title ¶
Title returns a title for the package.
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) CodeHTML ¶
CodeHTML renders example code as HTML.
func (*Renderer) DeclGemini ¶
DeclGemini renders a Go declaration as Gemini text.
func (*Renderer) DeclHTML ¶
DeclHTML renders a Go declaration as HTML.
func (*Renderer) DocGemini ¶
DocGemini returns formatted Gemini content for the doc comment text.
func (*Renderer) DocHTML ¶
DocHTML returns formatted HTML for the doc comment 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) PlayID ¶
PlayID returns the play ID for the given example.
func (*Renderer) Query ¶
Query returns the current query, if necessary.
func (*Renderer) SourceLink ¶
SourceLink returns a source link for the given position.
func (*Renderer) View ¶
View returns a link for the current package.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
The Go documentation server.
func New ¶
New returns a new server with the given configuration.
func (*Server) GeminiHandler ¶
func (*Server) HTTPHandler ¶
func (*Server) Refresh ¶
Refresh refreshes the oldest module in the database.
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
func (TemplateMap) HTML ¶
func (m TemplateMap) HTML(name string) *htemp.Template
func (TemplateMap) ParseHTML ¶
func (TemplateMap) ParseText ¶
func (TemplateMap) Text ¶
func (m TemplateMap) Text(name string) *ttemp.Template
Source Files ¶
config.go errors.go fetch.go gemini.go http.go load.go package.go platforms.go play.go render.go server.go template.go
- Version
- v0.0.0-20240124133021-55358d4d592d (latest)
- Published
- Jan 24, 2024
- Platform
- linux/amd64
- Imports
- 48 packages
- Last checked
- 1 day ago –
Tools for package owners.