简体   繁体   English

如何自定义 JavaDoc 中的“概览”页面?

[英]How to customize “Overview” page in JavaDoc?

I'd like the " Overview " page of my library's javadoc to essentially be a user/API guide for the entire JAR.我希望我的库的 javadoc 的“概述”页面本质上是整个 JAR 的用户/API 指南。 I know that adding a package-info.java class to a package allows you to write package-level javadocs, but what about at the jar-level ?我知道将package-info.java类添加到包中可以让您编写包级别的javadoc,但是在jar 级别呢?

I know I could put a README.md in my project's root, but I like to think of README's as a doc for library developers (that is, people who will be maintaining the library).我知道我可以将README.md放在我的项目的根目录中,但我喜欢将 README 视为库开发人员(即将维护库的人员)的文档。 But the JavaDocs are API guides for people who will be using the library.但是 JavaDocs 是为将要使用该库的人提供的 API 指南。

You can create an overview HTML file and place it anywhere you like in your source tree.您可以创建概览 HTML 文件并将其放置在源代码树中您喜欢的任何位置。 The convention is to call it overview.html and place it at the root of your tree, but you are certainly not obligated to do so.约定是将其命名为overview.html 并将其放在树的根部,但您当然没有义务这样做。 In fact, you can create multiple overview files for different purposes.事实上,您可以为不同的目的创建多个概览文件。 When you generate your javadocs, you use the -overview flag and pass it the path to the target overview file.生成 javadoc 时,使用 -overview 标志并将其传递到目标概览文件的路径。

You can find more information about overview file requirements here .您可以在此处找到有关概览文件要求的更多信息。

When you are using Maven and its plugin for JavaDoc :当您使用 Maven 及其JavaDoc 插件时

Put a file named overview.html into folder src/main/javadoc and run the command mvn javadoc:javadoc ;将一个名为overview.html的文件放入文件夹src/main/javadoc并运行命令mvn javadoc:javadoc the JavaDoc files are written into folder target/site/apidocs . JavaDoc 文件被写入文件夹target/site/apidocs

This is also possible when you want to generate JavaDoc files for the Unit Tests: Put a file named overview.html into folder src/test/javadoc and run the command mvn javadoc:test-javadoc ;当您想为单元测试生成 JavaDoc 文件时,这也是可能的:将一个名为overview.html的文件放入文件夹src/test/javadoc并运行命令mvn javadoc:test-javadoc the JavaDoc files are written into folder target/site/testapidocs . JavaDoc 文件被写入文件夹target/site/testapidocs

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM