Skip to content

Commit 0f45460

Browse files
authored
docs: Add process-based plugin docs (#1669)
Still need more, but this is a good first pass
1 parent d20ca82 commit 0f45460

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

docs/guides/plugins.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Authoring plugins
2+
3+
## Process plugins
4+
5+
To use process-based plugins, you must be using [Version
6+
2](../reference/config.html) of the configuration file. The top-level `plugins`
7+
array defines the available plugins and maps them to an executable on the system.
8+
9+
In the `codegen` section, the `out` field dictates what directory will contain
10+
the new files. The `plugin` key must reference a plugin defined in the
11+
top-level `plugins` map. The `options` are serialized to a string and passed on
12+
to the plugin itself.
13+
14+
```json
15+
{
16+
"version": "2",
17+
"plugins": [
18+
{
19+
"name": "jsonb",
20+
"process": {
21+
"cmd": "sqlc-gen-json"
22+
}
23+
}
24+
],
25+
"sql": [
26+
{
27+
"schema": "schema.sql",
28+
"queries": "query.sql",
29+
"engine": "postgresql",
30+
"codegen": [
31+
{
32+
"out": "gen",
33+
"plugin": "jsonb",
34+
"options": {
35+
"indent": " ",
36+
"filename": "codegen.json"
37+
}
38+
}
39+
]
40+
}
41+
]
42+
}
43+
```
44+
45+
For a complete working example see the following files:
46+
- [sqlc-gen-json](https://github.com/kyleconroy/sqlc/tree/main/cmd/sqlc-gen-json)
47+
- A process-based plugin that serializes the CodeGenRequest to JSON
48+
- [process_plugin_sqlc_gen_json](https://github.com/kyleconroy/sqlc/tree/main/internal/endtoend/testdata/process_plugin_sqlc_gen_json)
49+
- An example project showing how to use a process-based plugin
50+
51+
### Security
52+
53+
Process-based plugins offer minimal security. Only use plugins that you trust.
54+
Better yet, only use plugins that you've written yourself.
55+
56+
## WASM plugins
57+
58+
*Coming soon!*

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,5 @@ code ever again.
7474
:hidden:
7575

7676
guides/development.md
77+
guides/plugins.md
7778
guides/privacy.md

docs/reference/config.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,16 @@ The `gen` mapping supports the following keys:
120120
- Filename for the generated JSON document. Defaults to `codegen_request.json`.
121121
- `indent`:
122122
- Indent string to use in the JSON document. Defaults to ` `.
123+
124+
### plugins
125+
126+
Each mapping in the `plugins` collection has the following keys:
127+
128+
- `name`:
129+
- The name of this plugin. Required
130+
- `process`:
131+
- `cmd`:
132+
- The executable to call when using this plugin
123133
124134
## Version 1
125135

docs/reference/language-support.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Database and Language Support
1+
Database and language support
22
#############################
33

44
======== ============ ============

0 commit comments

Comments
 (0)