marmos v0.1.0 (alpha state) - Documentation Generation using external tooling

Bradley Chatha sealabjaster at gmail.com
Tue Jul 2 19:18:38 UTC 2024


# Overview

marmos (MARs + deiMOS... I'm not creative) is a tool for 
generating a "generic documentation model" from D code that can 
then be consumed and converted into other formats for external 
documentation generators.

It's in an alpha state right now since it's in a half-rushed 
state where it captures a fair amount of the basic structure of D 
code, but still has a lot to be desired, but I got excited enough 
about the current result to make an announcement.

In more specific terms:

* It uses dmd-as-a-library to parse individual D files (only 
syntax analysis).
* It generates a "strongly-typed" JSON file. Each object has an 
"@type" field denoting its layout.
* It maintains a separate documentation-focused AST so that 
future changes to the frontend's AST can be mitigated. At some 
point I'll add versioning to the documentation types, but for now 
I'll wait until a stable release before thinking about that.
* A core part is integration with external tooling, so a goal for 
marmos is to generate typings and parsers of the documentation 
model for other languages, to make it easy for them to consume 
the JSON output.
* (Currently only a rushed TypeScript generator exists, but it 
does the job surprisingly well).
* It contains a dogfood/reference TypeScript project that 
generates API pages for Microsoft's 
[docfx](https://dotnet.github.io/docfx/) tool.
* As it was mainly purpose-written for one of my other 
unannounced projects, the comment format it supports is some 
dodgy Markdown-esque format rather than ddoc (I don't like 
writing or reading ddoc). This is very much subject to change 
though, it just needs more man-hours put in.

I'll reiterate that this is an alpha, early version release, 
please keep expectations low :D

### Getting Started

It's not easy to get it setup locally yet (something I want to 
address fairly soon), but the README goes over it a bit, and the 
demo repo linked below shows a fairly simple setup.

### Examples

This demo repo: https://github.com/Juptune/marmos-docfx-demo

Generates the following site: 
https://juptune.github.io/marmos-docfx-demo/

I'd say this is a decent example of the current generation's 
(lack of) ability: 
https://juptune.github.io/marmos-docfx-demo/juptune/juptune/http/v1/Structs/Http1WriterBase.html

The above being generated from this comment, to get a feel for 
the formatting: 
https://github.com/Juptune/juptune/blob/master/src/juptune/http/v1.d#L1357

### Next Steps

I'd like to get some feedback on the general idea of this tool; 
whether it's useful at all, etc.

Beyond that I really need to get the missing data collection 
sorted. e.g. arrays; functions/delegates, and some other things 
show up as `<bug: unknown>` since these types aren't properly 
extracted from the frontend yet... `enum` stuff as a whole needs 
properly sorting out when rendering types.

Any pointers on pitfalls the frontend's AST has would be nice as 
well; e.g. it seems I need to manually handle attribute blocks 
(`private:`, etc.) instead of it being auto-propagated onto the 
child nodes of the blocks?


More information about the Digitalmars-d-announce mailing list