doc

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package doc generates Markdown documentation from a dashboard service snapshot and serves it as rendered HTML. The generated docs include an at-a-glance summary, a runtime & operations table, a Mermaid architecture diagram, interface and endpoint tables, configuration and policy tables, the dependency graph and readiness, SBOM and lockfile sections. The snapshot (dashboard.ServiceDetails) is the single source of truth already used by the dashboard, so the doc and the UI stay in lock-step.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildStaticExport

func BuildStaticExport(d *dashboard.ServiceDetails, g *dashboard.GlobalGraph) (map[string][]byte, error)

BuildStaticExport returns the embedded dashboard UI tree (path -> bytes) with index.html rewritten to embed the snapshot as window.__PACTO_STATIC__, so the single-service view renders offline with no backend.

func Generate

func Generate(d *dashboard.ServiceDetails, gr *graph.Result) (string, error)

Generate renders a Markdown document from a dashboard service snapshot. gr (may be nil) drives the Mermaid architecture diagram and the per-dependency snapshots via the existing graph-walk helpers; when it is nil the diagram is built from the snapshot alone.

func ServeStatic

func ServeStatic(ctx context.Context, files map[string][]byte, port int) error

ServeStatic starts a local HTTP server that serves the given in-memory static export tree (path -> bytes, as produced by BuildStaticExport). It blocks until the context is cancelled.

func ServeStaticOnListener

func ServeStaticOnListener(ctx context.Context, files map[string][]byte, ln net.Listener) error

ServeStaticOnListener is like ServeStatic but accepts an existing net.Listener. This is useful in tests where port 0 is used to obtain a random port and the caller needs the address before blocking. Requests for "/" resolve to index.html; unknown paths return 404.

func ServeSwagger

func ServeSwagger(ctx context.Context, opts SwaggerOptions) error

ServeSwagger starts a local HTTP server that renders an interactive API explorer (Scalar) for every HTTP interface that has an OpenAPI contract. It blocks until the context is cancelled.

func ServeSwaggerOnListener

func ServeSwaggerOnListener(ctx context.Context, opts SwaggerOptions, ln net.Listener) error

ServeSwaggerOnListener is like ServeSwagger but accepts an existing net.Listener. This is useful in tests where port 0 is used to obtain a random port and the caller needs the address before blocking.

func WriteStaticExport

func WriteStaticExport(files map[string][]byte, dir string) error

WriteStaticExport writes the in-memory static export tree to dir, creating parent directories as needed.

Types

type SwaggerOptions

type SwaggerOptions struct {
	Specs   []SwaggerSpec
	FS      fs.FS
	Title   string
	Port    int
	Target  string            // global target; applies to all interfaces
	Targets map[string]string // per-interface targets; overrides Target
}

SwaggerOptions configures the interactive API explorer server.

type SwaggerSpec

type SwaggerSpec struct {
	InterfaceName string
	SpecPath      string
}

SwaggerSpec pairs an interface name with the path to its OpenAPI spec file.

func CollectSwaggerSpecs

func CollectSwaggerSpecs(interfaces []contract.Interface) []SwaggerSpec

CollectSwaggerSpecs returns the OpenAPI interfaces that have a spec.

func FilterSpecs

func FilterSpecs(specs []SwaggerSpec, name string) []SwaggerSpec

FilterSpecs returns only the spec matching the given interface name. It returns nil if no match is found.

Jump to

Keyboard shortcuts

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