在 dart 文档注释中使用本地图像资源

Isa*_* dl 5 dart flutter dartdoc

如何在 dart 文档注释中使用本地资源?当使用基于网络的 url 时,这可以正常工作,如下所示:

/// ![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)
Run Code Online (Sandbox Code Playgroud)

我想做的是引用我的资产文件夹中的一些图像资产并显示它。像这样的东西:

///![](/assets/some/local/path.png)
///![](/assets/some/other/path.svg)
Run Code Online (Sandbox Code Playgroud)

但我无法获得任何相对的工作路径,这可能吗?

小智 2

这并不完全令人满意,但我只是制作了一个 shell 脚本,将文档中的图像复制到生成的 HTML 树中的正确位置,即:

#!/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 ..
Run Code Online (Sandbox Code Playgroud)

ObRant:令我失望的是,文档生成工具通常不会这样做(至少据我所知)。视觉沟通可以极大地改善文档!

例如,考虑一下 Java 的这一点。UML 对于理解结构有很大帮助。 http://spritely.jovial.com/javadocs/index.html?edu/calpoly/spritely/package-summary.html