[llvm] [clang-doc] fix mustache template whitespace (PR #153724)
Paul Kirth via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 25 13:03:10 PDT 2025
ilovepi wrote:
Thanks for the patch.
First, this needs some kind of test. Without at least that, we can't really tell whats happening to the output. If you want to check whitespace in lit tests, you'll probably need to set up some that use `--match-full-lines` ( https://llvm.org/docs/CommandGuide/FileCheck.html#cmdoption-FileCheck-match-full-lines). As @evelez7 mentioned, it may be possible to check in a unit test, and better test coverage is always welcome.
As for your patch, I'm not totally sure that this is the right way to handle things. I'm fairly certain that the current mustache implementation doesn't handle partials correctly, and even fails some of the conformance tests.
We have an in-tree tool to test the conformance
https://github.com/llvm/llvm-project/blob/main/llvm/utils/llvm-test-mustache-spec/llvm-test-mustache-spec.cpp
In that file there are a fair number of tests that are expected to fail (e.g. we don't conform). Notably the interpolation and partials test suites have failures that I think are significant. This is an area I've been meaning to spend some time improving, but I haven't had time recently to dig into the formatting problem.
My intuition is that the whitespace issue you're fixing on the clang-doc side is a symptom of this deficiency in our mustache implementation.
> Just a thought... if we have JSON, and we have the templates, there are probably already tools that can do this better...
That may be true, but clang-doc is supposed to be a standalone tool with no external dependencies. You're right that another library or external tool may be even more well suited to the task, but its our goal to provide a compelling implementation here, and to not require any other third party dependencies. We're just not quite there yet.
https://github.com/llvm/llvm-project/pull/153724
More information about the llvm-commits
mailing list