asciidoctor / asciidoctor-diagram

:left_right_arrow: Asciidoctor diagram extension, with support for AsciiToSVG, BlockDiag (BlockDiag, SeqDiag, ActDiag, NwDiag), Ditaa, Erd, GraphViz, Mermaid, Msc, PlantUML, Shaape, SvgBob, Syntrax, UMLet, Vega, Vega-Lite and WaveDrom.
http://asciidoctor.org
MIT License
439 stars 107 forks source link

Disable generation and store pre-generated the image files #382

Closed nfrankel closed 1 year ago

nfrankel commented 2 years ago

Is it possible to pre-generate the image files and just "use" them during the build? My idea is to save on Cloud build-time.

Context: I'm using Jekyll and my posts are in Asciidoc. The idea is to generate images from the posts on my machine, store them in Git, and reuse them in the site as is, without re-generating them during the build on the Cloud.

pepijnve commented 2 years ago

Kind of, sort of. The diagram processor has a mechanism to avoid rerendering images if nothing changed in the inputs. It does this by computing a hash over the diagram source code and saving that in a metadata file along with some other attributes. If the metadata file exists when rendering and the hash has not changed the rendered image will be used as is.

These metadata files get written to a .asciidoctor/diagram directory relative to the asciidoc file. You can override that per diagram block using the cachedir attribute or globally using the diagram-cachedir document attribute.

I think you should be able to use this to achieve what you're trying to do, but I haven't tried this out myself.

nfrankel commented 2 years ago

Thanks @pepijnve, I'll have a look!