[clang-tools-extra] [clang-doc] [feat] add --repository-line-prefix argument (PR #131280)
Paul Kirth via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 22 13:30:43 PDT 2025
================
@@ -57,11 +58,13 @@ static void writeFileDefinition(const ClangDocContext &CDCtx, const Location &L,
OS << "*Defined at " << L.Filename << "#" << std::to_string(L.LineNumber)
<< "*";
} else {
- OS << "*Defined at [" << L.Filename << "#" << std::to_string(L.LineNumber)
- << "](" << StringRef{*CDCtx.RepositoryUrl}
- << llvm::sys::path::relative_path(L.Filename) << "#"
- << std::to_string(L.LineNumber) << ")"
- << "*";
+
+ std::string LineAnchor =
+ formatv("#{0}{1}", CDCtx.RepositoryLinePrefix.value_or(""),
+ std::to_string(L.LineNumber));
+
+ OS << formatv("*Defined at [{0}{1}]({0}{2})*", LineAnchor, L.Filename,
+ StringRef{*CDCtx.RepositoryUrl});
----------------
ilovepi wrote:
I disagree on the readability. I also think extra allocations and copies should be avoided as much as possible.
https://github.com/llvm/llvm-project/pull/131280
More information about the cfe-commits
mailing list