Skip to content

Commit 2f64253

Browse files
committed
Add local Faust doc query API and README docs
1 parent 7e01782 commit 2f64253

2 files changed

Lines changed: 551 additions & 0 deletions

File tree

README.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,131 @@ More details on the build process:
4040
$ make help
4141
~~~~~~~~~~~~~~~~
4242

43+
### Faust Library JSON Exports
44+
45+
This repository can also generate machine-readable JSON exports of the Faust
46+
library documentation directly from the `.lib` sources.
47+
48+
The generator is:
49+
50+
```bash
51+
scripts/build_faust_doc_index.py
52+
```
53+
54+
It parses documentation blocks from the library sources, starting from
55+
`stdfaust.lib`, follows `library("...")` and `import("...")` directives, and
56+
extracts for each documented symbol:
57+
58+
- `summary`
59+
- `usage`
60+
- `params`
61+
- `io` with `inSignals` / `outSignals` when derivable
62+
- `testCode`
63+
- `references`
64+
- `source`
65+
66+
Two JSON layouts are supported:
67+
68+
- monolithic: one full JSON file containing all libraries and symbols
69+
- split: one compact global index plus one detailed JSON file per module
70+
71+
Default Make targets:
72+
73+
```bash
74+
make doc-index
75+
make doc-index-split
76+
```
77+
78+
Default output locations:
79+
80+
- `make doc-index` writes `tests/faust-doc-index.json`
81+
- `make doc-index-split` writes:
82+
- `tests/faust-doc-index.json`
83+
- `tests/faust-doc/index.json`
84+
- `tests/faust-doc/modules/*.json`
85+
86+
You can override the output paths:
87+
88+
```bash
89+
make doc-index DOC_INDEX_OUTPUT=/tmp/faust-doc-index.json
90+
make doc-index-split DOC_INDEX_OUTPUT=/tmp/faust-doc-index.json DOC_INDEX_SPLIT_DIR=/tmp/faust-doc
91+
```
92+
93+
You can also run the generator directly:
94+
95+
```bash
96+
python3 scripts/build_faust_doc_index.py --repo-root . --output tests/faust-doc-index.json --pretty
97+
python3 scripts/build_faust_doc_index.py --repo-root . --output tests/faust-doc-index.json --split-output-dir tests/faust-doc --pretty
98+
```
99+
100+
The split layout is recommended for LLM or retrieval-based use because it avoids
101+
loading the whole documentation into context for every request.
102+
103+
### Local Documentation Query API
104+
105+
The repository also ships with a local query tool that reproduces the Faust
106+
library documentation operations used in `faustforge`:
107+
108+
```bash
109+
scripts/faust_doc_api.py
110+
```
111+
112+
Supported operations:
113+
114+
- `search_faust_lib`
115+
- `get_faust_symbol`
116+
- `list_faust_module`
117+
- `get_faust_examples`
118+
- `explain_faust_symbol_for_goal`
119+
120+
The tool can read either:
121+
122+
- the monolithic export `tests/faust-doc-index.json`
123+
- the split export `tests/faust-doc/index.json`
124+
125+
If `--index` is omitted, it tries these defaults in that order:
126+
127+
1. `tests/faust-doc/index.json`
128+
2. `tests/faust-doc-index.json`
129+
130+
Examples:
131+
132+
```bash
133+
python3 scripts/faust_doc_api.py --pretty search_faust_lib reverb --limit 5
134+
python3 scripts/faust_doc_api.py --pretty search_faust_lib filter --module filters --limit 10
135+
136+
python3 scripts/faust_doc_api.py --pretty get_faust_symbol de.delay
137+
python3 scripts/faust_doc_api.py --pretty list_faust_module delays --limit 20
138+
python3 scripts/faust_doc_api.py --pretty get_faust_examples delay
139+
python3 scripts/faust_doc_api.py --pretty explain_faust_symbol_for_goal re.springreverb "build a metallic spring reverb"
140+
```
141+
142+
To force a specific index location:
143+
144+
```bash
145+
python3 scripts/faust_doc_api.py --index tests/faust-doc-index.json --pretty get_faust_symbol aa.Rsqrt
146+
python3 scripts/faust_doc_api.py --index tests/faust-doc --pretty list_faust_module filters --limit 10
147+
```
148+
149+
Operation semantics mirror `faustforge`:
150+
151+
- `search_faust_lib(query, limit?, module?)`
152+
searches symbols by name, qualified name, summary, and source file without
153+
loading full docs into context
154+
- `get_faust_symbol(symbol)`
155+
returns the full symbol entry plus close alternatives
156+
- `list_faust_module(module, limit?)`
157+
lists symbols from one library module such as `delays` or `filters`
158+
- `get_faust_examples(symbolOrModule, limit?)`
159+
returns the `#### Test` snippets for a symbol or module
160+
- `explain_faust_symbol_for_goal(symbol, goal)`
161+
builds an action-oriented explanation for a concrete DSP objective
162+
163+
The `make clean` target removes the generated JSON artifacts by default:
164+
165+
- `tests/faust-doc-index.json`
166+
- `tests/faust-doc/`
167+
43168
### Publishing
44169

45170
Publishing is handled by GitHub Actions. Pushing to the main branch will build and deploy the site.

0 commit comments

Comments
 (0)