This project implements a utility that generates OpenRewrite recipe documentation in markdown format for all recipes on the classpath.
This project also builds up a CHANGELOG to track what has changed over time. The way this works is that, every time
this project is run, it looks in the /src/main/resources
directory for either a recipeDescriptors.yml
or a
snapshotRecipeDescriptors.yml
file (depending on whether this is being run for an OpenRewrite release or a weekly
snapshot). It will then parse that file and compare it to the latest information obtained. If there are differences,
they will be outlined in a CHANGELOG that will be created in the resources directory. After the CHANGELOG is built,
the latest information will be stored in the descriptors file for future use.
By default, the assumption is that this is being run for an OpenRewrite release. If you'd like to run it for a snapshot
release, you'll need to modify the build.gradle.kts
file to change rewriteVersion
to whatever version you want
(such as latest.integration
) and deployType
to snapshot
.
Once you have the CHANGELOG created, you can copy it over to the changelog section in the OpenRewrite docs. When doing a full release, make sure you remove the old snapshot releases.
A few important things to note:
SUMMARY.md
. If you don't, those new files won't appear.It's possible to configure the markdown generator to create a diff log that generates something like this. That doc shows all of the recipes created since a particular version of OpenRewrite. Companies may want to see the work we've done for them since they've signed on. In order to make this log, please follow these steps:
7.24.0
.7.24.0
, then rewrite-circleci
would be 1.8.0
and rewrite-spring
would be 4.22.1
.build.gradle.kts
file to include all of those old versions. You can see an example of this and some key notes in the old-build.gradle-example.kts
file provided in the src
directory.snapshot
specified as the deploy type and all of the versions specified. This will update the snapshotRecipeDescriptors.yml
file with all of the details from that version.snapshotRecipeDescriptors.yml
file into a new file for safe keeping. This file will be used as a backup so you don't need to do the above steps every time you wish to regenerate the log.build.gradle.kts
file you made above.diff
as the deploy type in the build.gradle.kts
file, specify the diffFileName
as the name of the company you're making this for, specify latest.integration
for the rewriteVersion
, and copy over the snapshot descriptors file you made earlier into the diffRecipeDescriptors.yml
file.diffFileName.md
that shows all of the recipes created between the old version and the latest snapshot.diffRecipeDescriptors.yml
file and re-run the generator.Note: It's possible that with old versions of Rewrite that the markdown generator might not compile. I added a comment in the code that shows what one of the lines need to change to with some older versions.
When you run this project for either a snapshot or a full release, all documentation will be updated in the
build/docs
directory. There are three key pieces to that: the reference
folder and the SUMMARY_snippet.md
and latest-versions-of-every-openrewrite-module.md
files.
If you wish to update the docs, you should replace this directory
with the reference/recipe
folder generated here.
After that, you should update the SUMMARY.md
with the snippet generated in the SUMMARY_snippet.md
file.
You can replace latest-versions-of-every-openrewrite-module.md with the one in build/docs
,
but be sure to fill in the rewrite-recipe-bom
version with the latest version of the BOM.
Please note that for snapshot releases, you should not copy over all the generated files. This is because we want
the docs to generally only show full release information. Rather, you should copy over the specific new docs you want
(as well as the updates to the SUMMARY_snippet.md
).
Also note that this does not cover all of the documentation that needs to be updated with a release. There are still others docs that needs to be updated manually, in particular around versions used in popular recipe guides.
Quickstart:
build/docs
./gradlew run
./gradlew run --args="desired/output/path"
./gradlew run --args="--help"
./gradlew markdownToHtml
rm -rf ../../rewrite-docs/reference/recipes
cp -r build/docs/reference/recipes ../../rewrite-docs/reference/
cp -r build/docs/latest-versions-of-every-openrewrite-module.md ../../rewrite-docs/reference/
The SUMMARY_snippet.md
file generated does not entirely match the one in the rewrite-docs
repository. This is
because GitBook makes some strange changes at time automatically. This hasn't been investigated, yet.