Getting Started
Minimal setup demonstrating CLI usage and simple programmatic scanning. This is the first example new users should explore.
meta-yml6 FILESbeginnerscanninggetting-started
Getting Started
This example demonstrates the most basic use case: scanning for examples using the CLI and programmatic API.
CLI Usage
bash
1# Scan for examples
2functional-examples scan
3
4# Output as JSON
5functional-examples scan -f jsonProgrammatic Usage
The scan.ts file demonstrates the simplest programmatic entry point:
async function main() {
// scan() auto-discovers config and plugins
const result = await scan();
console.log(`Found ${result.examples.length} examples:`);
for (const example of result.examples) {
console.log(` - ${example.title} (${example.id})`);
}
if (result.errors.length > 0) {
console.log(`\n${result.errors.length} errors occurred:`);
for (const error of result.errors) {
console.log(` - ${error.path}: ${error.message}`);
}
}
}
The scan() function auto-discovers your config file and installed plugins, then returns:
examples— Array of extracted exampleserrors— Array of any errors encountered during scanningstats— Timing and count information
Key Concepts
JSON Configuration
This example uses a JSON config (functional-examples.config.json) which is the simplest way to configure scanning. Plugins are auto-detected from your package.json dependencies.
scan()
The convenience function wraps config discovery, loading, resolution, and scanning in a single call. For most use cases, this is all you need.
All Example Files
FILE EXPLORER
README.md
1# Getting Started
2
3This example demonstrates the most basic use case: scanning for examples using the CLI and programmatic API.
4
5## CLI Usage
6
7```bash
8# Scan for examples
9functional-examples scan
10
11# Output as JSON
12functional-examples scan -f json
13```
14
15## Programmatic Usage
16
17The `scan.ts` file demonstrates the simplest programmatic entry point:
18
19<%= file('scan.ts').region('scan') %>
20
21The `scan()` function auto-discovers your config file and installed plugins, then returns:
22- `examples` — Array of extracted examples
23- `errors` — Array of any errors encountered during scanning
24- `stats` — Timing and count information
25
26## Key Concepts
27
28### JSON Configuration
29
30This example uses a JSON config (`functional-examples.config.json`) which is the simplest way to configure scanning. Plugins are auto-detected from your `package.json` dependencies.
31
32### `scan()`
33
34The convenience function wraps config discovery, loading, resolution, and scanning in a single call. For most use cases, this is all you need.
35