Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format code in Doxia Apt Format

I am currently starting to write a documentation for one of our projects. For reasons of simplicity we chose to use the Almost Plain Text (APT) Format, see more info here: http://maven.apache.org/doxia/references/apt-format.html

APT is great documentation format, since it uses a minimal syntax and hence it is very easy to create and make changes to the documentation without knowing a lot about APT.

However, I couldn't find a way to format code in a nice way. Is there a code tag or similar, which can be used to include some source code? I'm aware I could use FML, but this would be less desirable.

Thanks

like image 662
evgeni Avatar asked Sep 22 '11 14:09

evgeni


4 Answers

For those who are still wondering how to make a code snipped in APT:

     This is regular text
+---------------------
This is a code snippet
+---------------------
      More regular text
like image 132
josh-cain Avatar answered Oct 17 '22 23:10

josh-cain


Apache Maven Fluido Skin highlights syntax out of the box. Here you can find an example. Information about syntax highlighting in Fluido: "Source code sections are enhanced by Google Code Prettify, users can optionally enable line numbers rendering (disabled by default)" from Fluido website.

like image 41
Marcin Avatar answered Oct 17 '22 23:10

Marcin


The

+---------------------
code
+---------------------

syntax is correct. And Fluido does highlight using Prettify out of the box as others have mentioned.

However, a Doxia change in Site Plugin 3.3 broke Fluido. MSKINS-86 fixes this, but hasn't been released yet.

Workarounds

  1. Use the site.xml workaround <body> <head> <script type="text/javascript"> $(document).ready(function () { $("div.source pre").addClass("prettyprint"); prettyPrint(); }); </script> </head> </body>
  2. Use Site Plugin 3.2
  3. Build the unreleased Fluido 1.4 that contains MSKINS-86 fix and use it instead of 1.3.1
like image 3
Keegan Avatar answered Oct 18 '22 00:10

Keegan


I ended up using the snippet macro from the Doxia Macros Guide: http://maven.apache.org/doxia/macros/index.html#Snippet_Macro

It puts the code from the snippet file in a verbatim box. However it does not provide a syntax highlightning.

like image 2
evgeni Avatar answered Oct 18 '22 00:10

evgeni