Package org.opencastproject.util.doc
Class DocUtil
java.lang.Object
org.opencastproject.util.doc.DocUtil
This provides methods for handling documentation generation The is mainly for generating REST documentation but it
could be used for other things as well
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringUse this method to generate the documentation using passed in document data, allows the user to specify the template that is usedstatic StringloadTemplate(String path) Loads a template based on the given pathstatic StringHandles the replacement of the variable strings within textual templates and also allows the setting of variables for the control of logical branching within the text template as well
Uses and expects freemarker (http://freemarker.org/) style templates (that is using ${name} as the marker for a replacement)
NOTE: These should be compatible with Velocity (http://velocity.apache.org/) templates if you use the formal notation (formal: ${variable}, shorthand: $variable)static voidreset()
-
Method Details
-
reset
public static void reset() -
processTextTemplate
public static String processTextTemplate(String templateName, String textTemplate, Map<String, Object> data) Handles the replacement of the variable strings within textual templates and also allows the setting of variables for the control of logical branching within the text template as well
Uses and expects freemarker (http://freemarker.org/) style templates (that is using ${name} as the marker for a replacement)
NOTE: These should be compatible with Velocity (http://velocity.apache.org/) templates if you use the formal notation (formal: ${variable}, shorthand: $variable)- Parameters:
templateName- this is the key to cache the template undertextTemplate- a freemarker/velocity style text template, cannot be null or empty stringdata- a set of replacement values which are in the map like so:
key => value (String => Object)
"username" => "aaronz"- Returns:
- the processed template
-
generate
Use this method to generate the documentation using passed in document data, allows the user to specify the template that is used- Parameters:
data- any populated DocData objecttemplate- any freemarker template which works with the DocData data structure- Returns:
- the documentation (e.g. REST html) as a string
- Throws:
IllegalArgumentException- if the input data is invalid in some way- See Also:
-
loadTemplate
Loads a template based on the given path- Parameters:
path- the path to load the template from (uses the current classloader)- Returns:
- the template as a string
-