mersinvald / aquamarine

Inline diagrams for rustdoc with mermaid.js
MIT License
487 stars 25 forks source link

Support for `include_str`? #19

Closed Testare closed 1 year ago

Testare commented 2 years ago

I think this is a great project. I was trying to use aquamarine so I could have diagrams for some high-level designs in my crate, and given the potential complexity of this I wanted to write this documentation in its own file and add it to the module like so

#[cfg_attr(doc, aquamarine::aquamarine)]
#[doc = include_str!("../foobar.md")]

I've also tried

#[cfg_attr(doc, aquamarine::aquamarine, doc = include_str!("../foobar.md"))]

I've also tried rearranging the order but it seems not to matter.

However, in both cases what happens is that the file is included, and the mermaid code blocks are rendered as regular code blocks instead of diagrams. I'm a relatively new rustacean with no macro writing experience, is there a way to accomplish this?

mersinvald commented 2 years ago

Hi @Testare, this case has to be supported by a macro, there's no way to do it without modifying aquamarine

drbh commented 1 year ago

@Testare this is not exactly the feature you specified above, but this PR #26 is how I'm including the contents of an external file (it can probably be modified for the API you specified if this does not meet your usecase).

#[cfg_attr(doc, aquamarine, path = "./diagram.md")]

Hope this is helpful!

mersinvald commented 1 year ago

Fixed in #26, huge thanks to @drbh