------ Doxia Macros Guide ------ Vincent Siveton ------ 2009-03-02 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ~~ NOTE: For help with the syntax of this file, see: ~~ http://maven.apache.org/doxia/references/apt-format.html Doxia Macros Guide The Doxia includes macro mechanisms to facilitate the documentation writing. Macros are currently only supported for APT, Xdoc and FML formats. Starting with Doxia 1.7 (maven-site-plugin 3.5), macros are also supported for XHTML and Markdown. Macros are not (and probably will never be) supported by Confluence, Docbook and Twiki modules. A macro in an APT source file is a <> line that looks like this: +---- %{macro_name|param1=value1|param2=value2|...} +---- An Xdoc or FML macro has the following syntax: +---- ... +---- Since Doxia 1.7, an XHTML or Markdown macro has the following syntax: +---- +---- As of Doxia 1.7, the following macros are available: %{toc|section=1|fromDepth=2|toDepth=2} * {Echo Macro} The macro is a very simple macro: it prints out the key and value of any supplied parameters. For instance, in an APT file, you could write: +---- %{echo|param1=value1|param2=value2} +---- Similarly, it will be for xdoc file: +---- +---- and it will output +---- param1 ---> value1 param2 ---> value2 +---- * {Snippet Macro} The macro is a very useful macro: it prints out the content of a file or a URL. For instance, in an APT file, you could write: +---- %{snippet|id=myid|url=http://myserver/path/to/file.txt} +---- In a xdoc file, it will be: +---- +---- The <<>> parameter is not required if you want to include the entire file. If you want to include only a part of a file, you should add start and end demarcators: any line (typically a comment) that contains the strings "<<>>", "<<>>" and "<<>>" (where <<>> is the <<>> of the snippet) is a start demarcator, and similarly "<<>>" denotes the end of the snippet to include. For example: * Start and end snippets in a Java file +---- public class MyClass { // START SNIPPET: myid public static void main( String[] args ) throws Exception { ... } // END SNIPPET: myid } +---- * Start and end snippets in a XML file +---- ... ... +---- [] *-----------+--------------+ || Parameter || Description | *-----------+--------------+ | id | The id of the snippet to include. | | If omitted the whole file/url will be included (since Doxia 1.1). *-----------+--------------+ | url | The path of the URL to include. *-----------+--------------+ | file | The path of the file to include (since doxia-1.0-alpha-9). *-----------+--------------+ | verbatim | If the content should be output as verbatim escaped text. If this is set to <<>> then the content | | of the snippet will not be escaped. This means that you can use it like Server-Side Includes on a | | webserver. Default value is <<>>. *-----------+--------------+ | encoding | The encoding of the file to read (since Doxia 1.6). If omitted the default JVM encoding will be used. *-----------+--------------+ * {TOC Macro} The macro prints a Table Of Content of a document. It is useful if you have several sections and subsections in your document. For instance, in an APT file, you could write: +---- %{toc|section=2|fromDepth=2|toDepth=3} +---- This displays a TOC for the second section in the document, including all subsections (depth 2) and sub-subsections (depth 3). <> that in Doxia, apt section titles are not implicit anchors (see {{{../references/doxia-apt.html}Enhancements to the APT format}}), so you need to insert explicit anchors for links to work! In a xdoc file, it will be: +---- +---- *-----------+--------------+ || Parameter || Description | *-----------+--------------+ | section | Display a TOC for the specified section only, or all sections if 0. Positive int, not mandatory, 0 by default. *-----------+--------------+ | fromDepth | Minimum section depth to include in the TOC (sections are depth 1, sub-sections depth 2, etc.). Positive int, not mandatory, 0 by default. *-----------+--------------+ | toDepth | Maximum section depth to include in the TOC. Positive int, not mandatory, 5 by default. *-----------+--------------+ From <> on you may also specify any of the html base attributes ( any of <<>>, <<>>, <<