如何为我没有源代码的 .jar 文件中的类生成 JavaDoc 文档?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3115335/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to generate JavaDoc documentation for classes in a .jar file that I don't have the source code for?
提问by User 1034
I want to generate the API for all the classes that are there in my Java 1.6 application. It should look like regular Java 1.5 API documentation.
我想为 Java 1.6 应用程序中的所有类生成 API。它应该看起来像常规的 Java 1.5 API 文档。
I don't have the source code. I have class files in a jar file.
我没有源代码。我在 jar 文件中有类文件。
采纳答案by User 1034
You can't produce Javadoc from jars of class files, not even rudimentary Javadoc. You can only generate Javadoc from source files, because that is where the Javadoc lives.
您不能从类文件的 jar 文件中生成 Javadoc,甚至是基本的 Javadoc。您只能从源文件生成 Javadoc,因为这是 Javadoc 所在的位置。
回答by TheLQ
Who is changing my question ? I don't have the source code. I have class files in a jar file. Purushotham 47 mins ago
谁在改变我的问题?我没有源代码。我在 jar 文件中有类文件。普鲁索塔姆 47 分钟前
You don't have any source files? Well then you're probably out of luck. There might be some obscure plugin buried in Eclipse's huge database that can do it from class files, but even then you're only going to get method signatures, not any comments.
你没有任何源文件?那么你可能不走运了。Eclipse 庞大的数据库中可能隐藏着一些晦涩的插件,可以从类文件中执行此操作,但即便如此,您也只会获得方法签名,而不是任何注释。
However, if this is your project that you have written then you can generate JavaDoc in your IDE. For Eclipse do Project > Generate JavaDoc. In NetBeans, right click your project and select Generate JavaDoc.
但是,如果这是您编写的项目,那么您可以在 IDE 中生成 JavaDoc。对于 Eclipse,执行 Project > Generate JavaDoc。在 NetBeans 中,右键单击您的项目并选择生成 JavaDoc。
If you're wanting to include your dependencies, then that's a very bad idea. Always link to your dependencies' JavaDocs, never include it in yours. If not for losing your sanity at seeing a massive wall of classes from Large Overly Framework X, it's just to keep them separate. If I want to read the JavaDoc on your project, I want to read it only on your project, not on slf4j.
如果您想包含您的依赖项,那么这是一个非常糟糕的主意。始终链接到依赖项的 JavaDocs,切勿将其包含在您的依赖项中。如果不是因为看到来自 Large Overly Framework X 的大量类而失去理智,那只是为了将它们分开。如果我想阅读您项目的 JavaDoc,我只想阅读您的项目,而不是 slf4j。
回答by Brad Parks
I haven't used it, but this opensource project claims to create docs from java class or jar files:
我没有使用过它,但是这个开源项目声称可以从 java 类或 jar 文件创建文档:
回答by Loduwijk
You can use the javap
command on any class in your classpath. This will not produce Javadoc files, but it will allow you to see what the class provides.
您可以javap
在类路径中的任何类上使用该命令。这不会生成 Javadoc 文件,但可以让您查看该类提供的内容。
Ex...
前任...
javap java.lang.String
produces the following output
javap java.lang.String
产生以下输出
public final class java.lang.String implements java.io.Serializable, java.lang.Comparable<java.lang.String>, java.lang.CharSequence {
public static final java.util.Comparator<java.lang.String> CASE_INSENSITIVE_ORDER;
public java.lang.String();
public java.lang.String(java.lang.String);
public java.lang.String(char[]);
public java.lang.String(char[], int, int);
...and after a bunch of constructors there are other methods...
...在一堆构造函数之后还有其他方法......
public int length();
public boolean isEmpty();
public char charAt(int);
public int codePointAt(int);
And you can have it show you other things too, but this is probably the most helpful.
你也可以让它向你展示其他东西,但这可能是最有帮助的。
Not exactly what you are looking for, but if you just have a jar with a bunch of classes this might be your best option.
不完全是你要找的,但如果你只有一个带有一堆类的罐子,这可能是你最好的选择。