我能够在Android项目中记录几乎所有内容,并为它们生成漂亮的API参考。
唯一的例外是XML文件,尤其是包含可样式属性的属性文件。
例如, res / values / attrs.xml 的一部分:
<resources>
<declare-styleable name="TimelineView">
<attr name="drawCollapsed" format="boolean" />
</declare-styleable>
</resources>
我注意到在Android源代码中standard attributes documentation is generated for R。
我生成的文档显然包含了我的属性类型的一些通用文本(在本例中为boolean):
是否有此类文档的官方规范或记录源自XML的属性的方式,以便描述出现在自动生成的JavaDoc中?
答案 0 :(得分:17)
我不确定这是一个官方标准,但在写我的问题时我偶然发现了它。无论如何,为了可能遇到这个问题的其他人,我决定发布问题并回答它。
我能够通过在属性上方添加XML注释来生成属性文档,现在我已经看到它了,这似乎很明显。
我最初尝试过而没有重建我的项目,导致原来缺乏文档。一旦我重建了模块并生成了JavaDoc,我就得到了理想的结果。
要遵循的步骤是:
在所需属性上方添加评论。
<resources>
<declare-styleable name="TimelineView">
<!-- Initially draw collapsed until adapters have been set. -->
<attr name="drawCollapsed" format="boolean" />
</declare-styleable>
</resources>
重建相关模块/项目。
如果有人知道任何官方消息来源或官方方法,请不要犹豫与他人分享。
<强>更新强>
看来这确实是在Android source files中完成的方式,包括注释中的一些JavaDoc指令,HTML和子注释,例如:
<!-- Alignment constants. -->
<attr name="alignmentMode">
<!-- Align the bounds of the children.
See {@link android.widget.GridLayout#ALIGN_BOUNDS}. -->
<enum name="alignBounds" value="0" />
<!-- Align the margins of the children.
See {@link android.widget.GridLayout#ALIGN_MARGINS}. -->
<enum name="alignMargins" value="1" />
</attr>