This RFC is a follow up from:
Proposal
There are numerous places in LLVM codebases where we generate HTML
- llvm-project/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp at 90556efaa2f5703920cce4a9c0ee36365e15e2ab · llvm/llvm-project · GitHub
- llvm-project/clang/lib/Rewrite/HTMLRewrite.cpp at a3d41879ecf5690a73f9226951d3856c7faa34a4 · llvm/llvm-project · GitHub
- llvm-project/clang/tools/clang-diff/ClangDiff.cpp at a3d41879ecf5690a73f9226951d3856c7faa34a4 · llvm/llvm-project · GitHub
- llvm-project/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp at a3d41879ecf5690a73f9226951d3856c7faa34a4 · llvm/llvm-project · GitHub
- llvm-project/clang-tools-extra/include-cleaner/lib/HTMLReport.cpp at a3d41879ecf5690a73f9226951d3856c7faa34a4 · llvm/llvm-project · GitHub
- llvm-project/llvm/lib/Passes/StandardInstrumentations.cpp at a3d41879ecf5690a73f9226951d3856c7faa34a4 · llvm/llvm-project · GitHub
- llvm-project/llvm/tools/llvm-exegesis/lib/Analysis.cpp at a3d41879ecf5690a73f9226951d3856c7faa34a4 · llvm/llvm-project · GitHub
Each place in the code has its own ad-hock way of generating HTML via C++. This can make it hard make a change to the HTML output since the application logic is mixed up with the presentation logic.
The idea is to introduce an existing template language spec (Mustache) into the llvm support library for future/existing tools to use, which enables easier reasoning of the output.
The library will implement the mustache spec specified here GitHub - mustache/spec: The Mustache spec.
Implementation
Currently the library/tests is implemented in the PR below with most of the mustache spec implemented with some exceptions
This library was evolved out of my GSOC project to improve clang-doc (a new documentation generator for C++). I was able to cut down on the HTML back end output by around 500 lines and greatly simplifying the HTML generation.
Also by separating out the mustache presentation files you can also change the HTML output without recompilation of the tool.
To view the PR of the use of the library see here: