如何在 javadoc 中生成指向 android 类引用的链接? [英] How to generate links to the android Classes' reference in javadoc?

查看:44
本文介绍了如何在 javadoc 中生成指向 android 类引用的链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在 Eclipse 中为我的 Android 项目生成 javadoc 时,有很多警告,比如

When I generate javadoc for my Android project in Eclipse, there are lots of warnings like

cannot find symbol
symbol  : class TextView

warning - Tag @see: reference not found: android.app.Dialog

我也试过

-link http://developer.android.com/reference/
-link http://java.sun.com/j2se/1.4.2/docs/api/

额外的javadoc选项(带有空格的路径名必须用引号括起来)标签在Configure Javadoc Arguments(eclipse->project->Generate Javadoc的第三个对话框)).

in Extra javadoc options (path names with white spaces must be enclosed in quotes) tab in Configure Javadoc Arguments (3rd dialog of eclipse->project->Generate Javadoc).

但只有 -link http://java.sun.com/j2se/1.4.2/docs/api/ 有效,即用于 String 类链接 http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true 生成.但是对于 android.app.Dialog ,不会生成链接.

But only -link http://java.sun.com/j2se/1.4.2/docs/api/ is working i.e for String class link http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true is generated. but for android.app.Dialog , no link is generated.

编辑

我也试过在Select referenced archives and projects中选择android.jar 应该生成链接的Configure Javadoc arguments for standard doclet 中的选项卡(eclipse->project->Generate Javadoc 的第二个对话框),但这会在本地 android-sdk 目录中创建指向文档的本地链接,而不是像 Java API 那样的在线 Android 参考.

I also tried selecting android.jar in Select referenced archives and projects to which links should be generated tab in Configure Javadoc arguments for standard doclet (2nd dialog of eclipse->project->Generate Javadoc), but this creates local links to docs in local android-sdk directory, NOT the online Android references like it does for Java APIs.

推荐答案

Javadoc 依赖于一个名为 package-list 的文件来确定在给定目录下记录了哪些 Java 包.出于某种原因,http://d.android.com缺少这样的文件/reference/,因此使用

Javadoc relies on a file called package-list to determine what Java packages are documented below a given directory. For some reason, such a file is missing for http://d.android.com/reference/, therefore the "naive" approach with

-link http://d.android.com/reference/

不起作用–您收到一条警告,提示无法检索包列表,并且您的文档中未生成任何链接.(注意:第二个 Eclipse 对话框中的复选框只是为您组合了 -link 参数,所以这并没有什么区别)

doesn't work – you get a warning that the package-list could not be retrieved and no links are generated into your docs. (Note: The checkboxes in that 2nd eclipse dialog just assemble -link parameters for you, so that doesn't really make any difference)

但是,Javadoc 提供了 -linkoffline 参数,以便能够针对这种情况进行精确调整:您想在线链接到其他一些 Javadoc 文档,但您无法访问它在生成您自己的文档时.下面是它的工作原理:虽然 -link 只接受一个参数(您要链接到的 JavaDoc 文档的 URL),但 -linkoffline 接受第二个参数.那个是 package-list 文件的位置!

However, Javadoc offers the -linkoffline parameter to be able to adjust for precisely this situation: You want to link to some other Javadoc documentation online, but you cannot access it at the time of generating your own docs. Here's how it works: While -link takes only one parameter (the URL of the JavaDoc docs you want to link to), -linkoffline takes a second one. That one is the location of the package-list file!

因此,要链接到在线 Android 参考文档,您应该不要选择第二个日食对话框中的任何复选框,而是添加

So, to link to the online Android reference documentation, you should not select any checkboxes in the 2nd eclipse dialog, but instead add

-linkoffline http://d.android.com/reference file:/C:/pathtoyour/android-sdk-windows/docs/reference

在第三个对话框的 Extra Javadoc 选项 中.这样您就可以使用本地安装的 Android 文档的 package-list,但生成的 Javadoc 中的链接仍然会指向在线版本.

in the Extra Javadoc options in the 3rd dialog. That way you use the package-list of your locally installed Android docs, but the links in your generated Javadoc will still point to the online version anyway.

希望能帮到你!

这篇关于如何在 javadoc 中生成指向 android 类引用的链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆