CodeName OneShai Almog4 min readintermediate
Javadoc That Feels Like Your Website
Summary
Codename One replaced its Javadoc‑generated site with a Hugo‑based pipeline: a custom doclet emits one Hugo content file per Java type, preserving Markdown comments, generating a lightweight search index, and keeping the traditional offline Javadoc archive. The approach reduces index size (1.9 MB → 341 KB gzipped), retains existing anchors, and can be reused for other Java projects.
- A custom doclet (`maven/javadoc-hugo-doclet`) converts the Javadoc model into Hugo front‑matter files, letting the static site generator handle layout and theming.
- Java 23+ Markdown doc comments are passed unchanged to Hugo’s Goldmark renderer, avoiding double‑parsing.
- `MarkdownSections` extracts conventional headings (Parameters, Returns, etc.) into structured data while preserving author‑defined sections.
- Search index built from the API model is ~5× smaller than a naïve JSON dump (1.9 MB → 341 KB gzipped).
Integrating documentation generation with the site’s own build pipeline eliminates CSS/JS wrapper hacks, provides a consistent look across guide and API, and improves discoverability by surfacing API members in the site search. The reduced index size speeds up client‑side search, and the anchor‑pre…
6/10