Page MenuHomePhabricator

[clang-doc] Add templates to HTML generator
AbandonedPublic

Authored by DiegoAstiazaran on Jun 21 2019, 1:16 PM.

Details

Summary

Templates are added to create a stuctured HTML file.
Commands in doxygen comments are still not handled and the command is displayed in the output.
In HTMLGenerator.cpp .str().str().c_str() is done several times, this is necesary to covert a SmallString object to a char pointer: SmallString->StringRef->string->char*. SmallString and string can't be used because function applyHTMLTemplate is variadic and it requires its arguments to be of a trivial type. StringRef can't be used because its data may not be null terminated. StringRef has a c_str method but it's not constant. It is being considered to change the SmallString attributes to a string to avoid this, but it would be done later.

Depends on D63180.

Diff Detail

Event Timeline

juliehockett added inline comments.Jun 21 2019, 2:00 PM
clang-tools-extra/clang-doc/HTMLGenerator.cpp
59

Put FIXME: Transition Members from llvm::SmallString to std::string and such on this (and others)

clang-tools-extra/clang-doc/HTMLTemplates.cpp
164–167

For verbatim, the open/close commands are simply specifiers for where the section starts and stops, and so don't need to be rendered.

clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
307–308

Emitting an extra div here?

313–314

Emitting extra div/p here? Add a check in the comment generation bit to ensure you're not emitting an empty string for ParagraphComments

DiegoAstiazaran marked 2 inline comments as done.Jun 21 2019, 4:28 PM
DiegoAstiazaran added inline comments.
clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
307–308

The first div is emitted by the MainContent template.
The second div is emitted by the FunctionBlock template.
There's nothing between them because the TopLevelInfoHeader template is not rendered between them, which happens because there's no NamespaceInfo or RecordInfo.
I think we shouldn't worry about it because this won't happen in a real case. In here we're calling generateDocForInfo() with a FunctionInfo as parameter, which won't happen when the complete clang-doc is running, only RecordInfo and NamespaceInfo are passed to generateDocForInfo().

DiegoAstiazaran marked 4 inline comments as done.

Add FIXME comments for llvm::SmallString to std::string transition.
Add check so ParagraphComment template is not generated if its content would be empty.
Fix the VerbatimBlockComment template, open/close commands shouldn't be rendered.
Remove empty assignments in string declarations.

clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
313–314

The <div> is for same reason as the previous comment.
The <p> is generated by the the first child of the FullComment, it has no text.
A check for empty paragraphs has been added.

DiegoAstiazaran abandoned this revision.Jun 28 2019, 12:16 PM

D63857 replaces this revision.
Nodes that represent each HTML tag are used instead of templates, it's easier to maintain.