如何从命令行生成 Javadoc

发布于 2024-10-10 09:29:40 字数 124 浏览 4 评论 0原文

谁能告诉我如何从命令行生成 Javadoc?

我的项目包含 com.test 包,我想将生成的文档放入特定文件夹中的文件中,如下所示:C:/javadoc/test

Can anybody show me how to generate Javadoc from command line?

My project contains the package com.test and I want to put the generated documentation in files located in a specific folder like this: C:/javadoc/test.

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

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

发布评论

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

评论(8

來不及說愛妳 2024-10-17 09:29:40

您可以参考 javadoc 8 文档

我认为 你所看到的是这样的:

javadoc -d C:\javadoc\test com.test

You can refer the javadoc 8 documentation

I think what you are looking at is something like this:

javadoc -d C:\javadoc\test com.test
栩栩如生 2024-10-17 09:29:40

Oracle 提供了一些简单的示例:

http://docs .oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html#CHDJBGFC

假设您位于 ~/ 并且 java 源代码树位于 ./saxon_source/net 中并且您想要递归通过整个源树网络既是一个目录又是顶级包名称。

mkdir saxon_docs
javadoc -d saxon_docs -sourcepath saxon_source -subpackages net

Oracle provides some simple examples:

http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html#CHDJBGFC

Assuming you are in ~/ and the java source tree is in ./saxon_source/net and you want to recurse through the whole source tree net is both a directory and the top package name.

mkdir saxon_docs
javadoc -d saxon_docs -sourcepath saxon_source -subpackages net
泪痕残 2024-10-17 09:29:40

假设您有以下目录结构,您希望在 file1.javafile2.java (包 com.test)上生成 javadoc,并将 javadocs 放置在 < code>C:\javadoc\test:

C:\
|
+--javadoc\
|  |
|  +--test\
|
+--projects\
   |
   +--com\
      |
      +--test\
         |
         +--file1.java
         +--file2.java

在命令终端中,导航到包的根目录:C:\projects。如果您只想在项目内的所有 java 文件上生成标准 javadoc,请运行以下命令(对于多个包,用空格分隔包名称):

C:\projects> javadoc -d [path to javadoc destination directory] [package name]

C:\projects> javadoc -d C:\javadoc\test com.test

如果您想从其他地方运行 javadocs,则需要指定源路径。例如,如果您要在 C:\ 中运行 javadocs,则可以按如下方式修改命令:

C:\> javadoc -d [path to javadoc destination directory] -sourcepath [path to package directory] [package name]

C:\> javadoc -d C:\javadoc\test -sourcepath C:\projects com.test

如果您想仅在选定的 .java 文件上运行 javadocs,则添加用 分隔的源文件名空格(您可以使用星号 (*) 作为通配符)。确保包含文件的路径:

C:\> javadoc -d [path to javadoc destination directory] [source filenames]

C:\> javadoc -d C:\javadoc\test C:\projects\com\test\file1.java

可以找到更多信息/方案 此处

Let's say you have the following directory structure where you want to generate javadocs on file1.java and file2.java (package com.test), with the javadocs being placed in C:\javadoc\test:

C:\
|
+--javadoc\
|  |
|  +--test\
|
+--projects\
   |
   +--com\
      |
      +--test\
         |
         +--file1.java
         +--file2.java

In the command terminal, navigate to the root of your package: C:\projects. If you just want to generate the standard javadocs on all the java files inside the project, run the following command (for multiple packages, separate the package names by spaces):

C:\projects> javadoc -d [path to javadoc destination directory] [package name]

C:\projects> javadoc -d C:\javadoc\test com.test

If you want to run javadocs from elsewhere, you'll need to specify the sourcepath. For example, if you were to run javadocs in in C:\, you would modify the command as such:

C:\> javadoc -d [path to javadoc destination directory] -sourcepath [path to package directory] [package name]

C:\> javadoc -d C:\javadoc\test -sourcepath C:\projects com.test

If you want to run javadocs on only selected .java files, then add the source filenames separated by spaces (you can use an asterisk (*) for a wildcard). Make sure to include the path to the files:

C:\> javadoc -d [path to javadoc destination directory] [source filenames]

C:\> javadoc -d C:\javadoc\test C:\projects\com\test\file1.java

More information/scenarios can be found here.

Hello爱情风 2024-10-17 09:29:40

例如,如果我有一个如下所示的应用程序源代码结构:

  • C:\b2b\com\steve\util\
  • C:\b2b\com\steve\app\
  • C:\b2b\com\steve\gui\

然后我会做:

javadoc -d "C:\docs" -sourcepath "C:\b2b" -subpackages com

这应该为 com 包的源代码和所有子包(递归地)创建 javadoc,在“C:\b2b”目录中找到。

For example if I had an application source code structure that looked like this:

  • C:\b2b\com\steve\util\
  • C:\b2b\com\steve\app\
  • C:\b2b\com\steve\gui\

Then I would do:

javadoc -d "C:\docs" -sourcepath "C:\b2b" -subpackages com

And that should create javadocs for source code of the com package, and all subpackages (recursively), found inside the "C:\b2b" directory.

黄昏下泛黄的笔记 2024-10-17 09:29:40

很简单,转到保存所有 java 代码的文件夹,例如 E:/javaFolder,然后 javadoc *.java

示例

E:\javaFolder> javadoc *.java

its simple go to the folder where your all java code is saved say E:/javaFolder and then javadoc *.java

example

E:\javaFolder> javadoc *.java

蔚蓝源自深海 2024-10-17 09:29:40

如果必须处理多个sourcepath和子包,给出的答案并不完全完整。

以下命令行将处理位于 /home/rudy/IdeaProjects/demo/src/main/java com LOR(指环王)下的所有包/home/rudy/IdeaProjects/demo/src/test/java/

请注意:

  • 这是 Linux,路径和包由 ':' 分隔
  • ,我使用了 private 并希望记录所有类和成员

rudy@rudy-ThinkPad-T590:~$ javadoc -d /home/rudy/IdeaProjects/demo_doc
-sourcepath /home/rudy/IdeaProjects/demo/src/main/java/
:/home/rudy/IdeaProjects/demo/src/test/java/
-subpackages com:LOR 
-private

rudy@rudy-ThinkPad-T590:~/IdeaProjects/demo/src/main/java$ ls -R 
.: com LOR
./com: example
./com/example: demo
./com/example/demo: DemowApplication.java
./LOR: Race.java TolkienCharacter.java

rudy@rudy-ThinkPad-T590:~/IdeaProjects/demo/src/test/java$ ls -R 
.: com
./com: example
./com/example: demo
./com/example/demo: AssertJTest.java DemowApplicationTests.java

The answers given were not totally complete if multiple sourcepath and subpackages have to be processed.

The following command line will process all the packages under com and LOR (lord of the rings) located into /home/rudy/IdeaProjects/demo/src/main/java and /home/rudy/IdeaProjects/demo/src/test/java/

Please note:

  • it is Linux and the paths and packages are separated by ':'
  • that I made usage of private and wanted all the classes and members to be documented

rudy@rudy-ThinkPad-T590:~$ javadoc -d /home/rudy/IdeaProjects/demo_doc
-sourcepath /home/rudy/IdeaProjects/demo/src/main/java/
:/home/rudy/IdeaProjects/demo/src/test/java/
-subpackages com:LOR 
-private

rudy@rudy-ThinkPad-T590:~/IdeaProjects/demo/src/main/java$ ls -R 
.: com LOR
./com: example
./com/example: demo
./com/example/demo: DemowApplication.java
./LOR: Race.java TolkienCharacter.java

rudy@rudy-ThinkPad-T590:~/IdeaProjects/demo/src/test/java$ ls -R 
.: com
./com: example
./com/example: demo
./com/example/demo: AssertJTest.java DemowApplicationTests.java
帅哥哥的热头脑 2024-10-17 09:29:40
D:\>javadoc *.java

如果你想创建 lang 包的停靠文件,那么路径应该与你的 lang 包当前所在的路径相同。例如,我创建了一个名为 javaapi 的文件夹并解压缩 src zip 文件,然后使用以下命令。

C:\Users\Techsupport1\Desktop\javaapi\java\lang> javadoc *.java
D:\>javadoc *.java

If you want to create dock file of lang package then path should be same where your lang package is currently. For example, I created a folder name javaapi and unzipped the src zip file, then used the command below.

C:\Users\Techsupport1\Desktop\javaapi\java\lang> javadoc *.java
神回复 2024-10-17 09:29:40

JavaDoc 链接

我相信这肯定会有所帮助你。

javadoc -d C:/javadoc/test com.mypackage

Link to JavaDoc

I believe this will surely help you.

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