SuperJavaDoc fast document building framework

SuperJavaDoc Quick document building framework Generates interfaces based on Java annotations Document annotation support Extension Interface Framework support extension By default documents in markdown and offline/online HTML formats are supported by spring MVC specification by default spri……

Welcome to visit my blind few whole site: Copy the future

  • Generate interface documentation based on Java annotations
  • Comment support extension
  • The interface framework supports extensions
  • Markdown and offline/online HTML documents are supported by default
  • The Spring MVC specification is supported by default
  • By default, spring-boot directly embedded boot is supported

Online direct use based on SpringBoot

1. Introduce Maven dependencies

< the dependency > < groupId > com. Uifuture < / groupId > < artifactId > super - Java - doc - starter < / artifactId > < version > 1.0.0 < / version > </dependency>Copy the code

2. Add EnableDoc annotations

Add the EnableDoc annotation to the Application class

@EnableDoc @SpringBootApplication public class TestApplication { public static void main(String[] args) { SpringApplication.run(TestApplication.class, args); }}Copy the code

3.1 Properties Configuration file

# enable XDoc =true # enable XDoc =true # enable XDoc =true # source path, separated by English comma, super-java-doc-test is the project module name. Single-module projects can remove super-java-doc-test/, SRC /main/ Java doc.sourcePath=super-java-doc-test/ SRC /main/ Java Doc. Version = 1.0Copy the code

3.2 YML Configuration File

Doc: enable: true title: online interface document sourcePath: super-java-doc-test/ SRC /main/ Java version: 1.0Copy the code

4 use

The above configuration is written

Write a few random controllers as Demo interfaces to facilitate direct browsing of the generated results:

@Controller @RequestMapping("admin/blogs") public class BlogsController { @Resource private BlogsService blogsService; @PostMapping("add") @ResponseBody public ResultModel add(Blogs blogs) { blogsService.insert(blogs); return ResultModel.success(); } @PostMapping("delete") @ResponseBody public ResultModel delete(@RequestParam Integer id) { blogsService.deleteById(id); return ResultModel.success(); } @PostMapping("update") @ResponseBody public ResultModel update(Blogs blogs) { blogsService.updateById(blogs); return ResultModel.success(); } @PostMapping("detail") @ResponseBody public ResultModel detail(@RequestParam Integer id) { Blogs blogs = blogsService.selectById(id); return ResultModel.success(blogs); } @PostMapping("list") @ResponseBody public ResultModel list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) { PageHelper.startPage(page, size); List<Blogs> list = blogsService.selectAll(); PageInfo pageInfo = new PageInfo(list); return ResultModel.success(pageInfo); }}Copy the code

To start the project directly, type in the address:http://localhost:8080/superJavaDoc/index.html

The following two figures are part of the display contents.

2. Generate an offline document

Supports HTML:

@Test
public void buildMarkdown() {
    
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    String rootDir = System.getProperty("user.dir");
    SuperJavaDoc xDoc = new SuperJavaDoc(rootDir + "/src/main/java/com/uifuture", new SpringWebFramework());
    xDoc.build(out, new MarkdownFormat());

    System.out.println(out.toString());
}
Copy the code

Support the markdown:

@Test
public void buildHtml() throws Exception {
    
    String userDir = System.getProperty("user.dir");
    FileOutputStream out = new FileOutputStream(new File(userDir, "api.html"));
    SuperJavaDoc xDoc = new SuperJavaDoc(userDir + "/src/main/java/com/uifuture", new SpringWebFramework());
    xDoc.build(out, new HtmlForamt());
}
Copy the code

Note: This document is not recommended in production environment, which may consume performance. Therefore, in production environment, configure the following information in the configuration file:

doc.enable=false
Copy the code

Project address: github.com/chenhaoxian…