Skip to content

[WIP] add a mustache backend #108653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 68 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
ac1c7b5
[clang-doc] add suport for clang-doc enum generation
PeterChou1 Jul 31, 2024
bcc4b0d
[clang-doc] remove useless code
PeterChou1 Jul 31, 2024
5fe47ca
[clang-doc] modify unittest
PeterChou1 Jul 31, 2024
28fb40f
[clang-doc] address pr comments
PeterChou1 Aug 12, 2024
0d150ea
[clang-doc] revert CommentInfo change
PeterChou1 Aug 12, 2024
e5e70b8
[clang-doc] fix test
PeterChou1 Aug 12, 2024
1c4f631
[clang-doc] fix unittest
PeterChou1 Aug 12, 2024
b8f3f9c
[clang-doc] address pr comments
PeterChou1 Aug 12, 2024
bb98aad
[clang-doc] clang-format
PeterChou1 Aug 12, 2024
c60e2b5
[llvm] implement support for mustache template language
PeterChou1 Aug 23, 2024
0a20de8
Merge branch 'main' into llvm-add-mustache
PeterChou1 Aug 23, 2024
8290c38
[llvm][Support] Finish implementation of Mustache
PeterChou1 Sep 6, 2024
07d31b4
Merge branch 'llvm-add-mustache' of https://github.com/PeterChou1/llv…
PeterChou1 Sep 6, 2024
6e893c0
[llvm][support] fix mustache test
PeterChou1 Sep 6, 2024
976593e
[llvm][support] add comments
PeterChou1 Sep 6, 2024
6a60eab
[llvm][support] add comments
PeterChou1 Sep 6, 2024
6a1fcc8
[llvm][support] use enumerate for loop
PeterChou1 Sep 6, 2024
f1c27af
Merge branch 'main' into llvm-add-mustache
PeterChou1 Sep 6, 2024
eb1e1a6
[llvm][support] clang-format
PeterChou1 Sep 6, 2024
8ff1100
Merge branch 'llvm-add-mustache' of https://github.com/PeterChou1/llv…
PeterChou1 Sep 6, 2024
f4b0520
[llvm][support] fix mustache test
PeterChou1 Sep 6, 2024
7ffaeec
[llvm][support] clang-format
PeterChou1 Sep 6, 2024
746fb97
[llvm][support] use llvm enumerate
PeterChou1 Sep 6, 2024
4944435
Merge branch 'main' into llvm-add-mustache
PeterChou1 Sep 6, 2024
bcc86fe
[llvm][support] fix unittest
PeterChou1 Sep 11, 2024
2ceb0b0
Merge branch 'llvm-add-mustache' of https://github.com/PeterChou1/llv…
PeterChou1 Sep 11, 2024
95ad7a6
[llvm][support] clang-format
PeterChou1 Sep 11, 2024
bb3b1ac
[llvm][support] address mustache comments
PeterChou1 Sep 12, 2024
d8aa85c
[llvm][support] clang-format
PeterChou1 Sep 12, 2024
0534a05
[llvm][support] clang-format
PeterChou1 Sep 12, 2024
06da7a5
[llvm][support] clang-format
PeterChou1 Sep 12, 2024
f713198
[llvm] mustache address comments
PeterChou1 Oct 8, 2024
6b4f5cd
[llvm] clang-format
PeterChou1 Oct 8, 2024
d400c29
[llvm] fix errors
PeterChou1 Oct 8, 2024
8fa5fd7
[llvm] fix more bugs
PeterChou1 Oct 8, 2024
fd7c106
[llvm] change mustache to pass by reference
PeterChou1 Oct 8, 2024
29bba68
[llvm] fix failing mustache regression test
PeterChou1 Oct 8, 2024
7eed82f
[llvm] format
PeterChou1 Oct 8, 2024
e73454d
[llvm] remove unused mustache member
PeterChou1 Oct 8, 2024
b58fbcb
[llvm] remove unused mustache member
PeterChou1 Oct 8, 2024
bb4ba40
[llvm] address more comments
PeterChou1 Oct 8, 2024
b0ce196
[llvm] address comments
PeterChou1 Oct 8, 2024
561c7eb
clang-format
PeterChou1 Oct 8, 2024
96f6990
clang-format
PeterChou1 Oct 8, 2024
a247423
[llvm] factor out internal classes
PeterChou1 Oct 10, 2024
a0e7d48
[llvm] clang-format
PeterChou1 Oct 10, 2024
4165fec
[llvm] refactor mustache to raw_ostream
PeterChou1 Oct 12, 2024
5b0a20a
[llvm] refactor to use os_stream
PeterChou1 Oct 12, 2024
ba4a6db
[llvm] clang-format
PeterChou1 Oct 12, 2024
362728f
[llvm] fix indentation bug
PeterChou1 Oct 12, 2024
dca40c5
[llvm] add mustache verification tool
PeterChou1 Oct 8, 2024
6fffeb2
[llvm] modify mustache tool
PeterChou1 Oct 12, 2024
7337a99
[llvm] add mustache verification tool
PeterChou1 Oct 8, 2024
439955b
[llvm] add mustache verification tool
PeterChou1 Oct 8, 2024
20045a9
[clang-doc] init mustache implementation
PeterChou1 Sep 13, 2024
adda08b
[clang-doc] add a mustache backend init implementation
PeterChou1 Sep 13, 2024
587bb02
[clang-doc] update
PeterChou1 Sep 24, 2024
ab1c3a6
[clang-doc] add more templates
PeterChou1 Oct 7, 2024
47c2d15
[clang-doc] init mustache implementation
PeterChou1 Sep 13, 2024
279ceee
[clang-doc] add a mustache backend init implementation
PeterChou1 Sep 13, 2024
9ab49b2
[clang-doc] update
PeterChou1 Sep 24, 2024
00830fe
[clang-doc] add more templates
PeterChou1 Oct 7, 2024
08a9f99
[clang-doc] init mustache implementation
PeterChou1 Sep 13, 2024
7e1399b
[clang-doc] add a mustache backend init implementation
PeterChou1 Sep 13, 2024
4e5109a
[clang-doc] add class template
PeterChou1 Oct 11, 2024
42d2995
clang-doc improve mustache output
PeterChou1 Oct 31, 2024
3778849
updated working copy
PeterChou1 Nov 1, 2024
2b490ed
add source ranges
PeterChou1 Nov 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[clang-doc] add more templates
  • Loading branch information
PeterChou1 committed Oct 12, 2024
commit 00830fe6ae738ada3389aec794a47d41f9950cfe
5 changes: 3 additions & 2 deletions clang-tools-extra/clang-doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ add_clang_library(clangDoc
BitcodeReader.cpp
BitcodeWriter.cpp
ClangDoc.cpp
FileHelpersClangDoc.cpp
Generators.cpp
HTMLGenerator.cpp
HTMLMustacheGenerator.cpp
Mapper.cpp
MDGenerator.cpp
Representation.cpp
Serialize.cpp
YAMLGenerator.cpp
HTMLMustacheGenerator.cpp


DEPENDS
omp_gen
ClangDriverOptions
Expand Down
59 changes: 1 addition & 58 deletions clang-tools-extra/clang-doc/HTMLGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "Generators.h"
#include "Representation.h"
#include "FileHelpersClangDoc.h"
#include "clang/Basic/Version.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
Expand Down Expand Up @@ -251,46 +252,6 @@ static void appendVector(std::vector<Derived> &&New,
std::move(New.begin(), New.end(), std::back_inserter(Original));
}

// Compute the relative path from an Origin directory to a Destination directory
static SmallString<128> computeRelativePath(StringRef Destination,
StringRef Origin) {
// If Origin is empty, the relative path to the Destination is its complete
// path.
if (Origin.empty())
return Destination;

// The relative path is an empty path if both directories are the same.
if (Destination == Origin)
return {};

// These iterators iterate through each of their parent directories
llvm::sys::path::const_iterator FileI = llvm::sys::path::begin(Destination);
llvm::sys::path::const_iterator FileE = llvm::sys::path::end(Destination);
llvm::sys::path::const_iterator DirI = llvm::sys::path::begin(Origin);
llvm::sys::path::const_iterator DirE = llvm::sys::path::end(Origin);
// Advance both iterators until the paths differ. Example:
// Destination = A/B/C/D
// Origin = A/B/E/F
// FileI will point to C and DirI to E. The directories behind them is the
// directory they share (A/B).
while (FileI != FileE && DirI != DirE && *FileI == *DirI) {
++FileI;
++DirI;
}
SmallString<128> Result; // This will hold the resulting path.
// Result has to go up one directory for each of the remaining directories in
// Origin
while (DirI != DirE) {
llvm::sys::path::append(Result, "..");
++DirI;
}
// Result has to append each of the remaining directories in Destination
while (FileI != FileE) {
llvm::sys::path::append(Result, *FileI);
++FileI;
}
return Result;
}

// HTML generation

Expand Down Expand Up @@ -1133,24 +1094,6 @@ static llvm::Error genIndex(const ClangDocContext &CDCtx) {
return llvm::Error::success();
}

static llvm::Error
copyFile(StringRef FilePath, StringRef OutDirectory) {
llvm::SmallString<128> PathWrite;
llvm::sys::path::native(OutDirectory, PathWrite);
llvm::sys::path::append(PathWrite, llvm::sys::path::filename(FilePath));
llvm::SmallString<128> PathRead;
llvm::sys::path::native(FilePath, PathRead);
std::error_code OK;
std::error_code FileErr = llvm::sys::fs::copy_file(PathRead, PathWrite);
if (FileErr != OK) {
return llvm::createStringError(llvm::inconvertibleErrorCode(),
"error creating file " +
llvm::sys::path::filename(FilePath) +
": " + FileErr.message() + "\n");
}
return llvm::Error::success();
}

llvm::Error HTMLGenerator::createResources(ClangDocContext &CDCtx) {
auto Err = serializeIndex(CDCtx);
if (Err)
Expand Down
Loading