docs

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 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 required), 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. When the app wires EnableInApp (dashboard auth on), a signed-in visitor gets the same pages inside the dashboard chrome instead of the standalone shell; anonymous visitors and auth-less builds keep the standalone rendering.

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 full site header a composing build injected (empty in the community build).

func NewHandler

func NewHandler(extra []Section, header template.HTML, 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 is the full site header rendered above every doc page (empty in the community build, where the shell falls back to a minimal home brand).

func (*Handler) EnableInApp added in v0.9.0

func (h *Handler) EnableInApp(authed func(*http.Request) bool, render func(http.ResponseWriter, *http.Request, string, template.HTML))

EnableInApp wires the two collaborators the in-app rendering path needs: authed soft-checks the session cookie (no redirect), and render writes a trusted HTML fragment inside the authenticated dashboard chrome. The composition root calls this only when an auth layer exists; until then Render keeps the standalone shell for every request, so the community build (no control plane) is untouched.

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/sso) 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. When EnableInApp was wired and the request is authenticated, the page renders inside the dashboard chrome instead — core and extension doc pages take the exact same branch, so the two never diverge.

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