从 JavaDoc 中提取所有方法的列表

发布于 2025-01-03 05:37:14 字数 461 浏览 2 评论 0原文

我有一些 javadoc 包,我想提取其中记载的所有方法的列表。像这样的东西:

path="C:\Doc\idex.html"; 

List<String> listMethods=ExtractAPI(path);

我不介意用什么语言来做这件事,但我猜java有一个内置的功能。

我尝试阅读javadoc doumntation:

http:// docs.oracle.com/javase/1.5.0/docs/guide/javadoc/doclet/overview.html

但无法清楚地理解是否可能,以及如果可能的话到底如何做。

谢谢!

I have some package of javadoc, and I want to extract a list of all methods doumented inside. somethong like:

path="C:\Doc\idex.html"; 

List<String> listMethods=ExtractAPI(path);

I don't mind the language to do it, but I guess that java has a builtin features for it.

I tried reading the javadoc doumntation:

http://docs.oracle.com/javase/1.5.0/docs/guide/javadoc/doclet/overview.html

But couldn't understand clear enough if it is possible, and if yes how exactly to do it.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绝對不後悔。 2025-01-10 05:37:14

最快的解决方案是解压缩 jar,然后执行如下操作:

find . -name "*.class" | sed s/\.class// | xargs javap -private

这将为 jar 中的每个 .class 文件生成类似于以下内容的输出:

Compiled from "SHTMLPanelSingleDocImpl.java"
class com.lightdev.app.shtm.SHTMLPanelSingleDocImpl extends com.lightdev.app.shtm.SHTMLPanelImpl{
    public com.lightdev.app.shtm.SHTMLPanelSingleDocImpl();
    protected void initDocumentPane();
    protected void initActions();
}

输出可能有所不同。对于其他反编译选项,请输入 javap -help

如果您需要特殊格式的输出(无法从上面获取,上面的语法非常规则,因此很容易操作),那么 javap 可能不是最佳选择。但由于你拒绝陈述问题的目的,所以不可能知道你想要完成什么。

Quickest solution is to unzip the jar then do something like this:

find . -name "*.class" | sed s/\.class// | xargs javap -private

This will produce output similar to the following for each .class file in the jar:

Compiled from "SHTMLPanelSingleDocImpl.java"
class com.lightdev.app.shtm.SHTMLPanelSingleDocImpl extends com.lightdev.app.shtm.SHTMLPanelImpl{
    public com.lightdev.app.shtm.SHTMLPanelSingleDocImpl();
    protected void initDocumentPane();
    protected void initActions();
}

Output may vary. For other decompilation options type javap -help.

If you need specifically-formatted output (that can't be grabbed from the above, which has pretty regular syntax thus is easily-manipulated) then javap may not be the best option. But since you refuse to state the purpose of the question, it's impossible to know what you're trying to accomplish.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文