Documentation
¶
Index ¶
- func BuildSite(url string, indexContent template.HTML, footerContent template.HTML, ...) (files map[string]string, err error)
- type Module
- func (mod Module) GoImport() string
- func (mod Module) GoImportTag() template.HTML
- func (mod Module) GoSource() string
- func (mod Module) GoSourceTag() template.HTML
- func (mod Module) HomePageURL() string
- func (mod Module) RenderSite(footer template.HTML, w io.Writer, buf *bytes.Buffer) error
- func (mod Module) SourceCodeURL() string
- func (mod Module) ValidateGoImport() error
- func (mod Module) ValidateGoSource() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Module ¶
type Module struct {
ImportPath string // ImportPath of the module.
VCSType string
RepoURL string
HomePage string // URL to the homepage
DirectoryLinkTemplate string
FileLinkTemplate string
}
Module holds information for a go module with a custom VCSPath. See Module.GoImport and Module.GoSource.
func GitForgeModule ¶
GitForgeModule returns a new Module using templates for a common git forge.
ImportPath is the import path of the module. RepoURL is the https clone url of the repository. Ref should be the git reflike pointing to HEAD. This is typically a branch name.
func (Module) GoImport ¶
GoImport returns the value of the "go-import" tag in the [format supported by the go command].
If the struct contains invalid data, returns the empty string instead.
func (Module) GoImportTag ¶
GoImportTag renders this module information into a "go-import" meta tag. If this module contains invalid information, returns the empty string instead.
See Module.GoImport for details.
func (Module) GoSource ¶
GoSource returns the value of the "go-source" meta tag in the specified format supported by godoc.
Templates for building a link to a source directory and file are derived from the [Module.DirectoryLinkTemplate] and [Module.FileLinkTemplate] fields.
Both templates may contain the following placeholders:
- "{dir}": The import path with prefix and leading "/" trimmed. - "{/dir}": If {dir} is not the empty string, then {/dir} is replaced by "/" + {dir}. Otherwise, {/dir} is replaced with the empty string.
The SourceFileTemplate may additionally contain the following placeholders:
- "{file}": The name of the file. - "{line}": The decimal line number.
As a special case, if [Module.HomePage] is the empty string, falls back to the defaults of godoc.
If the data is invalid, returns the empty string.
func (Module) GoSourceTag ¶
GoSourceTag renders this module information into a "go-source" meta tag. If this module contains invalid information, returns the empty string instead.
See Module.GoSource for details.
func (Module) HomePageURL ¶
func (Module) RenderSite ¶
RenderSite renders the site template for the given footer. output is written to w. buf is used as an intermediate buffer and should be empty.
func (Module) SourceCodeURL ¶
func (Module) ValidateGoImport ¶
ValidateGoImport checks if this module can generate a "go-module" meta tag and returns a non-nil error if not.
func (Module) ValidateGoSource ¶
ValidateGoSource checks if this module can generate a "go-source" meta tag and returns a non-nil error if not.