Skip to content

Commit f5dfeb6

Browse files
authored
build(docs): generate brush and menu illustrations (#46)
Claude-Session: https://claude.ai/code/session_01JavEedb4MyR9NehY3HusTn
1 parent cb0e67c commit f5dfeb6

42 files changed

Lines changed: 5289 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitattributes‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docs/images/**/*.svg text eol=lf

‎build.gradle.kts‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,65 @@ modrinth {
297297
loaders.add("paper")
298298
syncBodyFrom.set(storePage)
299299
}
300+
301+
// Documentation tooling: the illustration generator, the stale-image check and the link checker. They live in
302+
// their own source sets, so shadowJar, which packages only main, keeps them out of the plugin jar.
303+
// See docs/development/documentation.md.
304+
val docsGen by sourceSets.creating {
305+
compileClasspath += sourceSets.main.get().output + sourceSets.test.get().output
306+
runtimeClasspath += output + compileClasspath
307+
}
308+
309+
val docsGenTest by sourceSets.creating {
310+
compileClasspath += docsGen.output + sourceSets.main.get().output + sourceSets.test.get().output
311+
runtimeClasspath += output + compileClasspath
312+
}
313+
314+
listOf(docsGen, docsGenTest).forEach { sourceSet ->
315+
configurations.named(sourceSet.implementationConfigurationName) { extendsFrom(configurations["testImplementation"]) }
316+
configurations.named(sourceSet.runtimeOnlyConfigurationName) { extendsFrom(configurations["testRuntimeOnly"]) }
317+
}
318+
319+
val docsDirectory = layout.projectDirectory.dir("docs")
320+
val docsGeneratorMain = "net.onelitefeather.bettergopaint.docsgen.DocsGenerator"
321+
322+
tasks.register<Test>("docsGenTest") {
323+
group = "documentation"
324+
description = "Runs the unit tests of the illustration generator and the link checker."
325+
testClassesDirs = docsGenTest.output.classesDirs
326+
classpath = docsGenTest.runtimeClasspath
327+
useJUnitPlatform()
328+
testLogging {
329+
events("passed", "skipped", "failed")
330+
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
331+
}
332+
}
333+
334+
tasks.register<JavaExec>("generateDocsImages") {
335+
group = "documentation"
336+
description = "Regenerates the SVG illustrations in docs/images from the brush and menu code."
337+
classpath = docsGen.runtimeClasspath
338+
mainClass.set(docsGeneratorMain)
339+
args("generate", docsDirectory.asFile.absolutePath)
340+
outputs.dir(docsDirectory.dir("images"))
341+
}
342+
343+
tasks.register<JavaExec>("checkDocsImages") {
344+
group = "documentation"
345+
description = "Fails when a file in docs/images is missing, differs from the generated output or is not generated."
346+
classpath = docsGen.runtimeClasspath
347+
mainClass.set(docsGeneratorMain)
348+
args("check", docsDirectory.asFile.absolutePath)
349+
}
350+
351+
tasks.register<JavaExec>("checkDocsLinks") {
352+
group = "documentation"
353+
description = "Fails when a relative link or image in docs/ does not resolve, or a builder page has no illustration."
354+
classpath = docsGen.runtimeClasspath
355+
mainClass.set(docsGeneratorMain)
356+
args("links", docsDirectory.asFile.absolutePath)
357+
}
358+
359+
tasks.named("check") {
360+
dependsOn("docsGenTest", "checkDocsImages", "checkDocsLinks")
361+
}

‎docs/development/documentation.md‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,46 @@ Pages are written for two readers. Server admins install, configure and permissi
2626
builders paint with it. `index.md` sends each to their entry points, and `SUMMARY.md` groups the
2727
how-to guides by audience. Tutorials: one per audience, each ending with a hand-off to the next
2828
pages.
29+
30+
## Illustrations
31+
32+
The brush and menu pictures in `docs/images/` are generated from the code, never drawn by hand.
33+
The generator is the `docsGen` source set (`src/docsGen`); it runs the real brush code on the test
34+
fixtures and renders the brush menu from `GUI.layout()`. Output is SVG with a fixed seed, LF line
35+
endings and no timestamp, so two runs produce the same bytes on every operating system.
36+
37+
| Command | What it does |
38+
|---|---|
39+
| `./gradlew generateDocsImages` | Writes `docs/images/brushes/*.svg` and `docs/images/menu/*.svg` |
40+
| `./gradlew checkDocsImages` | Fails when a generated image is missing or differs, or when a generated folder (`brushes/`, `menu/`) holds a file the generator does not produce; the message names the file |
41+
| `./gradlew checkDocsLinks` | Fails when a relative link or image in `docs/` does not resolve, when a builder page has neither an image nor a link to `development/screenshot-shotlist.md`, or when a planned image named in a hint is not listed in that shotlist; external links are not fetched |
42+
| `./gradlew docsGenTest` | Unit tests of the generator and the checker |
43+
44+
`checkDocsImages`, `checkDocsLinks` and `docsGenTest` run inside `./gradlew check`, so `./gradlew build`
45+
fails on stale images and broken links.
46+
47+
Rules for the generated files:
48+
49+
- The generated folders `docs/images/brushes/` and `docs/images/menu/` hold generated files only.
50+
`checkDocsImages` fails on any other file in them.
51+
- Hand-captured images, such as in-game screenshots and GIFs for the builder guides, go in
52+
`docs/images/screenshots/`. `checkDocsImages` does not check that folder for staleness, and
53+
`checkDocsLinks` still fails when a page links to a missing file there. A planned capture named in a
54+
hint block must be listed in `docs/development/screenshot-shotlist.md`.
55+
- A new brush needs a scene in `BrushScenes`; `docsGenTest` fails and names the brush until it has one.
56+
Run `./gradlew generateDocsImages`, commit the new SVG and update `reference/brushes.md` in the same
57+
pull request.
58+
- A change to the menu layout needs no code change here: run `./gradlew generateDocsImages` and commit
59+
the menu SVGs.
60+
- The generator reads no clock and no network. Fixed terrain comes from the test fixtures
61+
(`MemoryExtent`, `StrokeBuilder`, `Terrain`); the generator contains no copy of a brush algorithm.
62+
- Builder pages that still have no illustration are listed in
63+
`DocsLinkChecker.BUILDER_PAGES_AWAITING_ILLUSTRATIONS`. Remove the entry when the page embeds an
64+
image, and give a new builder page an image in the same pull request.
65+
66+
Pages that embed each generated file:
67+
68+
| Generated file | Embedded by |
69+
|---|---|
70+
| `images/brushes/*.svg`, one per brush | No page yet; the change `builder-guides-with-images` embeds them |
71+
| `images/menu/menu-sphere-default.svg`, `menu-spray-disabled.svg`, `menu-angle.svg` | No page yet; the change `builder-guides-with-images` embeds them |
Lines changed: 124 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)