Git Product home page Git Product logo

apiggs's Introduction

🐷 Apiggs - 非侵入的RestDoc文档生成工具

Download

前言

程序员一直以来都有一个烦恼,只想写代码,不想写文档。代码就表达了我的**和灵魂。

Python提出了一个方案,叫docstring,来试图解决这个问题。即编写代码,同时也能写出文档,保持代码和文档的一致。docstring说白了就是一堆代码中的注释。Python的docstring可以通过help函数直接输出一份有格式的文档,本工具的**与此类似。

代码即文档

Apiggs是一个非侵入的RestDoc文档生成工具。工具通过分析代码和注释,获取文档信息,生成RestDoc文档。

引入插件

gradle

buildscript {
    dependencies {
        classpath 'com.github.apiggs:apiggs-gradle-plugin:替换为上方版本号'
    }
}

apply plugin: 'com.github.apiggs'

maven

<plugin>
    <groupId>com.github.apiggs</groupId>
    <artifactId>apiggs-maven-plugin</artifactId>
    <version><!-- 替换为上方版本号 --></version>
    <executions>
        <execution>
            <phase>compile</phase>
            <goals>
                <goal>apiggs</goal>
            </goals>
        </execution>
    </executions>
</plugin>

有这样一段代码

/**
 * 欢迎使用Apiggs
 * @index 1
 */
@RestController
public class GreetingController {

    private static final String template = "Hello, %s!";
    private final AtomicLong counter = new AtomicLong();

    /**
     * 示例接口
     * @param name 名称
     * @return
     */
    @RequestMapping("/greeting")
    public Greeting greeting(@RequestParam(value="name", defaultValue="apiggs") String name) {
        return new Greeting(counter.incrementAndGet(),
                String.format(template, name));
    }
}

运行插件

  • gradle 运行
Tasks/documentation/apiggs
  • maven 运行
compile

生成文档

在编译目录下生成apiggs文件夹,并生成三个文件:

  1. .json文件,可直接导入postman
  2. .adoc文件,Asciidoc源文件
  3. .html文件,源文件渲染结果,效果如下图

example

想了解更多,请查看Wiki

apiggs's People

Contributors

ayz6uem avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.