简体   繁体   English

如何为我没有源代码的.jar文件中的类生成JavaDoc文档?

[英]How to generate JavaDoc documentation for classes in a .jar file that I don't have the source code for?

I want to generate the API for all the classes that are there in my Java 1.6 application. 我想为我的Java 1.6应用程序中的所有类生成API。 It should look like regular Java 1.5 API documentation. 它应该看起来像常规的Java 1.5 API文档。

I don't have the source code. 我没有源代码。 I have class files in a jar file. 我在jar文件中有类文件。

You can't produce Javadoc from jars of class files, not even rudimentary Javadoc. 你不能从类文件的jar中生成Javadoc,甚至不能生成基本的Javadoc。 You can only generate Javadoc from source files, because that is where the Javadoc lives. 您只能从源文件生成Javadoc,因为这是Javadoc所在的位置。

I haven't used it, but this opensource project claims to create docs from java class or jar files: 我没有使用它,但这个开源项目声称从java类或jar文件创建文档:

http://classdoc.sourceforge.net/ http://classdoc.sourceforge.net/

You can use the javap command on any class in your classpath. 您可以在类路径中的任何类上使用javap命令。 This will not produce Javadoc files, but it will allow you to see what the class provides. 这不会产生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. 不完全是你想要的,但如果你只有一个带有一堆课程的罐子,这可能是你最好的选择。

Who is changing my question ? 谁在改变我的问题? I don't have the source code. 我没有源代码。 I have class files in a jar file. 我在jar文件中有类文件。 Purushotham 47 mins ago Purushotham 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. 但是,如果这是您编写的项目,则可以在IDE中生成JavaDoc。 For Eclipse do Project > Generate JavaDoc. 对于Eclipse,请执行Project> Generate JavaDoc。 In NetBeans, right click your project and select Generate JavaDoc. 在NetBeans中,右键单击您的项目,然后选择Generate 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. 始终链接到您的依赖项的JavaDocs,永远不要将它包含在您的JavaDocs中。 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. 如果不是因为看不到来自Large Overly Framework X的大量课程而失去理智,那只是为了让它们分开。 If I want to read the JavaDoc on your project, I want to read it only on your project, not on slf4j. 如果我想在你的项目中阅读JavaDoc,我想只在你的项目上阅读它,而不是在slf4j上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何为没有源的类生成JavaDoc文档? - How to generate JavaDoc documentation for classes without source? 如何从包含source的许多插件jar文件生成javadoc - How to generate javadoc from many plugin jar files containing source 查找没有Javadoc的Java类,函数和成员 - Finding Java classes, functions and members that don't have Javadoc 如果我不使用类,如何从 kotlin 代码中获取 jar? - How can I get a jar from kotlin code if I don't use classes? 如何通过进入 jar 文件代码来调试代码,我在 Visual Studio Code 中有源代码? - How to debug code by stepping into jar file code for which I have the source code in Visual Studio Code? 如何阻止javadoc生成超类的文档? - How do I stop javadoc from generating documentation for super classes? 即使我不使用其中包含的任何类,如何添加jar来构建路径也会影响代码 - How can adding jar to build path affect code even if I don't use any of classes included at it 我可以编译依赖.class文件的java代码吗?我没有源.java文件? - Can I compile java code that relies on a .class file and I don't have the source .java file? 如何为SAHI脚本生成Javadoc样式文档? - How do I generate Javadoc Style Documentation for SAHI scripts? Maven源插件-如何仅为要包含的类生成源jar - Maven Source Plugin - How do I generate the source jar for ONLY the classes I want included
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM