Conversation
|
| Project | cot |
| Branch | toml-reference |
| Testbed | github-ubuntu-latest |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result microseconds (µs) (Result Δ%) | Upper Boundary microseconds (µs) (Limit %) |
|---|---|---|---|
| empty_router/empty_router | 📈 view plot 🚷 view threshold | 10,194.00 µs(-1.84%)Baseline: 10,385.29 µs | 18,868.39 µs (54.03%) |
| json_api/json_api | 📈 view plot 🚷 view threshold | 772.08 µs(-24.45%)Baseline: 1,021.93 µs | 1,353.98 µs (57.02%) |
| nested_routers/nested_routers | 📈 view plot 🚷 view threshold | 751.85 µs(-21.68%)Baseline: 960.02 µs | 1,253.62 µs (59.97%) |
| single_root_route/single_root_route | 📈 view plot 🚷 view threshold | 738.01 µs(-20.08%)Baseline: 923.41 µs | 1,214.61 µs (60.76%) |
| single_root_route_burst/single_root_route_burst | 📈 view plot 🚷 view threshold | 14,846.00 µs(-11.72%)Baseline: 16,817.31 µs | 21,960.95 µs (67.60%) |
There was a problem hiding this comment.
Pull request overview
Adds an auto-generated TOML configuration reference to the documentation, sourced from cot::config::ProjectConfig via JSON Schema so the docs stay in sync with the actual config surface.
Changes:
- Introduces a
schemars-based generator plus acot-testtest to enforcedocs/configuration.mdfreshness. - Adds a
config-docsinternal feature to enable JSON Schema derivation for config types. - Wires the new configuration page into the docs site navigation and adds a
justtask to regenerate the docs.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| justfile | Adds a just generate-config-docs helper to regenerate the config reference. |
| docs/site/src/main.rs | Adds the new “Configuration” page to the docs site nav. |
| docs/configuration.md | New generated configuration reference page. |
| cot/src/email/transport/smtp.rs | Enables JSON Schema derivation for SMTP auth mechanism enum (for docs generation). |
| cot/src/config.rs | Adds JsonSchema derives / schema overrides to config types to support docs generation. |
| cot/Cargo.toml | Adds internal config-docs feature to drive schema generation. |
| cot-test/tests/config_reference.rs | Adds a test that fails if docs/configuration.md is out of date. |
| cot-test/src/lib.rs | Exposes the config reference generator behind config-docs. |
| cot-test/src/config_reference.rs | Implements the Markdown generator from the ProjectConfig schema. |
| cot-test/src/bin/generate_config_docs.rs | Adds a binary to write the generated docs file. |
| cot-test/Cargo.toml | Adds deps and feature wiring for the docs generator/test/bin. |
| Cargo.lock | Records new dependency additions for schema generation. |
Comments suppressed due to low confidence (1)
cot/src/config.rs:1799
- Using
schemars(with = "Option<String>")forexpiry: Expiryimplies the config schema acceptsnull, even though the TOML representation is a string and the field is defaulted (optional-by-omission, not nullable). Preferschemars(with = "String")here to keep the schema accurate.
#[cfg_attr(feature = "config-docs", schemars(with = "Option<String>"))]
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4809c4c to
51db33f
Compare
51db33f to
8de229c
Compare
e0fb363 to
704e28e
Compare
This adds an automated script that generates a Guide page about the configuration by using JsonSchema of the config structures in config.rs. In addition to that, there's a new test added to cot-test that checks whether the markdown file in the repository is up to date. This has two huge advantages: 1. There is a full specification of the config file now, making it much easier to find out what the correct values are. 2. The specification never gets out of date, because the CI pipeline forces the guide page to be updated. The reason we store the markdown file in the repository instead of generating it on the fly is mainly so that any changes to the documentation can be easily reviewed. The workflow is therefore as following: 1. A change is made to the config structures in config.rs. 2. The change author regenerates the guide with `just generate-config-docs`. 3. The changes are reviewed when a PR is made. 4. Whenever the generated result is not up to our standards, either the docs or the generation script is modified. There are some limitations of the page generation script, such as: * The script only takes the first paragraph of the rustdoc, so the links need to be inlined - referencing links defined later in the doc will not work. * Some types are not supported - e.g. `[cache.timeout]` displays the type of the value is just `string`, even though it needs to be a specific string that represents a time duration. The config page "cheats" a little bit to be more readable, e.g. it reduces the padding of the content. See cot-rs/cot-site#111 for the details. Fixes #479
704e28e to
af1ed39
Compare
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
| | `max_retries` | integer | `3` | Maximum number of retries for cache operations. | | ||
| | `timeout` | string | `"5m"` | Timeout for cache operations. | | ||
| | `prefix` | string | — | Prefix for cache keys. | | ||
| | `store` | table | [`type = "memory"`](#cachestore) | The cache store configuration. | |
There was a problem hiding this comment.
I get the idea behind showing that default here, but I don't like how it looks like, especially with the 3-column layout for the page the table is really narrow. I think I'd just link to section below where the default is visible
There was a problem hiding this comment.
In my opinion, I think the current table is fine, considering that most default values are not long strings. Keeping the default value inline reduces the cognitive load of having to move between sections to find it.
That also draws my attention to cases like:
### [cache]
| `store` | `table` | `"type" = "memory"` |
### [`middlewares.session`]
| `store` | `table` | `"type" = "memory"` |
### [`email`]
| `transport` | `table` | `"type" = "console"` |Shouldn't the default values for these say “see below,” just like sections likemiddlewares.live_load?
| | `register_panic_hook` | boolean | `true` | Whether to register a panic hook. | | ||
| | `secret_key` | string | — | The secret key used for signing cookies and other sensitive data. This is a cryptographic key, should be kept secret, and should be set to a random and unique value for each project. | | ||
| | `fallback_secret_keys` | array of strings | `[]` | Fallback secret keys that can be used to verify old sessions. | | ||
| | `auth_backend` | table | [`type = "none"`](#auth_backend) | The authentication backend to use. | |
There was a problem hiding this comment.
Nit: I wonder whether using table as the type fits here. It reads like the actual type used in code rather than a docs-specific label, which could be confusing given that we use types like String elsewhere.

This adds an automated script that generates a Guide page about the
configuration by using JsonSchema of the config structures in config.rs.
In addition to that, there's a new test added to cot-test
that checks whether the markdown file in the repository is up to date.
This has two huge advantages:
easier to find out what the correct values are.
forces the guide page to be updated.
The reason we store the markdown file in the repository instead of
generating it on the fly is mainly so that any changes to the
documentation can be easily reviewed.
The workflow is therefore as following:
just generate-config-docs.docs or the generation script is modified.
There are some limitations of the page generation script, such as:
need to be inlined - referencing links defined later in the doc will
not work.
[cache.timeout]displays thetype of the value is just
string, even though it needs to bea specific string that represents a time duration.
The config page "cheats" a little bit to be more readable, e.g.
it reduces the padding of the content. See cot-rs/cot-site#111
for the details.
Fixes #479