Isak dl
Isak dl

Reputation: 577

Using local image assets in dart documentation comments

How can you use local assets in a dart documentation comment? This works fine when using a webbased url,, like so:

/// ![A row of icons representing a pink heart, a green musical note, and a blue umbrella](https://flutter.github.io/assets-for-api-docs/assets/widgets/icon.png)

What I would like to do is reference some image assets I have in my assets folder and display that. Something like this:

///![](/assets/some/local/path.png)
///![](/assets/some/other/path.svg)

But I cannot get any relative path to work, is this possible at all?

Upvotes: 5

Views: 932

Answers (2)

atreeon
atreeon

Reputation: 24097

This works for public repos.

///![my image](https://myoctocat.com/assets/images/base-octocat.svg)

and this works for private (displays a link in intellij idea, not the image).

/// [private repo link](https://github.com/atreeon/xyz/blob/abc/x.png?raw=true)

Again, not completely satisfying but it is another work around.

Upvotes: 0

Bill Foote
Bill Foote

Reputation: 421

It's not entirely satisfying, but I just made a shell script to copy images that are part of the documentation into the right place in the generated HTML tree, viz:

#!/bin/sh -x
cd `dirname $0`
dartdoc
cd lib
for f in `find . -name '*.comments' -print` ; do
    dir=`basename $f .comments`
    cp -r $f ../doc/api/$dir
done
cd ..

ObRant: It disappoints me that documentation generation tools often don't generally this (at least AFAIK). Visual communication can greatly improve documentation!

For example, consider this bit of Java. The UML is a big help in understanding the structure. http://spritely.jovial.com/javadocs/index.html?edu/calpoly/spritely/package-summary.html

Upvotes: 2

Related Questions