Page MenuHomePhabricator

[clang-doc] Add templates to HTML generator

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



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

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


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


Emitting an extra div here?


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.

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.


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.