Add image at crystal docs generation time

Hi,
I’m looking for a way to add an image (png or svg) when generating project documentation with crystal docs.
Is there any way of doing this?

Related: Include static assets in doc generator · Issue #13756 · crystal-lang/crystal · GitHub

1 Like

Currently, crystal docs only renders API documentation of the Crystal code.

An easy workaround is to supplement crystal docs with an external build script that takes care of whatever else you need.
We’re using this in the crystal repository’s Makefile for example:

Thanks @straight-shoota , but I’m not sure I understand what you mean.

I already have my images in docs/assets/images.
What’s the effect to the copy from the doc/ folder then ?
Does it mean I have to store my image in that folder ?
And how do I reference the image in my source code ?
I tried the markdown syntax,with various paths, but no luck!

![some text](/assets/images/image.png)

[Edit] Ok, I succeeded in using relative paths (…/…/assets/images/image.png), without needing to copy anything. So, it works, but this is not what you suggested and I wonder if there is another and better solution.

The example is just to demonstrate how to move pre-existing assets in the same place as the output of crystal docs.

Path resolution of the rendered HTML should be straightforward within the file structure of that target directory. The doc generator does not alter URLs.

Ah Ok, it’s all clear then.
Thanks.