spring-projects / spring-modulith

Modular applications with Spring Boot
https://spring.io/projects/spring-modulith
Apache License 2.0
779 stars 129 forks source link

Add option to let `Documenter` clear target folder before rendering documentation #644

Closed ciberkleid closed 2 months ago

ciberkleid commented 4 months ago

Request for a Documenter option that clears the target output directory before writing documentaiton.

Reasoning: If a module is renamed or deleted, any existing documentation will remain in the target output directory until the user runs a mvn clean. This can be misleading as the documentation will include modules that don't exist.

tobHai commented 3 months ago

I would like to contribute this functionality.
Currently, I have two options in my mind for the API of this feature.

Option 1: Add a new boolean parameter to the constructor of Documenter. Upon the first call of writeXYZ the given output directory is cleared if clearing is enabled for the Documenter instance. Subsequent calls won't clear the output directory again.

Option 2: Add a new method to the Documenter which clears the output directory and returns the Documenter instance to allow method chaining with the writeXYZ methods.

@ciberkleid, @odrotbohm what do you think about my suggestions? Do you have a different API in mind for this feature?

odrotbohm commented 3 months ago

Cora and me had a brief hacking session recently and we went down introducing an Options type similar to what the diagrams and canvas creations already take defaulting to an auto-clean. Find that – highly incomplete – code as a draft here. Feel free to take it from there.