public class JJDocMojo
extends org.apache.maven.reporting.AbstractMavenReport
*.jj
files and
run JJDoc once for each file it finds. Each of these output files, along with an index.html
file will
be placed in the site directory (target/site/jjdoc
), and a link will be created in the "Project
Reports" menu of the generated site.Modifier and Type | Class and Description |
---|---|
private static class |
JJDocMojo.GrammarInfoComparator
Compares grammar infos using their relative grammar file paths as the sort key.
|
Modifier and Type | Field and Description |
---|---|
private java.lang.Boolean |
bnf
A flag whether to generate a plain text document with the unformatted BNF.
|
private java.lang.String |
cssHref
The hypertext reference to an optional CSS file for the generated HTML documents.
|
private java.io.File |
defaultGrammarDirectoryJavaCC
The default source directory for hand-crafted grammar files.
|
private java.io.File |
defaultGrammarDirectoryJJTree
The default source directory for grammar files generated by JJTree.
|
private java.io.File |
defaultGrammarDirectoryJTB
The default source directory for grammar files generated by JTB.
|
private java.lang.String |
grammarEncoding
The file encoding to use for reading the grammar files.
|
private java.lang.String |
jjdocDirectory
The relative path of the JJDoc reports in the output directory.
|
private boolean |
oneTable
This option controls the structure of the generated HTML output.
|
private java.io.File |
outputDirectory
The destination directory where JJDoc saves the generated documentation files.
|
private org.apache.maven.project.MavenProject |
project
The current Maven project.
|
private org.apache.maven.doxia.siterenderer.Renderer |
siteRenderer
The site renderer.
|
private java.io.File[] |
sourceDirectories
The directories where the JavaCC grammar files (
*.jj ) are located. |
private java.lang.Boolean |
text
A flag to specify the output format for the generated documentation.
|
Constructor and Description |
---|
JJDocMojo() |
Modifier and Type | Method and Description |
---|---|
boolean |
canGenerateReport() |
private void |
createReportFooter(org.apache.maven.doxia.sink.Sink sink)
Create the HTML footer for the report page.
|
private void |
createReportHeader(java.util.ResourceBundle bundle,
org.apache.maven.doxia.sink.Sink sink)
Create the header and title for the HTML report page.
|
private void |
createReportLink(org.apache.maven.doxia.sink.Sink sink,
java.io.File sourceDirectory,
java.io.File grammarFile,
java.lang.String linkPath)
Create a table row containing a link to the JJDoc report for a grammar file.
|
void |
executeReport(java.util.Locale locale)
Run the actual report.
|
private java.util.ResourceBundle |
getBundle(java.util.Locale locale)
Get the resource bundle for the report text.
|
java.lang.String |
getDescription(java.util.Locale locale) |
private java.io.File |
getJJDocOutputDirectory()
Get the output directory of the JJDoc files, i.e.
|
java.lang.String |
getName(java.util.Locale locale) |
protected java.lang.String |
getOutputDirectory()
Get the output directory of the report if run directly from the command line.
|
private java.lang.String |
getOutputFileExtension()
|
java.lang.String |
getOutputName() |
protected org.apache.maven.project.MavenProject |
getProject()
Get the maven project.
|
protected org.apache.maven.doxia.siterenderer.Renderer |
getSiteRenderer()
Get the site renderer.
|
private java.io.File[] |
getSourceDirectories()
Get the source directories that should be scanned for grammar files.
|
private JJDoc |
newJJDoc()
Creates a new facade to invoke JJDoc.
|
private GrammarInfo[] |
scanForGrammars(java.io.File sourceDirectory)
Searches the specified source directory to find grammar files that can be documented.
|
closeReport, execute, generate, generate, generate, getCategoryName, getInputEncoding, getOutputEncoding, getReportOutputDirectory, getSink, getSinkFactory, isExternalReport, setReportOutputDirectory
private org.apache.maven.project.MavenProject project
private org.apache.maven.doxia.siterenderer.Renderer siteRenderer
private java.io.File[] sourceDirectories
*.jj
) are located. By default, the directories
${basedir}/src/main/javacc
, ${project.build.directory}/generated-sources/jjtree
and ${project.build.directory}/generated-sources/jtb
are scanned for grammar files to document.private java.io.File defaultGrammarDirectoryJavaCC
private java.io.File defaultGrammarDirectoryJJTree
private java.io.File defaultGrammarDirectoryJTB
private java.lang.String jjdocDirectory
private java.io.File outputDirectory
private java.lang.String grammarEncoding
private java.lang.String cssHref
<link>
element in the HTML documents. Otherwise, the default style will
be used.private java.lang.Boolean text
true
, JJDoc will
generate a plain text description of the BNF. Some formatting is done via tab characters, but the intention is to
leave it as plain as possible. Specifying false
causes JJDoc to generate a hyperlinked HTML document
unless the parameter bnf
has been set to true
. Default value is false
.private java.lang.Boolean bnf
true
is only effective if the parameter text
is false
. Default value is
false
.private boolean oneTable
true
, a single HTML
table for the entire BNF is generated. Setting it to false
will produce one table for every
production in the grammar.protected org.apache.maven.project.MavenProject getProject()
getProject
in class org.apache.maven.reporting.AbstractMavenReport
AbstractMavenReport.getProject()
protected org.apache.maven.doxia.siterenderer.Renderer getSiteRenderer()
getSiteRenderer
in class org.apache.maven.reporting.AbstractMavenReport
AbstractMavenReport.getSiteRenderer()
protected java.lang.String getOutputDirectory()
getOutputDirectory
in class org.apache.maven.reporting.AbstractMavenReport
AbstractMavenReport.getOutputDirectory()
private java.io.File getJJDocOutputDirectory()
jjdocDirectory
parameter.private java.io.File[] getSourceDirectories()
null
.public java.lang.String getName(java.util.Locale locale)
locale
- The locale to use for this report.MavenReport.getName(java.util.Locale)
public java.lang.String getDescription(java.util.Locale locale)
locale
- The locale to use for this report.MavenReport.getDescription(java.util.Locale)
public java.lang.String getOutputName()
MavenReport.getOutputName()
public boolean canGenerateReport()
canGenerateReport
in interface org.apache.maven.reporting.MavenReport
canGenerateReport
in class org.apache.maven.reporting.AbstractMavenReport
true
if the configured source directories are not empty, false
otherwise.MavenReport.canGenerateReport()
public void executeReport(java.util.Locale locale) throws org.apache.maven.reporting.MavenReportException
executeReport
in class org.apache.maven.reporting.AbstractMavenReport
locale
- The locale to use for this report.org.apache.maven.reporting.MavenReportException
- If the report generation failed.private java.lang.String getOutputFileExtension()
.html
or .txt
extension depending on the value of
the parameters text
and bnf
.private void createReportHeader(java.util.ResourceBundle bundle, org.apache.maven.doxia.sink.Sink sink)
bundle
- The resource bundle with the text.sink
- The sink for writing to the main report file.private void createReportLink(org.apache.maven.doxia.sink.Sink sink, java.io.File sourceDirectory, java.io.File grammarFile, java.lang.String linkPath)
sink
- The sink to write the reportsourceDirectory
- The source directory of the grammar file.grammarFile
- The JavaCC grammar file.linkPath
- The path to the JJDoc output.private void createReportFooter(org.apache.maven.doxia.sink.Sink sink)
sink
- The sink to write the HTML report page.private JJDoc newJJDoc()
null
.private GrammarInfo[] scanForGrammars(java.io.File sourceDirectory) throws org.apache.maven.reporting.MavenReportException
sourceDirectory
- The source directory to scan for grammar files.null
if the source
directory does not exist.org.apache.maven.reporting.MavenReportException
- If there is a problem while scanning for .jj files.private java.util.ResourceBundle getBundle(java.util.Locale locale)
locale
- The locale to use for this report.