Skip to content

Commit 2d18667

Browse files
authored
docs: Re-org the config page. Add JSON docs (#1659)
1 parent eb6015e commit 2d18667

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ code ever again.
5656
howto/upload.md
5757

5858
.. toctree::
59-
:maxdepth: 2
59+
:maxdepth: 3
6060
:caption: Reference
6161
:hidden:
6262

docs/reference/config.md

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ sql:
2424
out: "mysql
2525
```
2626
27+
### sql
28+
2729
Each mapping in the `sql` collection has the following keys:
2830
2931
- `engine`:
@@ -34,18 +36,14 @@ Each mapping in the `sql` collection has the following keys:
3436
- Directory of SQL queries or path to single SQL file; or a list of paths.
3537
- `gen`:
3638
- A mapping to configure built-in code generators. Supports the following keys:
37-
- `go`:
38-
- Go code generation options
39-
- `kotlin`:
40-
- Kotlin code generation options
41-
- `python`:
42-
- Python code generation options
43-
- `json`:
44-
- JSON output options
4539
- `strict_function_checks`
4640
- If true, return an error if a called SQL function does not exist. Defaults to `false`.
4741
48-
### go
42+
### gen
43+
44+
The `gen` mapping supports the following keys:
45+
46+
#### go
4947
5048
- `package`:
5149
- The package name to use for the generated code. Defaults to `out` basename.
@@ -90,7 +88,7 @@ Each mapping in the `sql` collection has the following keys:
9088
- `output_files_suffix`:
9189
- If specified the suffix will be added to the name of the generated files.
9290
93-
### kotlin
91+
#### kotlin
9492
9593
- `package`:
9694
- The package name to use for the generated code.
@@ -99,7 +97,7 @@ Each mapping in the `sql` collection has the following keys:
9997
- `emit_exact_table_names`:
10098
- If true, use the exact table name for generated models. Otherwise, guess a singular form. Defaults to `false`.
10199
102-
### python
100+
#### python
103101
104102
- `package`:
105103
- The package name to use for the generated code.
@@ -114,7 +112,14 @@ Each mapping in the `sql` collection has the following keys:
114112
- `emit_pydantic_models`:
115113
- If true, generate classes that inherit from `pydantic.BaseModel`. Otherwise, define classes using the `dataclass` decorator. Defaults to `false`.
116114
117-
### json
115+
#### json
116+
117+
- `out`:
118+
- Output directory for the generated JSON.
119+
- `filename`:
120+
- Filename for the generated JSON document. Defaults to `codegen_request.json`.
121+
- `indent`:
122+
- Indent string to use in the JSON document. Defaults to ` `.
118123
119124
## Version 1
120125
@@ -143,6 +148,8 @@ packages:
143148
output_querier_file_name: "querier.go"
144149
```
145150
151+
### packages
152+
146153
Each mapping in the `packages` collection has the following keys:
147154

148155
- `name`:
@@ -194,7 +201,7 @@ Each mapping in the `packages` collection has the following keys:
194201
- `output_files_suffix`:
195202
- If specified the suffix will be added to the name of the generated files.
196203

197-
## Type Overrides
204+
### overrides
198205

199206
The default mapping of PostgreSQL/MySQL types to Go types only uses packages outside
200207
the standard library when it must.
@@ -235,7 +242,7 @@ overrides:
235242
pointer: false # or true
236243
```
237244

238-
## Per-Column Type Overrides
245+
#### Per-Column Type Overrides
239246

240247
Sometimes you would like to override the Go type used in model or query generation for
241248
a specific field of a table and not on a type basis as described in the previous section.
@@ -252,7 +259,7 @@ overrides:
252259
go_type: "github.com/segmentio/ksuid.KSUID"
253260
```
254261

255-
## Package Level Overrides
262+
#### Package Level Overrides
256263

257264
Overrides can be configured globally, as demonstrated in the previous sections, or they can be configured on a per-package which
258265
scopes the override behavior to just a single package:
@@ -263,7 +270,7 @@ packages:
263270
- overrides: [...]
264271
```
265272

266-
## Renaming Struct Fields
273+
### rename
267274

268275
Struct field names are generated from column names using a simple algorithm:
269276
split the column name on underscores and capitalize the first letter of each
@@ -275,7 +282,7 @@ spotify_url -> SpotifyUrl
275282
app_id -> AppID
276283
```
277284
278-
If you're not happy with a field's generated name, use the `rename` dictionary
285+
If you're not happy with a field's generated name, use the `rename` mapping
279286
to pick a new name. The keys are column names and the values are the struct
280287
field name to use.
281288

0 commit comments

Comments
 (0)