Skip to content

Commit 7d33de9

Browse files
kyleconroyclaude
andauthored
Add a Go linter for the docs/ content contract (#4584)
internal/docs validates the documentation source tree with goldmark and runs from go test, so doc-breaking changes fail CI without any JavaScript toolchain. It enforces the contract the external site consumer relies on: every page parses as GFM and starts with exactly one level-1 heading; relative links and images resolve to files inside docs/, with anchor fragments checked against GitHub-style heading slugs; every page appears exactly once in toc.yaml and every toc.yaml entry names a real page; no raw HTML other than comments; and no leftover MyST directives. Fix everything the linter found in the existing docs: convert the eight remaining MyST admonitions to GitHub alert syntax, add the missing level-1 heading to the embedding guide, point extensionless and .html links (which only resolved under Sphinx) at the actual .md files, and correct anchors that did not match GitHub slugging (#sqlcdb-prepare, #rules-using-explain--output, #the-go_type-map, and stale #with-other-tools fragments in the changelog). Claude-Session: https://claude.ai/code/session_013XDcHxZk9UzfzMLayG66Zq Co-authored-by: Claude <noreply@anthropic.com>
1 parent fbf130e commit 7d33de9

14 files changed

Lines changed: 536 additions & 44 deletions

File tree

docs/howto/ci-cd.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ database schema. Learn more about uploading projects [here](push.md)
3838

3939
## General setup
4040

41-
Install `sqlc` using the [suggested instructions](../overview/install).
41+
Install `sqlc` using the [suggested instructions](../overview/install.md).
4242

4343
Create three steps in your pipeline for `sqlc diff`, `sqlc vet`, and `sqlc
4444
verify`. Run `sqlc push` after merge on your `main` branch.
@@ -98,9 +98,8 @@ jobs:
9898

9999
### push
100100

101-
```{note}
102-
Pushing a project is powered by [sqlc Cloud](https://dashboard.sqlc.dev). Sign up for [free](https://dashboard.sqlc.dev) today.
103-
```
101+
> [!NOTE]
102+
> Pushing a project is powered by [sqlc Cloud](https://dashboard.sqlc.dev). Sign up for [free](https://dashboard.sqlc.dev) today.
104103

105104
The following GitHub Workflow configuration runs [sqlc push](push.md) on
106105
every push to `main`. Create an auth token via the
@@ -125,9 +124,8 @@ jobs:
125124

126125
### verify
127126

128-
```{note}
129-
Verify database migrations is powered by [sqlc Cloud](https://dashboard.sqlc.dev). Sign up for [free](https://dashboard.sqlc.dev) today.
130-
```
127+
> [!NOTE]
128+
> Verify database migrations is powered by [sqlc Cloud](https://dashboard.sqlc.dev). Sign up for [free](https://dashboard.sqlc.dev) today.
131129

132130
```yaml
133131
name: sqlc

docs/howto/embedding.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#### Embedding structs
1+
# Embedding structs
22

33
Embedding allows you to reuse existing model structs in more queries, resulting
44
in less manual serialization work. First, imagine we have the following schema

docs/howto/managed-databases.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ sql:
7979

8080
With managed databases configured, `sqlc vet` will automatically create a hosted ephemeral database with your
8181
schema and use that database when running lint rules that require a
82-
database connection, e.g. any [rule relying on `EXPLAIN ...` output](vet.md#rules-using-explain-output).
82+
database connection, e.g. any [rule relying on `EXPLAIN ...` output](vet.md#rules-using-explain--output).
8383

84-
If you don't yet have any vet rules, the [built-in sqlc/db-prepare rule](vet.md#sqlc-db-prepare)
84+
If you don't yet have any vet rules, the [built-in sqlc/db-prepare rule](vet.md#sqlcdb-prepare)
8585
is a good place to start. It prepares each of your queries against the database
8686
to ensure the query is valid. Here's a minimal working configuration:
8787

docs/howto/named_parameters.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ type UpdateAuthorNameParams struct {
4646
If the `sqlc.arg()` syntax is too verbose for your taste, you can use the `@`
4747
operator as a shortcut.
4848

49-
```{note}
50-
The `@` operator as a shortcut for `sqlc.arg()` is not supported in MySQL.
51-
```
49+
> [!NOTE]
50+
> The `@` operator as a shortcut for `sqlc.arg()` is not supported in MySQL.
5251
5352
```sql
5453
-- name: UpsertAuthorName :one

docs/howto/overrides.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Overriding types
22

3-
:::{note}
4-
Type overrides and field renaming are only fully-supported for Go.
5-
:::
3+
> [!NOTE]
4+
> Type overrides and field renaming are only fully-supported for Go.
65
76
In many cases it's useful to tell `sqlc` explicitly what Go type you want it to
87
use for a query input or output. For instance, by default when you use
@@ -39,11 +38,10 @@ sql:
3938
go_type: "time.Time"
4039
```
4140
42-
:::{tip}
43-
A single `db_type` override configuration applies to either nullable or non-nullable
44-
columns, but not both. If you want the same Go type to override regardless of
45-
nullability, you'll need to configure two overrides: one with `nullable: true` and one without.
46-
:::
41+
> [!TIP]
42+
> A single `db_type` override configuration applies to either nullable or non-nullable
43+
> columns, but not both. If you want the same Go type to override regardless of
44+
> nullability, you'll need to configure two overrides: one with `nullable: true` and one without.
4745

4846
## The `overrides` list
4947

@@ -54,7 +52,7 @@ Each element in the `overrides` list has the following keys:
5452
- `column`:
5553
- A column name to override. The value should be of the form `table.column` but you can also specify `schema.table.column` or `catalog.schema.table.column`. `column` and `db_type` are mutually exclusive.
5654
- `go_type`:
57-
- The fully-qualified name of a Go type to use in generated code. This is usually a string but can also be [a map](#the-go-type-map) for more complex configurations.
55+
- The fully-qualified name of a Go type to use in generated code. This is usually a string but can also be [a map](#the-go_type-map) for more complex configurations.
5856
- `go_struct_tag`:
5957
- A reflect-style struct tag to use in generated code, e.g. `a:"b" x:"y,z"`.
6058
If you want `json` or `db` tags for all fields, configure `emit_json_tags` or `emit_db_tags` instead.
@@ -68,15 +66,13 @@ Each element in the `overrides` list has the following keys:
6866
Note that this only applies to `db_type` overrides and has no effect on `column` overrides.
6967
Defaults to `false`.
7068

71-
:::{tip}
72-
A single `db_type` override configuration applies to either nullable or non-nullable
73-
columns, but not both. If you want the same Go type to override regardless of nullability, you'll
74-
need to configure two overrides: one with `nullable: true` and one without.
75-
:::
69+
> [!TIP]
70+
> A single `db_type` override configuration applies to either nullable or non-nullable
71+
> columns, but not both. If you want the same Go type to override regardless of nullability, you'll
72+
> need to configure two overrides: one with `nullable: true` and one without.
7673

77-
:::{note}
78-
When generating code, `column` override configurations take precedence over `db_type` configurations.
79-
:::
74+
> [!NOTE]
75+
> When generating code, `column` override configurations take precedence over `db_type` configurations.
8076

8177
### The `go_type` map
8278

docs/howto/push.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# `push` - Uploading projects
22

3-
```{note}
4-
`push` is powered by [sqlc Cloud](https://dashboard.sqlc.dev). Sign up for [free](https://dashboard.sqlc.dev) today.
5-
```
3+
> [!NOTE]
4+
> `push` is powered by [sqlc Cloud](https://dashboard.sqlc.dev). Sign up for [free](https://dashboard.sqlc.dev) today.
65
76
*Added in v1.24.0*
87

docs/howto/vet.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
`sqlc vet` runs queries through a set of lint rules.
66

7-
Rules are defined in the `sqlc` [configuration](../reference/config) file. They
7+
Rules are defined in the `sqlc` [configuration](../reference/config.md) file. They
88
consist of a name, message, and a [Common Expression Language
99
(CEL)](https://github.com/google/cel-spec) expression. Expressions are evaluated
1010
using [cel-go](https://github.com/google/cel-go). If an expression evaluates to
@@ -48,7 +48,7 @@ each CEL expression has access to the output from running `EXPLAIN ...` on your
4848
via the `postgresql.explain` and `mysql.explain` variables.
4949
This output is quite complex and depends on the structure of your query but sqlc attempts
5050
to parse and provide as much information as it can. See
51-
[Rules using `EXPLAIN ...` output](#rules-using-explain-output) for more information.
51+
[Rules using `EXPLAIN ...` output](#rules-using-explain--output) for more information.
5252

5353
Here are a few example rules just using the basic configuration and query information available
5454
to the CEL expression environment. While these examples are simplistic, they give you a flavor

docs/reference/changelog.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ Like upload, `push` should be run when you tag a release of your application. We
548548

549549
#### MySQL support in `createdb`
550550

551-
The `createdb` command, added in the last release, now supports MySQL. If you have a cloud project configured, you can use `sqlc createdb` to spin up a new ephemeral database with your schema and print its connection string to standard output. This is useful for integrating with other tools. Read more in the [managed databases](../howto/managed-databases.md#with-other-tools) documentation.
551+
The `createdb` command, added in the last release, now supports MySQL. If you have a cloud project configured, you can use `sqlc createdb` to spin up a new ephemeral database with your schema and print its connection string to standard output. This is useful for integrating with other tools. Read more in the [managed databases](../howto/managed-databases.md) documentation.
552552

553553
#### Plugin interface refactor
554554

@@ -628,7 +628,7 @@ When you have a cloud project configured, you can use the new `sqlc createdb`
628628
command to spin up a new ephemeral database with your schema and print its
629629
connection string to standard output. This is useful for integrating with other
630630
tools. Read more in the [managed
631-
databases](../howto/managed-databases.md#with-other-tools) documentation.
631+
databases](../howto/managed-databases.md) documentation.
632632

633633
#### Support for pgvector
634634

@@ -833,7 +833,7 @@ full list.
833833

834834
#### Plugin access to environment variables
835835

836-
If you're authoring a [sqlc plugin](../guides/plugins.html), you can now configure
836+
If you're authoring a [sqlc plugin](../guides/plugins.md), you can now configure
837837
sqlc to pass your plugin the values of specific environment variables.
838838

839839
For example, if your plugin
@@ -1254,7 +1254,7 @@ rules:
12541254
database server. We'll expand this functionality over time, but for now it
12551255
powers the `sqlc/db-prepare` built-in rule.
12561256

1257-
When a [database](config.html#database) is configured, the
1257+
When a [database](config.md#database) is configured, the
12581258
`sqlc/db-preapre` rule will attempt to prepare each of your
12591259
queries against the connected database and report any failures.
12601260

docs/reference/config.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ See [Overriding types](../howto/overrides.md) for an in-depth guide to using typ
204204

205205
#### kotlin
206206

207-
> Removed in v1.17.0 and replaced by the [sqlc-gen-kotlin](https://github.com/sqlc-dev/sqlc-gen-kotlin) plugin. Follow the [migration guide](../guides/migrating-to-sqlc-gen-kotlin) to switch.
207+
> Removed in v1.17.0 and replaced by the [sqlc-gen-kotlin](https://github.com/sqlc-dev/sqlc-gen-kotlin) plugin. Follow the [migration guide](../guides/migrating-to-sqlc-gen-kotlin.md) to switch.
208208

209209
- `package`:
210210
- The package name to use for the generated code.
@@ -215,7 +215,7 @@ See [Overriding types](../howto/overrides.md) for an in-depth guide to using typ
215215

216216
#### python
217217

218-
> Removed in v1.17.0 and replaced by the [sqlc-gen-python](https://github.com/sqlc-dev/sqlc-gen-python) plugin. Follow the [migration guide](../guides/migrating-to-sqlc-gen-python) to switch.
218+
> Removed in v1.17.0 and replaced by the [sqlc-gen-python](https://github.com/sqlc-dev/sqlc-gen-python) plugin. Follow the [migration guide](../guides/migrating-to-sqlc-gen-python.md) to switch.
219219

220220
- `package`:
221221
- The package name to use for the generated code.

docs/reference/macros.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ FROM authors
2020
WHERE lower(name) = ?;
2121
```
2222

23-
See more examples in [Naming parameters](../howto/named_parameters).
23+
See more examples in [Naming parameters](../howto/named_parameters.md).
2424

2525
## `sqlc.embed`
2626

@@ -72,7 +72,7 @@ func (q *Queries) GetStudentAndScore(ctx context.Context, id int64) (GetStudentA
7272
}
7373
```
7474

75-
See a full example in [Embedding structs](../howto/embedding).
75+
See a full example in [Embedding structs](../howto/embedding.md).
7676

7777
## `sqlc.narg`
7878

@@ -92,7 +92,7 @@ FROM authors
9292
WHERE LOWER(name) = ?;
9393
```
9494

95-
See more examples in [Naming parameters](../howto/named_parameters).
95+
See more examples in [Naming parameters](../howto/named_parameters.md).
9696

9797
## `sqlc.slice`
9898

0 commit comments

Comments
 (0)