Skip to content

Commit 51c051f

Browse files
committed
Keep the formatter version in one place
The version the pages install was written out in nineteen places. It now lives once, as ojf_version under [project.extra] in zensical.toml, and the pages say {{ ojf_version }}: the macros plugin that Zensical ships puts the value in before the Markdown is rendered, so it reaches code blocks, their copy button and the search index. The key is not extra.version, because the theme reads that one as the switch for a version selector. The plugin runs strict. With its defaults a misspelt variable renders as nothing and a stray {{ leaves the whole page unrendered, and the strict build still passes; with on_undefined and on_error_fail set, both fail the build. For the same reason the GitHub Actions expression on the GitHub Action page is wrapped in raw. The worked example on the Migrate page and the default of the action's own version input keep their literal versions: the first describes 2.98.0.1 in particular, the second follows the action's releases. The built site is byte-identical to the one before, all fourteen pages and the search index.
1 parent 05718c1 commit 51c051f

9 files changed

Lines changed: 32 additions & 19 deletions

File tree

‎docs/get-started/command-line.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ Pick the file for your platform from the
1414
| Linux AArch64, glibc | `open-java-format-linux-glibc_aarch64` |
1515
| macOS, Apple silicon | `open-java-format-macos_aarch64` |
1616
| macOS, Intel | `open-java-format-macos_x86-64` |
17-
| Anything else with Java 21 or later | `open-java-format-2.98.0.1-all.jar` |
17+
| Anything else with Java 21 or later | `open-java-format-{{ ojf_version }}-all.jar` |
1818

1919
There is no native binary for Windows or for musl-based Linux such as Alpine. Use the jar there.
2020

2121
``` sh title="Native binary, here for Apple silicon"
22-
curl -LO https://github.com/openjavaformat/open-java-format/releases/download/2.98.0.1/open-java-format-macos_aarch64
22+
curl -LO https://github.com/openjavaformat/open-java-format/releases/download/{{ ojf_version }}/open-java-format-macos_aarch64
2323
chmod +x open-java-format-macos_aarch64
2424
./open-java-format-macos_aarch64 --version
2525
```
@@ -34,8 +34,8 @@ assume you did.
3434
not get the flag.
3535

3636
``` sh title="Runnable jar"
37-
curl -LO https://github.com/openjavaformat/open-java-format/releases/download/2.98.0.1/open-java-format-2.98.0.1-all.jar
38-
java -jar open-java-format-2.98.0.1-all.jar --version
37+
curl -LO https://github.com/openjavaformat/open-java-format/releases/download/{{ ojf_version }}/open-java-format-{{ ojf_version }}-all.jar
38+
java -jar open-java-format-{{ ojf_version }}-all.jar --version
3939
```
4040

4141
The jar carries its dependencies and the `Add-Exports` entries the formatter needs, so it runs

‎docs/get-started/eclipse.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ run on Java 21 or later, as current Eclipse packages do.
55

66
## Install
77

8-
1. Download `open-java-format-eclipse-plugin-2.98.0.1.jar` from the
8+
1. Download `open-java-format-eclipse-plugin-{{ ojf_version }}.jar` from the
99
[latest release](https://github.com/openjavaformat/open-java-format/releases/latest).
1010
2. Open `eclipse.ini` and add these lines after `-vmargs`. The formatter reaches into javac, and
1111
these options allow it.

‎docs/get-started/github-actions.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ jobs:
1919

2020
- uses: openjavaformat/open-java-format-action@v1
2121
with:
22-
version: '2.98.0.1'
23-
mode: ${{ github.event_name == 'push' && 'all' || 'changed' }}
22+
version: '{{ ojf_version }}'
23+
mode: {% raw %}${{ github.event_name == 'push' && 'all' || 'changed' }}{% endraw %}
2424
```
2525
2626
The [action](https://github.com/openjavaformat/open-java-format-action) downloads the binary, lists

‎docs/get-started/gradle.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ formatter version as the build. It needs Gradle 9 and a Gradle daemon running on
1010
``` groovy title="build.gradle"
1111
plugins {
1212
id 'java'
13-
id 'dev.openjavaformat.java-format' version '2.98.0.1'
13+
id 'dev.openjavaformat.java-format' version '{{ ojf_version }}'
1414
}
1515

1616
repositories {
@@ -23,7 +23,7 @@ formatter version as the build. It needs Gradle 9 and a Gradle daemon running on
2323
``` kotlin title="build.gradle.kts"
2424
plugins {
2525
java
26-
id("dev.openjavaformat.java-format") version "2.98.0.1"
26+
id("dev.openjavaformat.java-format") version "{{ ojf_version }}"
2727
}
2828

2929
repositories {
@@ -82,7 +82,7 @@ is resolved by the root project, so the root project needs the repository too.
8282

8383
``` groovy title="build.gradle"
8484
plugins {
85-
id 'dev.openjavaformat.java-format' version '2.98.0.1' apply false
85+
id 'dev.openjavaformat.java-format' version '{{ ojf_version }}' apply false
8686
}
8787

8888
allprojects {
@@ -101,7 +101,7 @@ is resolved by the root project, so the root project needs the repository too.
101101

102102
``` kotlin title="build.gradle.kts"
103103
plugins {
104-
id("dev.openjavaformat.java-format") version "2.98.0.1" apply false
104+
id("dev.openjavaformat.java-format") version "{{ ojf_version }}" apply false
105105
}
106106

107107
allprojects {

‎docs/get-started/index.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ the same formatter, so they all produce the same files. Set up the ones your pro
55

66
!!! info "Requirements"
77

8-
The current version is **2.98.0.1**. Everything except the native binaries needs Java 21 or
8+
The current version is **{{ ojf_version }}**. Everything except the native binaries needs Java 21 or
99
later, and the Gradle plugin needs Gradle 9.
1010

1111
<div class="grid cards" markdown>

‎docs/get-started/intellij-idea.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ has an **Install to IDE** button that does the same for an IDE that is already r
2424

2525
A version that is not on the Marketplace yet can be installed from a release.
2626

27-
1. Download `open-java-format-idea-plugin-2.98.0.1.zip` from the
27+
1. Download `open-java-format-idea-plugin-{{ ojf_version }}.zip` from the
2828
[latest release](https://github.com/openjavaformat/open-java-format/releases/latest). Do not
2929
unpack it.
3030
2. Open **Settings**, go to **Plugins**, click the gear icon and choose **Install Plugin from

‎docs/get-started/spotless.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ that line.
1616
plugins {
1717
id 'java'
1818
id 'com.diffplug.spotless' version '8.10.2'
19-
id 'dev.openjavaformat.java-format' version '2.98.0.1'
19+
id 'dev.openjavaformat.java-format' version '{{ ojf_version }}'
2020
}
2121

2222
repositories {
@@ -30,7 +30,7 @@ that line.
3030
plugins {
3131
java
3232
id("com.diffplug.spotless") version "8.10.2"
33-
id("dev.openjavaformat.java-format") version "2.98.0.1"
33+
id("dev.openjavaformat.java-format") version "{{ ojf_version }}"
3434
}
3535

3636
repositories {
@@ -72,7 +72,7 @@ The pull request [diffplug/spotless#3084](https://github.com/diffplug/spotless/p
7272

7373
``` xml title="pom.xml, with the pull request merged"
7474
<openJavaFormat>
75-
<version>2.98.0.1</version>
75+
<version>{{ ojf_version }}</version>
7676
</openJavaFormat>
7777
```
7878

‎docs/index.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ chain breaks into one call per line.
9898

9999
``` groovy title="build.gradle"
100100
plugins {
101-
id 'dev.openjavaformat.java-format' version '2.98.0.1'
101+
id 'dev.openjavaformat.java-format' version '{{ ojf_version }}'
102102
}
103103
```
104104

105105
=== "Kotlin"
106106

107107
``` kotlin title="build.gradle.kts"
108108
plugins {
109-
id("dev.openjavaformat.java-format") version "2.98.0.1"
109+
id("dev.openjavaformat.java-format") version "{{ ojf_version }}"
110110
}
111111
```
112112

@@ -141,7 +141,7 @@ Downloads, checksums and every option are on the [Command line](get-started/comm
141141

142142
- uses: openjavaformat/open-java-format-action@v1
143143
with:
144-
version: '2.98.0.1'
144+
version: '{{ ojf_version }}'
145145
```
146146
147147
The [action](https://github.com/openjavaformat/open-java-format-action) downloads the native binary

‎zensical.toml‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@ scheme = "slate"
9999
toggle.icon = "lucide/moon"
100100
toggle.name = "Switch to system preference"
101101

102+
# The formatter version that the pages install. A page writes it as {{ ojf_version }}, and the macros
103+
# plugin puts it in before the Markdown is rendered, so it lands in code blocks too. The key is not
104+
# extra.version: the theme reads that one as the switch for a version selector.
105+
[project.extra]
106+
ojf_version = "2.98.0.1"
107+
108+
# Renders every page as a Jinja template, for {{ ojf_version }}. A misspelt variable or a stray {{
109+
# fails the build instead of leaving a gap or the raw text on the site.
110+
# https://zensical.org/docs/compatibility/mkdocs/plugins/#macros
111+
[project.plugins.macros]
112+
on_undefined = "strict"
113+
on_error_fail = true
114+
102115
# [[project.extra.social]]
103116
# icon = "fontawesome/brands/github"
104117
# link = "https://github.com/user/repo"

0 commit comments

Comments
 (0)