Documentation generation
This page details Documentation generation.
Dependency
<dependency>
<groupId>io.yupiik.fusion</groupId>
<artifactId>fusion-documentation</artifactId>
<version>${fusion.version}</version>
</dependency>
Integration with yupiik-tools-maven-plugin
|
IMPORTANT
|
the main way to use these generators in practice is as pre-actions of the |
Here is the wiring used by this very project (fusion-documentation/pom.xml): each generator is declared as a <preAction>, and the generated partials land in src/main/minisite/content/_partials/generated/ so they can be include::d from the hand-written pages:
<plugin>
<groupId>io.yupiik.maven</groupId>
<artifactId>yupiik-tools-maven-plugin</artifactId>
<version>${yupiik-tools.version}</version>
<executions>
<execution>
<id>minisite</id>
<goals><goal>minisite</goal></goals>
<configuration>
<source>src/main/minisite</source>
<preActions>
<preAction>
<type>io.yupiik.fusion.documentation.ConfigurationDocumentationGenerator</type>
<parameters>
<includeEnvironmentNames>true</includeEnvironmentNames>
</parameters>
</preAction>
<preAction>
<type>io.yupiik.fusion.documentation.CliDocumentationGenerator</type>
</preAction>
</preActions>
<attributes>
<partialsdir>${project.basedir}/src/main/minisite/content/_partials</partialsdir>
</attributes>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>io.yupiik.fusion</groupId>
<artifactId>fusion-documentation</artifactId>
<version>${fusion.version}</version>
</dependency>
</dependencies>
</plugin>
Each generator consumes the metadata the Fusion annotation processor produced at compile time (META-INF/fusion/configuration/documentation.json for configuration, the CLI command metadata for CliDocumentationGenerator) and writes an .adoc partial which you then reference with an include directive from your content page (for example /home/fpa/planets/tatooine/yupiik/fusion/fusion-documentation/src/main/minisite/content/_partials/generated/documentation.my-app.adoc). Since the pre-action runs before the site renders, the partial exists by the time the page is resolved.
|
TIP
|
preview the site locally with |
JSON-RPC/OpenRPC to Asciidoc
The class io.yupiik.fusion.documentation.OpenRPC2Adoc enables to convert the partial OpenRPC metadata (META-INF/fusion/jsonrpc/openrpc.json) to Asciidoc format for an easier integration in documentation.
Configuration:
| Name | Description |
|---|---|
|
input |
the location of the input file (json), often it will be |
|
output |
the location of the output file (asciidoc). |
JSON-RPC/OpenRPC to OpenAPI
OpenAPI is the OpenRPC for plain old RESTful API. However it has some great tooling - SwaggerUI to not cite it.
The class io.yupiik.fusion.documentation.OpenRPC2OpenAPI enables to convert the partial OpenRPC metadata (META-INF/fusion/jsonrpc/openrpc.json) to OpenAPI format for an easier integration in documentation and in particular SwaggerUI.
Configuration:
| Name | Description |
|---|---|
|
input |
the location of the input file (json), often it will be |
|
output |
the location of the output file (json). |
|
*.url |
define a server URL, |
|
*.description |
define a server description, |
|
info.* |
define |
To integrate it with SwaggerUI you have to register the SwaggerUI requestInterceptor which will convert the request url to the server url (which must be JSON-RPC endpoint) since the converter moves methods as path to comply to OpenAPI model:
SwaggerUIBundle({
...,
requestInterceptor: function (request) {
if (request.loadSpec) {
return request;
}
var method = request.url.substring(request.url.lastIndexOf('/') + 1);
return Object.assign(request, {
url: spec.servers.filter(function (server) { return request.url.indexOf(server.url) === 0; })[0].url,
body: JSON.stringify({ jsonrpc: '2.0', method: method, params: JSON.parse(request.body) }, undefined, 2)
});
},
});
JSON-RPC/OpenRPC to Postman
The class io.yupiik.fusion.documentation.OpenRPC2Postman enables to convert the partial OpenRPC metadata (META-INF/fusion/jsonrpc/openrpc.json) to a Postman collection.
Configuration:
| Name | Description |
|---|---|
|
input |
the location of the input file (json), often it will be |
|
output |
the location of the output file (json). |
|
info.* |
define |
|
server.url |
define a server URL to use. |
Format documentation in Asciidoc
io.yupiik.fusion.documentation.ConfigurationDocumentationGenerator enables to format the documentation in asciidoc.
If you use Yupiik tools minisite, configuration will often look like:
<preActions>
<preAction>
<type>io.yupiik.fusion.documentation.ConfigurationDocumentationGenerator</type>
</preAction>
</preActions>
Configuration:
| Name | Description |
|---|---|
|
includeEnvironmentNames |
Should environment names of the keys be shown or ignored. Default |
|
module |
Title name for |
|
output |
When to generate the asciidoc file, by default - when not set - it uses |
|
formatter |
Can be |
|
urls |
If not set |
|
roots |
If you don't want to generate the configuration for all classes, the root classes to include from the JSON file (urls). |
CLI documentation
io.yupiik.fusion.documentation.CliDocumentationGenerator enables to generate documentation in asciidoc for CLI modules.
If you use Yupiik tools minisite, configuration will often look like:
<preActions>
<preAction>
<type>io.yupiik.fusion.documentation.CliDocumentationGenerator</type>
</preAction>
</preActions>
Configuration:
| Name | Description |
|---|---|
|
indexHeader |
Header - top content - of the index page. |
|
indexName |
Name if the index page listing commands, defaults to |
|
indexRelativePath |
Prefix to links to the command documentation, this is useful when the index page is generated in partials directory for example and you include it in another page. |
|
package |
If set enables to filter the commands included by package. |
|
outputBase |
Base directory where to generate the commands and command index documents. |
|
NOTE
|
the generator starts a fusion container disabling |