Home
Categories
Dictionary
Download
Project Details
Changes Log
What Links Here
How To
Syntax
FAQ
License

DocJGenerator API overview



The docJGenerator API allows to use the generator in another Java application.

Overview

You can use the library through an API to produce a wiki in your Java application. It allows to to create the content of the wiki programmatically, and generate the result through code in your application.

The entry point of the API is the DocGeneratorAPI class.

You can even merge several generations using the docGenerator API. This can be useful if for example you want several applications to contribute to the same wiki, rather than relying on only one generation.

Classpath

To use the API, you must put the docGeneratorAPI.jar Jar file in your classpath. This small Jar depends on the main docGenerator.jar jar file. You can either:
  • Put the docGenerator.jar jar file alongside the docGeneratorAPI.jar in the same directory
  • Or add the docGenerator.jar jar file in your Classpath

Generation steps

The steps for the generation include:
  • Creating the generator context
  • Programmatically creating the wiki content
  • Setting the generation output directory
  • Calling the generator

Creating the generator context


To create the generator context:
By default creating a DocGeneratorAPI does not reset the configuration. You can force to reset the configuration either by using the DocGeneratorAPI.resetConfiguration() method, or by calling the constructor with a boolean argument.

Setting the menus


You an access the wiki menus with the DocGeneratorAPI.getMenus() method.

Creating the wiki content


You can create the content of the wiki either by using directly the ArticlesModel which is the result of the createModel() method, or by using direct methods in the API.

Setting the generation output directory

You must call the DocGeneratorAPI.setOutputDirectory(URL) or the DocGeneratorAPI.setOutputDirectory(File) method. Note that of course the directory must be set before the generation.

Calling the generator

The generation is performed through the DocGeneratorAPI.writeContent(boolean) or DocGeneratorAPI.writeContent().

Note that for the generation to perform, you must have:
  • Create a model prior to the generation
  • Set the generation output directory

Checking the generation result

Several methods allow to check if the generation performed correctly: The errors can be:

Example

The following example creates the context, and one article, and generates the wiki:
   DocGeneratorAPI api = new DocGeneratorAPI();
   api.createModel();
   api.setOutputDirectory(<the wiki directory>);

   // add a sentence in the index
   api.addSentence(api.getIndex(), "this is the index");

   // create an article
   XMLArticle article = api.createArticle("article1");

   // add a sentence in the article
   api.addSentence(article, "this is the article");

   // generate the wiki (the output directory existing content will be cleaned prior to the generation)
   api.writeContent(true);

See also


Categories: api

docJGenerator Copyright (c) 2016-2023 Herve Girod. All rights reserved.