adrianvlupu / C4-Builder

This is a documentation builder. You feed it .md and .puml and it exports a site, pdf, or a markdown with navigation.
https://adrianvlupu.github.io/C4-Builder/
MIT License
562 stars 93 forks source link

Partial build in development #55

Closed vellala2000 closed 2 years ago

vellala2000 commented 2 years ago

c4builder seems to be building images for all of them for every build even when there are no changes. It would be great if we can only build images where there are changes.

same thing with -watch as well.

MickeJohannesson commented 2 years ago

I have a working solution on this one (for both generate full or on watch with local images). Sadly I only have it in my PR #56 code (I haven't commited this solution in to that one)

Solution: First it makes a backup of the current Docs folder and all it contents, and then clean the Docs folder. During generation of images it will calculate a checksum of the PUML file and store all of the checksums in a file in root. If checksum and a copy of the image exists it will instead of generating a new image copy it from the backup. When finished it will remove the backup.

For my own doc it takes about 25 seconds to generate, but now it only need to generate the image needed and it takes about 1-2 seconds if I change one PUML file.

vellala2000 commented 2 years ago

Sounds like good start. we could just simply keep what's in doc/public folder if there is no change in puml file checksum. That way we don't need to backup and restore..

MickeJohannesson commented 2 years ago

I could of course traverse it backwards and remove the images that has a modified puml file, or where the puml file can't be found. Need to handle all other changes too, like rename or remove of folders, MD files and other files. Not sure how the current solution will work, because it is made to work on an empty folder at each run. The risk is that a lot of the code needs to be modified. What I know is that it will be a more complex solution.

adrianvlupu commented 2 years ago

@vellala2000 You are right about the image generation, it needs to generate only when needed. At first it wasn't really a problem because the image generation worked in parallel, but at some point I noticed some images were randomly 0 bytes and kept them sequential.

@MickeJohannesson I included your changes, just with a lot of refactoring. If you have time, check it out.

MickeJohannesson commented 2 years ago

I'll haven't made a PR for the partial image update. Will fetch your latest, add my solution and create a new PR for it. You'll have it tomorrow or the day after.

adrianvlupu commented 2 years ago

Thanks again. It's merged