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 ¶
- func BuildStaticExport(d *dashboard.ServiceDetails, g *dashboard.GlobalGraph) (map[string][]byte, error)
- func Generate(d *dashboard.ServiceDetails, gr *graph.Result) (string, error)
- func ServeStatic(ctx context.Context, files map[string][]byte, port int) error
- func ServeStaticOnListener(ctx context.Context, files map[string][]byte, ln net.Listener) error
- func ServeSwagger(ctx context.Context, opts SwaggerOptions) error
- func ServeSwaggerOnListener(ctx context.Context, opts SwaggerOptions, ln net.Listener) error
- func WriteStaticExport(files map[string][]byte, dir string) error
- type SwaggerOptions
- type SwaggerSpec
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 ¶
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 ¶
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 ¶
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 ¶
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.
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 ¶
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.