Skip to content

Commit 01e2291

Browse files
committed
Unify tools documentation: consolidate CLI and Lab sections with new related tiles and service-specific examples. Refactor "Local Services" into distinct pages for "Static File Server" and "Mock API Server" with expanded syntax and usage details. Update weights, descriptions, and references for improved navigation. Mark unused tools as drafts.
1 parent 429c86f commit 01e2291

16 files changed

Lines changed: 333 additions & 211 deletions

content/docs/tools/cli/_index.md

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,4 @@ The Ferret CLI is the primary tool for working with FQL scripts. Use it to execu
1313

1414
All commands accept `--log-level`, `--log-output`, and `--log-file` flags for controlling log output. Settings can be persisted through the [config](config/) command or environment variables with the `FERRET_` prefix. See [Config](config/) for details.
1515

16-
<div class="docs-section-card-grid">
17-
<a class="docs-section-card" href="/docs/tools/cli/install/">
18-
<strong>Install</strong>
19-
<span>Install, update, and verify the Ferret CLI.</span>
20-
</a>
21-
<a class="docs-section-card" href="/docs/tools/cli/run/">
22-
<strong>Run</strong>
23-
<span>Execute FQL scripts from files, inline expressions, stdin, or compiled artifacts.</span>
24-
</a>
25-
<a class="docs-section-card" href="/docs/tools/cli/repl/">
26-
<strong>REPL</strong>
27-
<span>Launch an interactive FQL shell for experimenting with queries.</span>
28-
</a>
29-
<a class="docs-section-card" href="/docs/tools/cli/debug/">
30-
<strong>Debug</strong>
31-
<span>Debug FQL scripts interactively with breakpoints, stepping, and variable inspection.</span>
32-
</a>
33-
<a class="docs-section-card" href="/docs/tools/cli/check/">
34-
<strong>Check</strong>
35-
<span>Verify FQL scripts for syntax and semantic errors without executing them.</span>
36-
</a>
37-
<a class="docs-section-card" href="/docs/tools/cli/fmt/">
38-
<strong>Fmt</strong>
39-
<span>Format FQL scripts to a consistent style.</span>
40-
</a>
41-
<a class="docs-section-card" href="/docs/tools/cli/build/">
42-
<strong>Build</strong>
43-
<span>Compile FQL scripts into bytecode artifacts for faster execution.</span>
44-
</a>
45-
<a class="docs-section-card" href="/docs/tools/cli/inspect/">
46-
<strong>Inspect</strong>
47-
<span>Disassemble compiled programs and examine bytecode, constants, and source spans.</span>
48-
</a>
49-
<a class="docs-section-card" href="/docs/tools/cli/browser/">
50-
<strong>Browser</strong>
51-
<span>Start and stop managed browser instances for browser-backed scripts.</span>
52-
</a>
53-
<a class="docs-section-card" href="/docs/tools/cli/config/">
54-
<strong>Config</strong>
55-
<span>Manage persistent CLI configuration for runtime, browser, and logging settings.</span>
56-
</a>
57-
</div>
16+
{{< docs-related tiles="tools-cli-install,tools-cli-run,tools-cli-repl,tools-cli-debug,tools-cli-check,tools-cli-fmt,tools-cli-build,tools-cli-inspect,tools-cli-browser,tools-cli-config" >}}

content/docs/tools/docker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Docker"
33
weight: 50
4-
draft: false
4+
draft: true
55
description: "Reserved documentation for Ferret Docker images."
66
---
77

content/docs/tools/editor-integrations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Editor Integrations"
33
weight: 60
4-
draft: false
4+
draft: true
55
description: "Reserved documentation for Ferret editor and tooling integrations."
66
---
77

content/docs/tools/lab/_index.md

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,4 @@ Lab is the Ferret test runner. It discovers FQL and YAML test files, prepares pa
1111

1212
Use Lab when you want repeatable checks for extraction scripts, browser-backed flows, local static fixtures, mock REST APIs, or runtime compatibility.
1313

14-
<div class="docs-section-card-grid">
15-
<a class="docs-section-card" href="/docs/tools/lab/overview/">
16-
<strong>Overview</strong>
17-
<span>How Lab runs tests and where it fits with Ferret runtimes.</span>
18-
</a>
19-
<a class="docs-section-card" href="/docs/tools/lab/installation/">
20-
<strong>Installation</strong>
21-
<span>Install Lab from releases, Docker, or source.</span>
22-
</a>
23-
<a class="docs-section-card" href="/docs/tools/lab/writing-tests/">
24-
<strong>Writing Tests</strong>
25-
<span>Write FQL unit tests and YAML query/assert suites.</span>
26-
</a>
27-
<a class="docs-section-card" href="/docs/tools/lab/running-tests/">
28-
<strong>Running Tests</strong>
29-
<span>Run local, HTTP, and Git-hosted test files with parameters and waits.</span>
30-
</a>
31-
<a class="docs-section-card" href="/docs/tools/lab/static-serving/">
32-
<strong>Local Services</strong>
33-
<span>Serve static directories and mock APIs during tests or standalone.</span>
34-
</a>
35-
<a class="docs-section-card" href="/docs/tools/lab/runners/">
36-
<strong>Runners</strong>
37-
<span>Control concurrency, retries, repeated runs, timeouts, and reporters.</span>
38-
</a>
39-
<a class="docs-section-card" href="/docs/tools/lab/http-runtime/">
40-
<strong>HTTP Runtime</strong>
41-
<span>Run tests against a remote Ferret HTTP runtime.</span>
42-
</a>
43-
<a class="docs-section-card" href="/docs/tools/lab/binary-runtime/">
44-
<strong>Binary Runtime</strong>
45-
<span>Run tests through an external Ferret-compatible binary.</span>
46-
</a>
47-
<a class="docs-section-card" href="/docs/tools/lab/cdp/">
48-
<strong>CDP</strong>
49-
<span>Use browser-backed FQL with Lab and the selected runtime.</span>
50-
</a>
51-
<a class="docs-section-card" href="/docs/tools/lab/configuration/">
52-
<strong>Configuration</strong>
53-
<span>Reference Lab flags, defaults, environment variables, and runtime params.</span>
54-
</a>
55-
<a class="docs-section-card" href="/docs/tools/lab/ci/">
56-
<strong>CI</strong>
57-
<span>Run Lab in pipelines with waits, retries, Docker, and local fixtures.</span>
58-
</a>
59-
</div>
14+
{{< docs-related tiles="tools-lab-overview,tools-lab-installation,tools-lab-writing-tests,tools-lab-running-tests,tools-lab-static-serving,tools-lab-mock-api,tools-lab-runners,tools-lab-http-runtime,tools-lab-binary-runtime,tools-lab-cdp,tools-lab-configuration,tools-lab-ci" >}}

content/docs/tools/lab/binary-runtime.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,5 @@ The returned text is displayed as the runtime version.
8888
When you use `--serve` or `--mock`, Lab forwards the generated `@lab.static` and `@lab.mock` values as parameters to the binary runtime.
8989

9090
If the binary runs on the same machine as Lab, the default `127.0.0.1` service URLs usually work. If the binary is a wrapper into a container or remote environment, set `--serve-host` and `--serve-bind` so the runtime can reach the local services.
91+
92+
For local service entry syntax, see [Static File Server]({{< ref "static-serving" >}}) and [Mock API Server]({{< ref "mock-api" >}}).

content/docs/tools/lab/cdp.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ For example, if Lab runs on your laptop but the HTTP runtime runs in a container
5858

5959
The same rule applies to Lab local services. If a remote runtime must fetch `@lab.static` or `@lab.mock` URLs, set `--serve-bind` and `--serve-host` so those URLs are reachable from the runtime.
6060

61+
For Lab-owned local service flags, see [Static File Server]({{< ref "static-serving" >}}) and [Mock API Server]({{< ref "mock-api" >}}).
62+
6163
## CI pattern
6264

6365
A common CI shape is:

content/docs/tools/lab/ci.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ lab run tests/e2e \
106106

107107
Tests can read `@lab.static.app` and `@lab.mock.api`.
108108

109+
For the full local service syntax, see [Static File Server]({{< ref "static-serving" >}}) and [Mock API Server]({{< ref "mock-api" >}}).
110+
109111
If the selected Ferret runtime runs outside the Lab process, make the fixture services reachable from that runtime:
110112

111113
{{< terminal >}}

content/docs/tools/lab/configuration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ lab serve --static ./dist@app --mock ./users.yaml@api
6565

6666
Standalone service entries must use `--static` or `--mock`.
6767

68+
For service-specific examples, see [Static File Server]({{< ref "static-serving" >}}) and [Mock API Server]({{< ref "mock-api" >}}).
69+
6870
## `lab version`
6971

7072
`lab version` prints the Lab version and the selected runtime version.

content/docs/tools/lab/http-runtime.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ When tests use `--serve` or `--mock`, Lab starts those services locally and pass
106106

107107
If the HTTP runtime runs outside the Lab host, `127.0.0.1` may point to the runtime host instead of the Lab host. Use `--serve-host` to advertise a host the runtime can reach, and `--serve-bind` when Lab must listen on a non-loopback interface.
108108

109+
For local service entry syntax, see [Static File Server]({{< ref "static-serving" >}}) and [Mock API Server]({{< ref "mock-api" >}}).
110+
109111
{{< terminal >}}
110112
lab run \
111113
--runtime=https://ferret.example.com \

content/docs/tools/lab/mock-api.md

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
---
2+
title: "Mock API Server"
3+
weight: 55
4+
draft: false
5+
description: "Serve OpenAPI-described mock APIs for Lab tests or standalone fixture access."
6+
---
7+
8+
# Mock API Server
9+
10+
Lab can serve OpenAPI-described mock APIs over HTTP. Use mock APIs when a test needs stable REST responses without depending on an external service.
11+
12+
During `lab run`, mock service URLs are passed to FQL under `@lab.mock`.
13+
14+
## Serve a mock API during a test run
15+
16+
Use `run --mock` to serve an OpenAPI-compatible mock API while tests run.
17+
18+
{{< terminal >}}
19+
lab run --mock ./users.yaml@api tests/
20+
{{< /terminal >}}
21+
22+
The service URL is available as `@lab.mock.api`.
23+
24+
{{< code lang="fql" >}}
25+
LET response = IO::NET::HTTP::GET(@lab.mock.api + "/users/123")
26+
LET user = JSON_PARSE(TO_STRING(response))
27+
28+
RETURN user.id == "123"
29+
{{< /code >}}
30+
31+
Multiple mock APIs can be served in the same run:
32+
33+
{{< terminal >}}
34+
lab run \
35+
--mock ./users.yaml@users \
36+
--mock ./billing.yaml@billing \
37+
tests/
38+
{{< /terminal >}}
39+
40+
## Start standalone mock APIs
41+
42+
Use `lab serve --mock` when you want a mock API service without running tests.
43+
44+
{{< terminal >}}
45+
lab serve --mock ./users.yaml@api
46+
{{< /terminal >}}
47+
48+
Standalone `serve` entries must be explicit. Positional service entries are rejected; use `--mock` for mock API specs.
49+
50+
Lab prints the URL for each started service and runs until the process is cancelled.
51+
52+
## Entry syntax
53+
54+
Mock entries use this binding syntax:
55+
56+
| Syntax | Meaning |
57+
| --- | --- |
58+
| `<path>` | Serve the spec on a dynamic port with the filename, without extension, as the alias. |
59+
| `<path>:<port>` | Serve the spec on a fixed port with the filename, without extension, as the alias. |
60+
| `<path>@<alias>` | Serve the spec with an explicit alias. |
61+
| `<path>@<alias>:<port>` | Serve the spec with an explicit alias and fixed port. |
62+
63+
Mock entries must point to existing files. The default alias is the spec filename without its extension.
64+
65+
Aliases must start with a letter or underscore and may contain letters, numbers, underscores, and hyphens. Use bracket access for aliases that are not valid FQL dotted-property names:
66+
67+
{{< code lang="fql" >}}
68+
RETURN @lab.mock["users-api"] + "/users/123"
69+
{{< /code >}}
70+
71+
Duplicate aliases are rejected.
72+
73+
## Fixed ports
74+
75+
Use a fixed port when another process needs a stable URL.
76+
77+
{{< terminal >}}
78+
lab serve --mock ./users.yaml@api:8081
79+
{{< /terminal >}}
80+
81+
The fixed port is part of the service binding. The alias is still `api`, so test scripts use `@lab.mock.api`.
82+
83+
## Mock API specs
84+
85+
Mock specs use OpenAPI `paths` with operation-level `x-lab-mock` blocks.
86+
87+
```yaml
88+
openapi: 3.1.0
89+
info:
90+
title: Users API
91+
version: 1.0.0
92+
paths:
93+
/users/{id}:
94+
get:
95+
x-lab-mock:
96+
status: 200
97+
headers:
98+
X-Test-Server: lab
99+
body:
100+
id: "{{ .Path.id }}"
101+
name: "User {{ .Path.id }}"
102+
```
103+
104+
The mock server currently handles `GET`, `POST`, `PUT`, `PATCH`, and `DELETE` operations. Paths must start with `/`.
105+
106+
`x-lab-mock` supports:
107+
108+
| Field | Meaning |
109+
| --- | --- |
110+
| `status` | HTTP status code. Defaults to `200`. |
111+
| `headers` | Response headers as string values. |
112+
| `body` | Structured JSON response body. String values are rendered as templates. |
113+
| `bodyTemplate` | Raw text response template. Mutually exclusive with `body`. |
114+
115+
When `body` is used, Lab writes JSON and defaults `Content-Type` to `application/json` unless the mock sets it. When `bodyTemplate` is used, Lab writes text and defaults `Content-Type` to `text/plain; charset=utf-8`.
116+
117+
## Template context
118+
119+
Mock response templates use Go template syntax. They receive this context:
120+
121+
| Field | Meaning |
122+
| --- | --- |
123+
| `.Method` | Request method. |
124+
| `.Path` | Path parameters from routes such as `/users/{id}`. |
125+
| `.Query` | Query parameters. |
126+
| `.Headers` | Request headers. |
127+
| `.Body` | Parsed JSON request body, or `nil`. |
128+
129+
Example:
130+
131+
```yaml
132+
paths:
133+
/echo/{name}:
134+
post:
135+
x-lab-mock:
136+
status: 201
137+
body:
138+
method: "{{ .Method }}"
139+
name: "{{ .Path.name }}"
140+
active: "{{ .Body.active }}"
141+
```
142+
143+
Request bodies used by templates must be JSON. If the request body is not valid JSON, the mock server returns `400 Bad Request`.
144+
145+
## Bind and advertised hosts
146+
147+
By default, mock services bind to `127.0.0.1` and advertise URLs with `127.0.0.1`.
148+
149+
Use `--serve-bind` to choose the listener host. Use `--serve-host` to choose the host placed in generated URLs.
150+
151+
{{< terminal >}}
152+
lab run \
153+
--mock ./users.yaml@api \
154+
--serve-bind 0.0.0.0 \
155+
--serve-host host.docker.internal \
156+
tests/
157+
{{< /terminal >}}
158+
159+
Both values are hosts only. Do not include a port.
160+
161+
When `--serve-host` is set and `--serve-bind` is omitted, Lab binds to a wildcard host so remote runtimes can reach the service: `0.0.0.0` for IPv4 and hostnames, or `::` for IPv6 literals.

0 commit comments

Comments
 (0)