docscapture

package
v0.0.0-...-fe31ed2 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Overview

Package docscapture implements the browser-backed screenshot capture for the rela-docs screenshot{} island (Tier B). It stands up the data-entry SPA over a seeded temp project and drives headless Chrome (chromedp) to capture a PNG.

It is deliberately a SEPARATE package from internal/docs: it pulls in the whole data-entry + appbuild + chromedp dependency surface, which the core doc language must not carry. internal/docs depends on it only through the consumer-side docs.Capturer interface, injected by the CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

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

APIClient implements docs.APIClient: it stands up the data-entry server over a seeded temp project and issues real HTTP requests against it.

It lives here rather than in internal/docs for the same reason the Capturer does — it pulls in dataentry + appbuild, which the core doc language must not carry. Unlike the Capturer it needs NO browser and no built frontend, so a manual using only api{} assertions runs anywhere the Go tests do.

The temp project is stood up lazily on the first request and reused, with the manual's growing seed applied incrementally (see project.syncSeed): a manual creates entities as it goes, so a later api{} must see entities created after the server started.

Nil: never returned by New; the zero value is not usable — use NewAPIClient.

func NewAPIClient

func NewAPIClient(projectDir string) *APIClient

NewAPIClient returns a client serving the given project.

func (*APIClient) Close

func (c *APIClient) Close() error

Close tears down the temp project and server if one was stood up.

func (*APIClient) Do

Do issues one request, standing the server up on first use.

An HTTP error status is a normal return, not an error: asserting a 403 or a 404 is the point of the verb. Only a transport-level failure errors.

type Capturer

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

Capturer implements docs.Capturer using chromedp against a data-entry SPA served over a seeded temp project. The temp project + server + browser are created lazily on the first Capture and reused across islands; Close tears them all down.

func New

func New() (*Capturer, error)

New returns a Capturer. It does NOT launch a browser yet (that happens on the first Capture) so a manual with no screenshot{} pays nothing. It DOES verify a Chrome binary is resolvable, so a screenshot-bearing manual fails loud early rather than after standing up a server.

func (*Capturer) Capture

func (c *Capturer) Capture(ctx context.Context, spec docs.CaptureSpec) (string, error)

Capture renders one screenshot and writes the PNG, returning its path.

func (*Capturer) Close

func (c *Capturer) Close() error

Close tears down the browser, server, and temp project.

Jump to

Keyboard shortcuts

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