Other projects
tip
In the previous chapter, we demonstrated how to start with one click in a Springboot project. This chapter will introduce how to use doc-apis to generate API documentation in other projects such as Jfinal.
In all non-Springboot projects, the ease of use may slightly decrease, but the learning curve remains very low, requiring only the essential CV+ modification skills of a skilled coder. Below, I will demonstrate using a spring project as an example:
Firstly, the coordinates introduced in non-SpringBoot projects differ slightly. There's no need to introduce the starter module; merely including the core module suffices:
Maven
<!-- Introduce the latest version dependency of doc-apis -->
<dependency>
<groupId>com.doc-apis</groupId>
<artifactId>doc-apis-core</artifactId>
<!-- "Latest Version" here refers to the most recent version of the dependency, for instance, 2.0.0, which can be obtained via the image below -->
<version>Latest Version</version>
<!-- The following segment is optional. If you don't wish for doc-apis to be bundled into your project, it's also feasible to start the project with the test module to automatically generate the API documentation -->
<!--<scope>test</scope>-->
</dependency>
2
3
4
5
6
7
8
9
10
Gradle
compile group: 'com.doc-apis', name: 'doc-apis-core', version: 'Latest Version'
# Latest Version: (opens new window)
public static void main(String[] args) {
DocsConfig docsConfig = new DocsConfig();
// Specify the path of the project to be generated
docsConfig.setProjectPath("E:\\doc-apis-test\\springDemo");
// Document version number (optional)
docsConfig.setApiVersion("V1.0");
// Whether to auto-generate
docsConfig.setAutoGenerate(Boolean.TRUE);
// Path to store the generated document
docsConfig.setDocsPath("E:\\tmp");
// Generate additional markdown documents
docsConfig.addPlugin(new MarkdownDocPlugin());
// Execute the generation
Docs.buildHtmlDocs(docsConfig);
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Feel free to copy this code snippet into your project, then simply modify the path of the project to be generated and the document storage path, and run the main method.If you need to modify other personalized configurations, refer to the config chapter, where related configurations can be set directly through the set methods provided by DocsConfig.The usage in other niche types of projects like Jfinal, player, etc., is similar to spring projects and will not be repeated here.