smart-doc-gradle-plugin is a gradle
plugin developed by the smart-doc official team.
This plugin is available from smart-doc 1.8.6.
Using smart-doc-gradle-plugin makes it easier to integrate smart-doc into your project, and integration is more lightweight.
You no longer need to write unit tests in your project to
Start smart-doc to scan source code analysis and generate API documents.
You can run the gradle
command directly or click on the preset goal
of the smart-doc-maven-plugin in the IDE to generate API documentation.
smart-doc-gradle-plugin will also make smart-doc's ability to generate API documentation more powerful.
About smart-doc
smart-doc + Torna form an industry-leading document generation and management solution, using smart-doc to complete Java source code analysis and extract annotations to generate API documents without intrusion, and automatically push the documents to the Torna enterprise-level interface document management platform.
Using the plugins DSL:
plugins {
id "com.github.shalousun.smart-doc" version "[latest]"
}
Using legacy plugin application:
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.github.shalousun:smart-doc-gradle-plugin:[latest]"
}
}
apply plugin: "com.github.shalousun.smart-doc"
Option | Default value | Description |
---|---|---|
configFile | src/main/resources/default.json | |
exclude | exclude artifact,usage:exclude 'org.springframework.boot:spring-boot-starter-tomcat' | |
include | Let the plugin download the specified java lib source,usage:include 'org.springframework.boot:spring-boot-starter-tomcat' |
Example setting of options:
smartdoc {
configFile = file("src/main/resources/default.json")
// exclude example
// exclude artifact
exclude 'org.springframework.boot:spring-boot-starter-tomcat'
// exclude artifact use pattern
exclude 'org.springframework.boot.*'
// You can use the include configuration to let the plugin automatically load the specified source.
// include example
include 'org.springframework.boot:spring-boot-starter-tomcat'
}
For multi-module gradle projects, if you do not want to configure in each module, you can put the smart-doc plugin related configuration into subprojects.
subprojects{
apply plugin: 'com.github.shalousun.smart-doc'
smartdoc {
//
configFile = file("src/main/resources/smart-doc.json")
// exclude artifact
exclude 'org.springframework.boot:xx'
exclude 'org.springframework.boot:ddd'
// You can use the include configuration to let the plugin automatically load the specified source.
// include example
include 'org.springframework.boot:spring-boot-starter-tomcat'
}
}
Create a json configuration file in your project. If it is multiple modules, put them in the modules that need to generate documents.
The smart-doc-gradle-plugin plugin will use this configuration information.
For example, create /src/main/resources/smart-doc.json
in the project.
The configuration contents are as follows.
Minimize configuration:
{
"allInOne": true, // whether to merge documents into one file, generally recommended as true
"isStrict": false,//If the strict mode is set to true, Smart-doc forces that the public method in each interface in the code has a comment.
"outPath": "/src/main/resources" //Set the api document output path.
}
Only three configuration items are required to use the smart-doc-gradle-plugin to generate API documentation. In fact, only outPath must be configured.
Detailed configuration content:
smart-doc provides a lot of configuration options. For more configuration options, please refer to the official documentation
// Generate html
gradle smartDocRestHtml
// Generate markdown
gradle smartDocRestMarkdown
// Generate adoc
gradle smartDocRestAdoc
// Generate postman collection
gradle smartDocPostman
// Generate Open Api 3.0+
gradle smartDocOpenApi
// Generate document and send to Torna
gradle tornaRest
// For Apache Dubbo Rpc
gradle smartDocRpcHtml
// Generate markdown
gradle smartDocRpcMarkdown
// Generate adoc
gradle smartDocRpcAdoc
On Use IntelliJ IDE, if you have added smart-doc-gradle-plugin to the project, you can directly find the plugin smart-doc plugin and click to generate API documentation.
you can build with the following commands. (Java 1.8 is required to build the master branch)
// build and publish to local
gradle publishToMavenLocal
// build and publish to nexus
gradle publish
These are only part of the companies using smart-doc, for reference only. If you are using smart-doc, please add your company here to tell us your scenario to make smart-doc better.
smart-doc-gradle-plugin is under the Apache 2.0 license. See the LICENSE file for details.
Email: [email protected]