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

DocGenerator API configuration



This article presents how to configure the wiki generation through docJGenerator API.

Overview

You can configure the generation by calling DocGeneratorAPI.getConfiguration() and setting configuration properties.

Several configuration properties can be set directly through the DocGeneratorAPI.

Resetting the configuration

The DocGeneratorAPI.resetConfiguration() method force the resst of the configuration.

Setting the search configuration

By default the search is on articles and titles. It is possible to configure directly the search options through the following methods: The following example allows to seach on articles, titles, and anchors:
   DocGeneratorAPI api = new DocGeneratorAPI();
      
   api.setSearch(SearchOptions.SEARCH_ON_ANCHORS);    
To set a custom search configuration, you must set the SearchOptions.SEARCH_CUSTOM option, and specify which search categories you want to use.

For example, the following code will create two search categories which will appear in the search box: "Bird", and "Mammal":
   DocGeneratorAPI api = new DocGeneratorAPI();
      
   // set a custom search
   api.setSearch(SearchOptions.SEARCH_CUSTOM); 
      
   // specify the custom search categories
   CustomSearchCategories categories = api.getCustomSearchCategories();
   categories.addCategory("Bird");
   categories.addCategory("Mammal");      

Setting the locale

By default the wiki interface in in English. It is possible to configure the locale through the DocGeneratorAPI.setLocale(String) method. The supported locales are specified in the Locales interface.

For example, to use a "fr" Locale:
   DocGeneratorAPI api = new DocGeneratorAPI();
   api.setLocale("fr"); 

Setting the output format


The Wiki output format can be set through the DocGeneratorAPI.setOutputType(String) method:
  • The "help" and "html" formats are always supported
  • The "docx", "pdf", and "epub" formats are supported only if the associated plugins are present
For example, to specify that you want to generate a doxcx file:
  DocGeneratorAPI api = new DocGeneratorAPI();
  api.setOutputType("docx"); 
The DocGeneratorAPI.setHeader(String) and DocGeneratorAPI.setFooter(String) methods allow to add a header and a footer to the wiki.

The following example add the "My API wiki" text as the header for the wiki:
  DocGeneratorAPI api = new DocGeneratorAPI();
  api.setHeader("My API wiki");   

Other configuration properties

You can access the configuration through the DocGeneratorAPI.getConfiguration() lmethod. It gives you access to the Configuration which can be used to set all the configuration properties.

Setting the table of content configuration

You can set the table of content configuration through the following methods in the Configuration: The following example set that the articles will not have a table of content:
   DocGeneratorAPI api = new DocGeneratorAPI();
      
   Configuration conf = api.getConfiguration();
   conf.setArticlesTOC(false);    
Note that you can set that a specific article must not have a table of content by using the XMLArticle.setTOC(boolean).

The following example set that a specific article will not have a table of content:
   DocGeneratorAPI api = new DocGeneratorAPI();
   api.createModel();
         
   XMLArticle article = api.createArticle("the first article");    
   article.setTOC(false);

Getting rid of the dictionary or the categories

The following example set that there will be no dictionary and no categories in the wiki:
   DocGeneratorAPI api = new DocGeneratorAPI();
      
   Configuration conf = api.getConfiguration();
   conf.setHasDictionary(false); 
   conf.setHasCategories(false);       

See also


Categories: api

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