package frontend

Import Path
	golang.org/x/pkgsite/internal/frontend (on go.dev)

Dependency Relation
	imports 66 packages, and imported by 2 packages


Package-Level Type Names (total 47, in which 25 are exported)
/* sort exporteds by: | */
Directories is the directory listing for all directories in the unit, which is listed in the directories section of the main page. External contains all of the non-internal directories for the unit. Internal contains the top level internal directory for the unit, if any.
Directory is either a nested module or subdirectory of a unit, organized in a two level tree structure. This content is used in the directories section of the unit page. Prefix is the prefix of the unit path for the subdirectories. Root is the package located at prefix, nil for a directory. Subdirectories contains subdirectories with prefix trimmed from their suffix.
DirectoryInfo contains information about a package or nested module, relative to the path of a given unit. This content is used in the Directories section of the unit page. IsModule bool Suffix string Synopsis string URL string
File is a source file for a package. Name string URL string
Heading holds data about a heading and nested headings within a readme. This data is used in the sidebar template to render the readme outline. Children are nested headings. ID corresponds to the ID attribute for a heading element and is also used in an href to the corresponding section within the readme outline. All ids are prefixed with readme- to avoid name collisions. Level is the original level of the heading. Text is the content from the readme contained within a heading.
ImportedByDetails contains information for the collection of packages that import a given package. ImportedBy is the collection of packages that import the given package and are not part of the same module. They are organized into a tree of sections by prefix. ModulePath is the module path for the package referenced on this page. NumImportedByDisplay is the display text at the top of the imported by tab section, which shows the imported by count and package limit. Total is the total number of importers.
ImportsDetails contains information for a package's imports. ExternalImports is the collection of package imports that are not in the Go standard library and are not part of the same module InternalImports is an array of packages representing the package's imports that are part of the same module. ModulePath string StdLib is an array of packages representing the package's imports that are in the Go standard library.
License contains information used for a single license section. Anchor safehtml.Identifier License *licenses.License License.Contents []byte License.Metadata *licenses.Metadata License.Metadata.Coverage licensecheck.Coverage FilePath is the '/'-separated path to the license file in the module zip, relative to the contents directory. The output of oldlicensecheck.Cover. Types is the set of license types, as determined by the licensecheck package. Source string RemoveNonRedistributableData methods removes the license contents if the license is non-redistributable.
LicenseMetadata contains license metadata that is used in the package header. Anchor safehtml.Identifier Type string
LicensesDetails contains license information for a package or module. Licenses []License
MainDetails contains data needed to render the unit template. BuildContexts holds the values for build contexts available for the doc. CommitTime is time that this version was published, or the time that has elapsed since this version was committed if it was done so recently. Directories are packages and nested modules relative to the path for the unit. DocBody safehtml.HTML DocLinks are from the "Links" section of the Go package documentation, and are displayed on the right sidebar. DocOutline safehtml.HTML DocSynopsis is used as the content for the <meta name="Description"> tag on the main unit page. ExpandReadme is holds the expandable readme state. GOOS and GOARCH are the build context for the doc. GOOS and GOARCH are the build context for the doc. ImportedByCount is the number of packages that import this path. When the count is > limit it will read as 'limit+'. This field is not supported when using a datasource proxy. IsPackage bool IsStableVersion is true if the major version is v1 or greater. IsTaggedVersion is true if the version is not a psuedorelease. Licenses contains license metadata used in the header. MobileOutline safehtml.HTML ModFileURL is an URL to the mod file. ModuleReadmeLinks are from the "Links" section of this unit's module, if the unit is not itself a module. They are displayed on the right sidebar. See https://golang.org/issue/42968. NumImports is the number of imports for the package. Readme is the rendered readme HTML. ReadmeLinks are from the "Links" section of this unit's readme file, and are displayed on the right sidebar. ReadmeOutline is a collection of headings from the readme file used to render the readme outline in the sidebar. RepositoryURL is the URL to the repository containing the package. SourceFiles contains .go files for the package. SourceURL is the URL to the source of the package.
Readme holds the result of processing a REAME file. // rendered HTML // links from the "Links" section // document headings func ProcessReadme(ctx context.Context, u *internal.Unit) (_ *Readme, err error)
SearchPage contains all of the data that the search template needs to populate. AllowWideContent indicates whether the content should be displayed in a way that’s amenable to wider viewports. AppVersionLabel contains the current version of the app. DevMode indicates whether the server is running in development mode. Experiments contains the experiments currently active. GoogleTagManagerID is the ID used to load Google Tag Manager. HTMLTitle is the value to use in the page’s <title> tag. MetaDescription is the html used for rendering the <meta name="Description"> tag. Query is the current search query (if applicable). Pagination pagination Results []*SearchResult
SearchResult contains data needed to display a single search result. Approximate bool CommitTime string DisplayVersion string Licenses []string // package paths in lower major versions ModulePath string Name string NumImportedBy int PackagePath string // package paths in the same module Symbols *subResult Synopsis string
A Section represents a collection of lines with a common prefix. The collection is itself divided into sections by prefix, forming a tree. // total number of lines in subsections // prefix for this section, or if Subs==nil, a single line // subsections func Sections(lines []string, nextPrefix prefixFunc) []*Section
Server can be installed to serve the go discovery frontend. GetLatestInfo returns various pieces of information about the latest versions of a unit and module: - The linkable form of the minor version of the unit. - The latest module path and the full unit path of any major version found given the fullPath and the modulePath. It returns empty strings on error. It is intended to be used as an argument to middleware.LatestVersions. Install registers server routes using the given handler registration func. authValues is the set of values that can be set on authHeader to bypass the cache. PanicHandler returns an http.HandlerFunc that can be used in HTTP middleware. It returns an error if something goes wrong pre-rendering the error template. func NewServer(scfg ServerConfig) (_ *Server, err error)
ServerConfig contains everything needed by a Server. AppVersionLabel string CompletionClient *redis.Client DataSourceGetter should return a DataSource on each call. It should be goroutine-safe. DevMode bool GoogleTagManagerID string Queue queue.Queue ReportingClient *errorreporting.Client ServeStats bool StaticPath template.TrustedSource TaskIDChangeInterval time.Duration ThirdPartyPath string func NewServer(scfg ServerConfig) (_ *Server, err error)
StyleSection represents a section on the styleguide page. Content is the HTML rendered from the parsed markdown file. ID is the ID for the header element of the section. Outline is a collection of headings used in the navigation. Title is the title of the section, taken from the name of the markdown file.
Symbol is an element in the package API. A symbol can be a constant, variable, function, type, field or method. Builds lists all of the build contexts supported by the symbol, it is only available for limited set of builds. If the symbol supports all build contexts, Builds will be nil. Children contain the child symbols for this symbol. This will only be populated when the SymbolType is "Type". For example, the children of net/http.Handler are FileServer, NotFoundHandler, RedirectHandler, StripPrefix, and TimeoutHandler. Each child symbol will have ParentName set to the Name of this type. Kind is the type of a symbol, which is either a constant, variable, function, type, field or method. Link is the link to the symbol name on pkg.go.dev. Name is name of the symbol. At a given package version, name must be unique. New indicates that the symbol is new as of the version where it is present. For example, if type Client was introduced in v1.0.0 and Client.Timeout was introduced in v1.1.0, New will be false for Client and true for Client.Timeout if this Symbol corresponds to v1.1.0. Section is the section that a symbol appears in. Synopsis is the one line description of the symbol that is displayed.
TabSettings defines tab-specific metadata. AlwaysShowDetails defines whether the tab content can be shown even if the package is not determined to be redistributable. Disabled indicates whether a tab should be displayed as disabled. DisplayName is the formatted tab name. Name is the tab name used in the URL. TemplateName is the name of the template used to render the corresponding tab, as defined in Server.templates.
UnitPage contains data needed to render the unit template. AllowWideContent indicates whether the content should be displayed in a way that’s amenable to wider viewports. AppVersionLabel contains the current version of the app. DevMode indicates whether the server is running in development mode. Experiments contains the experiments currently active. GoogleTagManagerID is the ID used to load Google Tag Manager. HTMLTitle is the value to use in the page’s <title> tag. MetaDescription is the html used for rendering the <meta name="Description"> tag. Query is the current search query (if applicable). Breadcrumb contains data used to render breadcrumb UI elements. CanShowDetails indicates whether details can be shown or must be hidden due to issues like license restrictions. CanonicalURLPath is a permanent representation of the URL path for a unit. It uses the resolved module path and version. For example, if the latest version of /my.module/pkg is version v1.5.2, the canonical URL path for that unit would be /my.module@v1.5.2/pkg Details contains data specific to the type of page being rendered. The version string formatted for display. Information about the latest major version of the module. LatestMajorVersionURL string LatestMinorClass is the CSS class that describes the current unit's minor version in relationship to the latest version of the unit. LatestURL is a url pointing to the latest version of a unit. LinkVersion is version string suitable for links used to compute latest badges. PageLabels are the labels that will be displayed for a given page. PageType is the type of page (pkg, cmd, dir, std, or mod). RedirectedFromPath is the path that redirected to the current page. If non-empty, a "redirected from" banner will be displayed (see content/static/html/helpers/_unit_header.tmpl). Settings contains settings for the selected tab. Title is the title of the page. URLPath is the path suitable for links on the page. See the unitURLPath for details. Unit is the unit for this page.
VersionList holds all versions corresponding to a unique (module path, major version) tuple in the version hierarchy. VersionListKey VersionListKey Deprecated indicates whether the major version is deprecated. DeprecationComment holds the reason for deprecation, if any. Incompatible indicates whether the VersionListKey represents an incompatible module version. Major is the major version string (e.g. v1, v2) ModulePath is the module path of this major version. Versions holds the nested version summaries, organized in descending semver order.
VersionListKey identifies a version list on the versions tab. We have a separate VersionList for each major version of a module series. Notably we have more version lists than module paths: v0 and v1 module versions are in separate version lists, despite having the same module path. Deprecated indicates whether the major version is deprecated. DeprecationComment holds the reason for deprecation, if any. Incompatible indicates whether the VersionListKey represents an incompatible module version. Major is the major version string (e.g. v1, v2) ModulePath is the module path of this major version.
VersionsDetails contains the hierarchy of version summary information used to populate the version tab. Version information is organized into separate lists, one for each (ModulePath, Major Version) pair. IncompatibleModules is the slice of the VersionsLists with the same module path as the current package, but with incompatible versions. OtherModules is the slice of VersionLists with a different module path from the current package. ThisModule is the slice of VersionLists with the same module path as the current package. func ParseVersionsDetails(vd VersionsDetails) (_ *internal.SymbolHistory, err error)
VersionSummary holds data required to format the version link on the versions tab. CommitTime string IsMinor bool Link to this version, for use in the anchor href. Retracted bool RetractionRationale string Symbols [][]*Symbol Version string
Package-Level Functions (total 121, in which 7 are exported)
FetchAndUpdateState is used by the InMemory queue for testing in internal/frontend and running cmd/frontend locally. It is a copy of worker.FetchAndUpdateState that does not update module_version_states, so that we don't have to import internal/worker here. It is not meant to be used when running on AppEngine.
LegacyReadmeHTML sanitizes readmeContents based on bluemondy.UGCPolicy and returns a safehtml.HTML. If readmeFilePath indicates that this is a markdown file, it will also render the markdown contents using blackfriday. This function is exported for use in an external tool that uses this package to compare readme files to see how changes in processing will affect them.
NewServer creates a new Server for the given database and template directory.
ParseVersionsDetails returns a map of versionToNameToUnitSymbol based on data from the proovided VersionDetails.
ProcessReadme processes the README of unit u, if it has one. Processing includes rendering and sanitizing the HTML or Markdown, and extracting headings and links. Headings are prefixed with "readme-" and heading levels are adjusted to start at h3 in order to nest them properly within the rest of the page. The readme's original styling is preserved in the html by giving headings a css class styled identical to their original heading level. The extracted links are for display outside of the readme contents. This function is exported for use by external tools.
Sections transforms a list of lines, which must be sorted, into a list of Sections. Each Section in the result contains all the contiguous lines with the same prefix. The nextPrefix function is responsible for extracting prefixes from lines.
TagRoute categorizes incoming requests to the frontend for use in monitoring.
Package-Level Variables (total 23, in which 3 are exported)
FetchLatencyDistribution aggregates frontend fetch request latency by status code.
FetchResponseCount counts frontend fetch responses by response type.
Package-Level Constants (total 22, none are exported)