Skip to content

Commit 827c3b3

Browse files
committed
Add badge expiry docs and released field
1 parent 4cf00bb commit 827c3b3

1 file changed

Lines changed: 75 additions & 5 deletions

File tree

user_guide/28-multi-version-docs.qmd

Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ versions:
8585
| `eol` | `bool` | `false` | Show an end-of-life warning banner |
8686
| `api_snapshot` | `str` | `None` | Path to a pre-generated API snapshot JSON |
8787
| `git_ref` | `str` | `None` | Git tag for API introspection (tags only) |
88+
| `released` | `str` | `None` | ISO date (e.g. `"2025-03-15"`) when this version was released. Used by the `days` badge expiry mode |
8889

8990
When strings are used instead of dicts, `tag` and `label` both default to the string value. Most projects only need `tag`, `label`, and occasionally `api_snapshot`. The other fields are useful when you have pre-release or end-of-life versions to distinguish.
9091

@@ -141,7 +142,7 @@ This content appears in every version except 0.1.
141142

142143
### Version Expressions
143144

144-
Both `.version-only` and `.version-except` accept version expressions flexible patterns that target one or more versions. Here's the full set of supported expressions:
145+
Both `.version-only` and `.version-except` accept version expressions: flexible patterns that target one or more versions. Here's the full set of supported expressions:
145146

146147
| Expression | Meaning |
147148
|---|---|
@@ -169,7 +170,7 @@ This extra detail only appears in 0.3 and later.
169170
:::
170171
```
171172

172-
In version 0.2, only the outer content appears. In version 0.3+, both blocks are visible. In version 0.1, neither appears. This is useful for progressive disclosure adding detail in newer versions without duplicating the surrounding context.
173+
In version 0.2, only the outer content appears. In version 0.3+, both blocks are visible. In version 0.1, neither appears. This is useful for progressive disclosure, adding detail in newer versions without duplicating the surrounding context.
173174

174175
## Page-Level Version Scoping
175176

@@ -193,7 +194,7 @@ versions: ["0.1", "0.2"]
193194

194195
### Version Expressions in Frontmatter
195196

196-
Instead of listing every matching version explicitly, you can use the same version expression syntax that fences support. This is especially useful for pages that apply to a version "and everything newer" you don't need to update the frontmatter each time a new version is released:
197+
Instead of listing every matching version explicitly, you can use the same version expression syntax that fences support. This is especially useful for pages that apply to a version "and everything newer" so you don't need to update the frontmatter each time a new version is released:
197198

198199
```{.yaml filename="new-feature.qmd"}
199200
---
@@ -218,7 +219,7 @@ All expression types work:
218219
Use `versions: ">=0.5"` instead of `versions: ["0.5", "0.6", "0.7", "dev"]`. The expression form automatically includes future versions so you never need to update frontmatter when a new version is released.
219220
:::
220221

221-
Pages with no `versions` key appear in **all** versions. Scoped pages are excluded from the sidebar, search index, and build output for non-matching versions. This keeps the navigation clean users never see links to pages that don't exist in their version.
222+
Pages with no `versions` key appear in **all** versions. Scoped pages are excluded from the sidebar, search index, and build output for non-matching versions. This keeps the navigation clean and users never see links to pages that don't exist in their version.
222223

223224
## Section-Level Version Scoping
224225

@@ -266,6 +267,75 @@ These expand into styled `<span>` badges:
266267

267268
Badges are compact enough to use liberally throughout your API reference and user guide pages. They give readers an at-a-glance sense of what's new without interrupting the flow of the documentation.
268269

270+
### Badge Expiry
271+
272+
As your project matures, "new" badges from several releases ago become noise rather than signal. The `new_is_old` option lets you automatically suppress old `new` badges so they stop rendering after a configurable threshold. Only `new` badges are affected while `changed` and `deprecated` badges always render.
273+
274+
Add `new_is_old` to your `great-docs.yml`:
275+
276+
```{.yaml filename="great-docs.yml"}
277+
new_is_old: 3 releases
278+
```
279+
280+
With this setting, a `[version-badge new 0.3]` badge will render in versions 0.3 through 0.5 (three releases) and then silently disappear from version 0.6 onward. The badge is simply omitted from the output (no placeholder or residual markup is left behind).
281+
282+
#### Expiry Modes
283+
284+
| Value | Meaning |
285+
|---|---|
286+
| `"never"` | Badges never expire (the default) |
287+
| `"3 releases"` | Expire after 3 releases, counting all versions including prerelease |
288+
| `"2 minor releases"` | Expire after 2 releases, counting only non-prerelease versions |
289+
| `"0.6"` | Expire starting at version 0.6 (all `new` badges from before 0.6 are suppressed) |
290+
| `"2026-06-01"` | Expire after an absolute calendar date |
291+
| `"180 days"` | Expire 180 days after the badge's version was released (requires `released` dates in the version config) |
292+
293+
The `releases` and `minor releases` modes measure the distance between the badge's version and the version currently being built. For example, `3 releases` means "show this badge as long as the version being built is fewer than 3 releases newer than the badge's version." The `minor releases` variant is identical except that it skips prerelease entries when counting, so a `dev` prerelease doesn't consume a slot in the window.
294+
295+
::: {.callout-tip}
296+
## Choosing a mode
297+
Most projects should start with `"3 releases"` or `"2 minor releases"`. The release-counting modes are simple, predictable, and don't require any extra configuration. Use `days` only if your releases are irregular and you want time-based expiry.
298+
:::
299+
300+
#### Days Mode and Release Dates
301+
302+
The `days` mode requires `released` dates in your version configuration so that Great Docs can compute elapsed time:
303+
304+
```{.yaml filename="great-docs.yml"}
305+
new_is_old: 180 days
306+
307+
versions:
308+
- label: "0.7.0"
309+
tag: "0.7"
310+
latest: true
311+
released: "2026-01-15"
312+
- label: "0.6.0"
313+
tag: "0.6"
314+
released: "2025-09-01"
315+
- label: "0.5.0"
316+
tag: "0.5"
317+
released: "2025-03-15"
318+
```
319+
320+
A badge for a version without a `released` date is never expired (fail-open), so you can add dates incrementally.
321+
322+
#### Per-Page Override
323+
324+
You can override the global `new_is_old` setting on individual pages by adding `new-is-old` to the page's YAML frontmatter:
325+
326+
```{.yaml filename="important-feature.qmd"}
327+
---
328+
title: "Core Feature"
329+
new-is-old: never
330+
---
331+
```
332+
333+
This keeps all `new` badges visible on that page regardless of the global setting. The per-page value uses the same syntax as the global option (any expiry mode works).
334+
335+
#### Interaction with Fences
336+
337+
Badge expiry only affects **rendering** (whether the badge `<span>` appears in the HTML output). It does not change version fence behavior. A heading like `## Widget [version-badge new 0.3]` inside a `::: {.version-only versions=">=0.3"}` fence will still be included in matching versions even if the badge itself is suppressed. The fence controls structural inclusion; the badge is purely visual.
338+
269339
## Version Callouts
270340

271341
When a version change needs more explanation than a badge can provide, use a version callout. These render as styled admonition boxes that draw the reader's attention to important changes.
@@ -291,7 +361,7 @@ Use callouts for migration notes, deprecation notices, or any change that benefi
291361

292362
## API Reference Versioning
293363

294-
The API reference is the most complex part of versioned documentation because the public API surface classes, functions, parameters, and signatures changes between releases. Great Docs supports three strategies for keeping each version's reference accurate, from the most hands-on to the most automated.
364+
The API reference is the most complex part of versioned documentation because the public API surface (classes, functions, parameters, and signatures) changes between releases. Great Docs supports three strategies for keeping each version's reference accurate, from the most hands-on to the most automated.
295365

296366
### Strategy A: Pre-Written Snapshots
297367

0 commit comments

Comments
 (0)