public final class Compiler extends Object
This class is not thread-safe.
That is, create and use one instance per thread.
However an instance may be reused by invoking
compile(URL[], URL, URL, File)
several times.
Modifier and Type | Field and Description |
---|---|
static String |
BROWSER_LANGUAGE |
static String |
DOCUMENT_LANGUAGE |
static String |
VERSION
The version number of this Compiler.
|
Constructor and Description |
---|
Compiler(Console console)
Constructs a compiler.
|
Modifier and Type | Method and Description |
---|---|
boolean |
compile(File[] xhtmlFiles,
File tocFile,
File indexFile,
File outDir)
Convenience method equivalent to
compile(URL[], URL, URL, File) , except that the arguments
are File s and not URL s. |
boolean |
compile(URL[] xhtmlURLs,
URL tocURL,
URL indexURL,
File outDir)
Compiles a Web Help application by ``decorating'' specified XHTML pages.
|
boolean |
getCollapseTOC()
Returns
true if the TOC is to be initially
collapsed; otherwise returns false . |
Console |
getConsole()
Returns the console used to display error, warning and
progress messages.
|
String |
getDefaultLanguage()
Returns the language used when the XHTML page being parsed does not
specify a xml:lang or lang attribute
on its html root element.
|
URL |
getFavicon()
Returns the favicon to be added to an XHTML page decorated
by the compiler.
|
String |
getIdMapHref()
Returns the
href value specified
using setIdMapHref(java.lang.String) . |
String |
getIdMapIdPrefix()
Returns the ID prefix specified using
setIdMapIdPrefix(java.lang.String) . |
String |
getIdMapTitle()
Returns the
title value specified
using setIdMapTitle(java.lang.String) . |
boolean |
getIndexNumbers()
Returns
true if words looking like numbers
are to be indexed; otherwise returns false . |
String |
getJQuery()
Returns the location of the JavaScript file containing jQuery.
|
String |
getLayout()
Returns the selected selected for the generated Web Help.
|
boolean |
getResponsiveUI()
Returns
true if the UI of the generated Web Help
is to be "responsive"; false otherwise. |
static URL |
getTemplateManifestURL()
Returns the location of whc_template/manifest.txt,
May return
null . |
Map<String,String> |
getThemeProperties()
Returns a map containing the CSS theme properties specified using
setThemeProperty(java.lang.String, java.lang.String) . |
String |
getUILanguage()
Returns the language to be used for the messages of
the generated Web Help.
|
URL |
getUserCSS()
Returns the user's CSS stylesheet to be added to an
XHTML page decorated by the compiler.
|
URL |
getUserFooter()
Returns the user's footer to be added to an
XHTML page decorated by the compiler.
|
URL |
getUserHeader()
Returns the user's header to be added to an
XHTML page decorated by the compiler.
|
File |
getUserResources()
Returns the user's resource directory which is recursively copied to
output_directiry/_wh/user/.
|
boolean |
getUseStemming()
Returns
true if stemming is to be used to implement
the search by contents facility; otherwise returns false . |
void |
inheritFontAndColors(boolean inherit)
A shorthand invoking
setThemeProperty(java.lang.String, java.lang.String) to set all the
CSS theme properties specifying the font and colors of
the navigation pane to "inherit ". |
boolean |
isLocalJQuery()
Returns
true if the jQuery files must be copied to
the local resource directory created by this compiler;
false otherwise. |
boolean |
isVerbose()
Returns the verbosity of this compiler.
|
static void |
main(String[] args) |
boolean |
parseParameters(String[] parameters)
Parses specified parameters invoking
setUILanguage(java.lang.String) ,
setJQuery(java.lang.String) , ..., setCollapseTOC(boolean) , as needed to. |
boolean |
parseParameters(String[] parameters,
URL baseURL)
For internal use only.
|
void |
setCollapseTOC(boolean collapse)
Specifies whether the TOC should be initially collapsed.
|
void |
setDefaultLanguage(String lang)
Specifies the language used when the XHTML page being parsed does not
specify a xml:lang or lang attribute
on its html root element.
|
void |
setFavicon(URL url)
Specifies the favicon which is to be added to an XHTML page decorated
by the compiler.
|
void |
setIdMapHref(String href)
Instructs this compiler to save an ID map to
output_dir/_wh/idMap.xml.
|
void |
setIdMapIdPrefix(String prefix)
In addition to the IDs of "formal elements" (sections, figures,
tables, etc) which are automatically added to the ID map,
also add the IDs starting with specified prefix.
|
void |
setIdMapTitle(String title)
Instructs this compiler to save an ID map to
output_dir/_wh/idMap.xml.
|
void |
setIndexNumbers(boolean index)
Specifies whether words looking like numbers are to be indexed.
|
void |
setJQuery(String location)
Specifies the location of the JavaScript file containing jQuery.
|
void |
setLayout(String layout)
Selects a layout for the generated Web Help.
|
void |
setLocalJQuery(boolean local)
Specifies whether the jQuery files must be copied to
the local resource directory created by this compiler.
|
void |
setResponsiveUI(boolean responsive)
Specifies whether the UI of the generated Web Help
is to be "responsive".
|
static void |
setTemplateManifestURL(URL url)
Specifies the location of whc_template/manifest.txt,
the manifest file listing all the files used by the compiler
to ``decorate'' an XHTML page.
|
void |
setThemeProperty(String name,
String value)
Override a CSS theme property with specified values.
|
void |
setUILanguage(String lang)
Specifies the language to be used for the messages of
the generated Web Help.
|
void |
setUserCSS(URL url)
Specifies the user's CSS stylesheet which is to be added to an
XHTML page decorated by the compiler.
|
void |
setUserFooter(URL url)
Specifies the user's footer which is to be added to an
XHTML page decorated by the compiler.
|
void |
setUserHeader(URL url)
Specifies the user's header which is to be added to an
XHTML page decorated by the compiler.
|
void |
setUserResources(File dir)
Specifies a user's resource directory which is to be recursively
copied to output_directory/_wh/user/.
|
void |
setUseStemming(boolean stemming)
Specifies whether stemming should be used to implement
the search by contents facility.
|
void |
setVerbose(boolean verbose)
Specifies the verbosity of this compiler.
|
public static final String VERSION
public static final String DOCUMENT_LANGUAGE
public static final String BROWSER_LANGUAGE
public Compiler(Console console)
console
- the console used to display error, warning
and progress (setVerbose(boolean)
) messages.
May be null
in which case these messages are printed
System.err
and System.out
.public static void setTemplateManifestURL(URL url)
When this location has not been explicitly specified, it is searched in the following location:
url
- location of whc_template/manifest.txt.
May be null
in which case
whc_template/manifest.txt will be searched
in the above locations.getTemplateManifestURL()
public static URL getTemplateManifestURL()
null
.setTemplateManifestURL(java.net.URL)
public Console getConsole()
null
.public void setVerbose(boolean verbose)
By default the compiler is not verbose.
verbose
- if true
, display progress messages
on the console.isVerbose()
public boolean isVerbose()
setVerbose(boolean)
public void setLayout(String layout)
layout
- layout name.
For now, only "classic", "simple" and
"corporate" layouts are supported.
May be null
in which case "classic" is used.getLayout()
public String getLayout()
setLayout(java.lang.String)
public void setLocalJQuery(boolean local)
Default: Not local. jQuery files are downloaded from the Web by the Web Help.
local
- true
the jQuery files must be local to
the Web Help; false
if they are to be downloaded
from the Web by the Web HelpisLocalJQuery()
public boolean isLocalJQuery()
true
if the jQuery files must be copied to
the local resource directory created by this compiler;
false
otherwise.setLocalJQuery(boolean)
public void setJQuery(String location)
By default the compiler references a file found on the Google CDN.
location
- relative or absolute URI of
the JavaScript file containing jQuery.getJQuery()
public String getJQuery()
null
.setJQuery(java.lang.String)
public void setUserHeader(URL url)
url
- location of an XHTML page.
The content of its body element is inserted as is in
the div id="wh-header" found in an XHTML page
decorated by the compiler.getUserHeader()
public URL getUserHeader()
null
.setUserHeader(java.net.URL)
public void setUserFooter(URL url)
url
- location of an XHTML page.
The content of its body element is inserted as is in
the div id="wh-footer" found in an XHTML page
decorated by the compiler.getUserFooter()
public URL getUserFooter()
null
.setUserFooter(java.net.URL)
public void setUserCSS(URL url)
This file is copied to output_directory/_wh/user/.
url
- location of a CSS stylesheetgetUserCSS()
,
setUserResources(java.io.File)
public URL getUserCSS()
null
.setUserCSS(java.net.URL)
public void setUserResources(File dir)
dir
- a directory to be recursively copied
to output_directory/_wh/user/.getUserResources()
,
getUserHeader()
,
setUserFooter(java.net.URL)
,
setUserCSS(java.net.URL)
public File getUserResources()
null
.setUserResources(java.io.File)
public void setFavicon(URL url)
A favicon is a small image displayed next to the page title in the browser tab.
This file is copied to output_directory/_wh/user/.
url
- location of the favicongetFavicon()
public URL getFavicon()
null
.
A favicon is a small image displayed next to the page title in the browser tab.
setFavicon(java.net.URL)
public void setDefaultLanguage(String lang)
This language is needed by the full-text indexer component of this compiler.
lang
- the default language of an XHTML page.
A language code conforming
RFC 3066.
Examples: "de", "fr-CA".
May be null
in which case "en" is used.getDefaultLanguage()
public String getDefaultLanguage()
setDefaultLanguage(java.lang.String)
public void setCollapseTOC(boolean collapse)
By default, the TOC is initially expanded.
collapse
- if true
, the TOC should be initially
collapsed.getCollapseTOC()
public boolean getCollapseTOC()
true
if the TOC is to be initially
collapsed; otherwise returns false
.setCollapseTOC(boolean)
public void setUseStemming(boolean stemming)
By default, stemming must be used whenever possible, that is, when the main language of the document can be determined and when this main language is one of: danish, dutch, english, finnish, french, german, hungarian, italian, norwegian, portuguese, russian, spanish, swedish, romanian, turkish.
stemming
- if true
, stemming is to implement
the search by contents facilitygetUseStemming()
,
setDefaultLanguage(java.lang.String)
public boolean getUseStemming()
true
if stemming is to be used to implement
the search by contents facility; otherwise returns false
.setUseStemming(boolean)
public void setIndexNumbers(boolean index)
By default, words looking like numbers are not indexed.
Examples of such words: 3.14, 3,14, 3times4equals12, +1, -1.0, 3px, 1,2cm, 100%, 1.0E+6, 1,000.00$.
getIndexNumbers()
public boolean getIndexNumbers()
true
if words looking like numbers
are to be indexed; otherwise returns false
.setIndexNumbers(boolean)
public void setIdMapTitle(String title)
title
- the value of the title
attribute
of the generated idMap
root element.
This value is the title of the document for which a Web Help has been generated.
May be empty or null
in which case an ID map
is not generated (which is the default behavior).
setIdMapHref(java.lang.String)
,
getIdMapTitle()
public String getIdMapTitle()
public void setIdMapHref(String href)
href
- the value of the href
attribute
of the generated idMap
root element.
This value should point to the HTML file which is the "entry point" of the generated Web Help.
May be empty or null
in which case an ID map
is not generated (which is the default behavior).
Note that this parameter is the absolute or relative URL of a file or directory. Directory example: specify My%20Doc/index.html, not My Doc\index.html.
setIdMapTitle(java.lang.String)
,
getIdMapHref()
public String getIdMapHref()
public void setIdMapIdPrefix(String prefix)
prefix
- prefix of extra IDs to be added to the ID map.setIdMapTitle(java.lang.String)
,
setIdMapHref(java.lang.String)
public String getIdMapIdPrefix()
setIdMapIdPrefix(java.lang.String)
.
May return null
.public void setResponsiveUI(boolean responsive)
true
.getResponsiveUI()
public boolean getResponsiveUI()
true
if the UI of the generated Web Help
is to be "responsive"; false
otherwise.setResponsiveUI(boolean)
public void setUILanguage(String lang)
BROWSER_LANGUAGE
.lang
- the language to be used. An ISO 639-1 language code
(e.g. "de
", "fr-CH
") or
DOCUMENT_LANGUAGE
or BROWSER_LANGUAGE
or
null
(which is equivalent to BROWSER_LANGUAGE
).getUILanguage()
public String getUILanguage()
setUILanguage(java.lang.String)
public void setThemeProperty(String name, String value)
name
- name of a custom CSS property
used by the current Web Help "theme".
Example: --navigation-width
.
(name always starts with "--
".)value
- value of the name custom CSS property.
Example: 25%
.getThemeProperties()
,
inheritFontAndColors(boolean)
public Map<String,String> getThemeProperties()
setThemeProperty(java.lang.String, java.lang.String)
.public void inheritFontAndColors(boolean inherit)
setThemeProperty(java.lang.String, java.lang.String)
to set all the
CSS theme properties specifying the font and colors of
the navigation pane to "inherit
".public boolean parseParameters(String[] parameters)
setUILanguage(java.lang.String)
,
setJQuery(java.lang.String)
, ..., setCollapseTOC(boolean)
, as needed to.parameters
- a list of parameter name/parameter value pairs.
A parameter may be prefixed by "wh-",
in which case this prefixed is stripped.true
if the parameters have been successfully
parsed; false
otherwise (in which case error messages
are displayed on the console).public boolean parseParameters(String[] parameters, URL baseURL)
public boolean compile(File[] xhtmlFiles, File tocFile, File indexFile, File outDir) throws IOException
compile(URL[], URL, URL, File)
, except that the arguments
are File
s and not URL
s.IOException
public boolean compile(URL[] xhtmlURLs, URL tocURL, URL indexURL, File outDir) throws IOException
Decorating means: adding a few extra XHTML elements to each page. These elements typically point to CSS, image and JavaScript resources found in the output_directory/_wh/ directory.
xhtmlURLs
- the list of XHTML input files to be ``decorated'' by
the compiler.tocURL
- the XML file specifying the entries of
the Table Of Contents.
May be null
in which case a simple TOC
comprising the list of the titles of the XHTML input files
is automatically used to populate the Contents tab.
This XML file must conform to RELAX NG schema toc.rnc.
indexURL
- the XML file specifying the entries of the Index.
May be null
in which case the Index tab
is not created.
This XML file must conform to RELAX NG schema index.rnc.
outDir
- the output directory. May be null
in which case the XHTML input files are modified in place.
When the XHTML input files are decorated in place, they must all be found in the same directory.
true
if the Web Help application has
been successfully generated;
false
otherwise (in which case error messages
are displayed on the console).IOException
- if an I/O error occurs while reading or
writing files.public static void main(String[] args)