This project extends Maven Doxia with a macro offering an advanced way of including static or dynamic content into generated technical sites & documents that are built within the Maven ecosystem.
Include Macro for Maven2 & 3 :: Doxia starts where the standard Snippet macro ends. It combines features like standard file & snippet inclusion, source code highlighting and dynamic content creation without adding additional dependencies like requiring custom site skins or modifications to the standard site templates.
Maven :: Doxia is used by the maven-site-plugin to build project sites within a Maven project. The Macro defined by this extension can be used as soon as it was registered within your own project's pom.xml (Maven - Project Object Model).
See Usage & Parameter Reference for an overview how the Macro can be used in own projects.
%{include|source=samples/HelloWorld.java}
1 2 3 4 5 6 7 8 9 | /** * Hello World Class */ public class HelloWorld { @Override public String toString() { return "Hello World" ; } } |
Bundled highlighting schemes (brushes) include support for: Java, JavaFX, JavaScript, JSP, Groovy, GSP, XML/XHTML, SQL, Bash, Batch, Flex/AS3 and more.
Behind the scenes, syntax highlighting is implemented using a well known javascript library (SyntaxHighlighter) that runs on Rhino during a build. This results in good support for highlighting schemes in combination with no requirement for client side javascript.
%{include|source=samples.HelloWorld|snippet=AJ:..toString()}
5 6 7 8 | @Override public String toString() { return "Hello World" ; } |
%{include|source=pom.xml|snippet=XP://license}
213 214 215 216 217 | < license > < name >The Apache Software License, Version 2.0</ name > < distribution >repo</ distribution > </ license > |
Among other options, snippets can be selected using AOP-like, XPath and Regular expressions as well as the traditional snippet IDs (similar to snippet macro).
Examples:snippet=#SnippetId
'snippet=!snippet-ids
'snippet=#SnippetId, !snippet-ids
'snippet=grep:Token,!grep:NotToken
'snippet=re:([0-9,.;\s]+)$
' (all lines ending with numeric expressions)snippet=xp:/html/head/title
'snippet=aj:..InnerClass, !aj:..toString()
'snippet=tb:"json-key"{, !tb:"inner-array"[
'snippet=lines:50-100
'1 2 3 4 5 6 | <%@ page contentType="text/html;charset=UTF-8"%> < html > < body > < h1 ><% out.println("${title}"); %></ h1 > </ body > </ html > |
%{include|source=samples/hello-world.jsp.vm|title=Hello World 2}
1 2 3 4 5 6 | <%@ page contentType= "text/html;charset=UTF-8" %> < html > < body > < h1 > <% out.println( "Hello World 2" ); %> </ h1 > </ body > </ html > |
Any source that ends with the file extension ".vm" is considered a velocity template and processed before any inclusion and snippet extraction is applied (w. or wo. highlighting of the final results).
All call-time parameters that were specified with the Macro call are available inside the velocity template using ${paramName}.
In addition when using a source-class, dynamic content can be made available to the template which is excessively used in the bundled templates and extensions. See reference for more details on using templates and look after bundled extensions to see how this feature can be used.