Open kirkilj opened 2 years ago
With a format="javadoc
<topic>
, the transform already places outputclass="java"
on the <body>
of each topic. That is sufficient to add code highlighting using the Prism.js plugin which works out Java semantics.
The PDF output looks something like this:
Obviously you can tweak the colours as necessary e.g. here
That's handy, but I'd still prefer to retain a semantic trail for other future possible needs beyond formatting.
If you want to add the semantics directly to the JavaDoc DITA just run with both the JavaDoc and PrismJS plugins and run the normalize transform:
./dita -f dita -i <input>.ditamap -Dprismjs.highlightable=true
The result is something like this:
<row>
<entry colname="col1" align="left">
<codeph outputclass="language-java">
<ph outputclass="token keyword">static</ph>
<ph outputclass="token class-name">Effect</ph>
</codeph>
</entry>
<entry colname="col2" align="left">
<codeph outputclass="language-java">
<xref format="dita" scope="local" type="table" href="#org.casbin.jcasbin.effect.Effect/methods_valueOf">valueOf</xref>
<ph outputclass="token punctuation">(</ph>java
<ph outputclass="token punctuation">.</ph>lang
<ph outputclass="token punctuation">.</ph>
<ph outputclass="token class-name">String</ph> name
<ph outputclass="token punctuation">)</ph>
</codeph>Returns the enum constant of this type with the specified name.
</entry>
</row>
Great idea. I've asked the writer to have their R&D peers generate the XML from the xmldoclet so I have something of theirs to play with.
Hi Jason,
Have you considered adding outputclasses to the generated DITA so the semantics of the JavaDoc can be styled as needed? We could easily add those, but it might make your plugin more customizable.
Syncrosoft's recent OpenAPI to DITA converter uses this approach: