docs

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package docs serves the public, server-rendered product documentation at /doc. It owns the doc shell (its own dark chrome, no dashboard auth), a Markdown renderer, and the table-of-contents model. Core registers its own product pages from embedded Markdown; a composing build adds pages of its own by injecting Sections (for the shared left rail) and rendering its Markdown through the RenderDoc capability the app hands it — so every doc page looks identical whichever module served it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarkdownToHTML

func MarkdownToHTML(src []byte) (template.HTML, error)

MarkdownToHTML converts a Markdown source to the HTML fragment a doc page drops into the prose column. It is exported so a composing build renders its own embedded Markdown through the same converter before handing the result to RouteContext.RenderDoc, keeping every doc page — core or extension — identical.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler serves the doc pages. nav is the merged, ordered table of contents (core + injected sections) shared by every page; header is the top-bar site links a composing build injected.

func NewHandler

func NewHandler(extra []Section, header []Link, log *slog.Logger) *Handler

NewHandler builds the doc handler, merging the injected extension sections after the core ones. The merged set drives the left rail on every page, so an extension page and a core page show the same table of contents; header drives the top-bar site links (empty in the community build).

func (*Handler) Register

func (h *Handler) Register(mux *http.ServeMux)

Register mounts the doc routes on the public mux. /doc/{topic} is the core content; a composing build's own pages mount on more specific patterns (/doc/billing) that take ServeMux precedence over the {topic} wildcard.

func (*Handler) Render

func (h *Handler) Render(w http.ResponseWriter, r *http.Request, title string, body template.HTML)

Render wraps a rendered body in the doc shell with the rail lit for the current request path. It is the capability the app exposes as RouteContext.RenderDoc so a composing build renders its own pages in this exact chrome, with the shared table of contents, without importing this package's internals.

type Link struct {
	Label, Href string
}

Link is one top-bar site link (e.g. "Pricing" -> /pricing). A composing build injects these via app.WithDocHeaderLinks so a visitor who reached the docs from the marketing site can navigate back; the community build injects none, so the top bar shows only the home brand and no dead links to routes it does not serve.

type Section

type Section struct {
	// Group is the rail heading the link sits under (e.g. "Product", "Enterprise").
	Group string
	// Title is the link text; Href is the absolute path it points at ("/doc/quickstart").
	Title, Href string
	// Order sorts links within a group; groups themselves keep first-seen order.
	Order int
}

Section is one entry in the docs left rail. Core contributes its own product sections; a composing build adds more via app.WithDocSections so its pages are discoverable from every doc page's table of contents.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL