|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +nav-class: dark |
| 4 | +categories: dmitry |
| 5 | +title: Some Thoughts on Documentation |
| 6 | +author-id: dmitry |
| 7 | +author-name: Dmitry Arkhipov |
| 8 | +--- |
| 9 | + |
| 10 | +Most of my work during the first quarter of this year involved experimenting |
| 11 | +with things which haven't yet reached the state where it would be interesting |
| 12 | +to discuss them. But there was a project that at this point is reaching its |
| 13 | +finish, and thus let's focus on it. That project is AsciiDoc-based |
| 14 | +documentation for Boost.JSON. |
| 15 | + |
| 16 | +Previously the project used a setup that was not too dissimilar to that of many |
| 17 | +Boost libraries. Doxygen collected API reference docs from Javadocs comments in |
| 18 | +the project sources and outputted a set of XML files, then those XML files were |
| 19 | +converted to a Quickbook file. The file was included by the main Quickbook |
| 20 | +documentation source, which Quickbook converted into BoostBook (a dialect of |
| 21 | +DocBook). Finally, BoostBook XSLT stylesheets were used to transform files from |
| 22 | +the previous step to HTML (or some other format, e.g. PDF). |
| 23 | + |
| 24 | +At some point I got frustrated with issues with Docca, the tool we used to |
| 25 | +convert Doxygen XML to Quickbook and wrote a Python equivalent. I wrote about |
| 26 | +it back in [July 2025](../../../2024/07/12/dmitrys-q2-update.html). As noted there, the |
| 27 | +new tool's design allows for changing of output formats and the resulting |
| 28 | +structure of the API reference documentation. Specifically, AsciiDoc and |
| 29 | +producing one page for a set of function overloads was mentioned. Well, this is |
| 30 | +exactly what soon will be used for Boost.JSON's docs. ([Menwhile, here's |
| 31 | +a preview](https://1080.json.prtest2.cppalliance.org/libs/json/doc/html/index.html)). |
| 32 | + |
| 33 | +The first step of the change was of course conversion from Quickbook syntax to |
| 34 | +AsciiDoc syntax. The next step was making the output multi-page. The default |
| 35 | +Asciidoctor HTML backend only produces a single page. I could create multiple |
| 36 | +source files and generate a separate page from each one, but that creates two |
| 37 | +problems: brittle cross-references between sections and no table of contents |
| 38 | +for the entire thing. So, instead I took an existing Asciidoctor plugin, |
| 39 | +[asciidoctor-multipage](https://github.com/owenh000/asciidoctor-multipage/), |
| 40 | +and using its core idea I wrote my own, as I needed somewhat different |
| 41 | +behaviour. The core idea of the plugin is that certain sections are removed |
| 42 | +from their parent sections and spawn separate documents. |
| 43 | + |
| 44 | +The third step involved structuring Javadocs comments very differently. |
| 45 | +Analysing Cpprefernce pages for overloaded functions I came to the idea that |
| 46 | +rather than documenting every overload separately, I could put all |
| 47 | +documentation text into the Javadocs comment of the first one, and reference |
| 48 | +every overload by their number there. There is a catch, though. Overloads have |
| 49 | +different parameter lists and Doxygen warns if a Javadocs comment documents |
| 50 | +a parameter that the function doesn't have or doesn't document a parameter it |
| 51 | +does have. I worked around that by using most of the description for the first |
| 52 | +overload, but collecting parameter list documentation from all overloads. In |
| 53 | +the end it came out nicely. The coolest thing about it is that I didn't have to |
| 54 | +change anything in my Python version of Docca, everything I needed was possible |
| 55 | +with just a custom [Jinja](https://jinja.palletsprojects.com/en/stable/) |
| 56 | +template. |
| 57 | + |
| 58 | +The current target for Boost.JSON's documentation pipeline is Doxygen + Python |
| 59 | +Docca + Asciidoctor. In the future I'm aiming towards replacing Doxygen with |
| 60 | +[Mr.Docs](https://github.com/cppalliance/mrdocs), another exciting project from |
| 61 | +the C++ Alliance. I also hope that this change will motivate other projects |
| 62 | +to switch to AsciiDoc. |
0 commit comments