Skip to content

Commit

Permalink
[clang-format] Fix style of css file paths
Browse files Browse the repository at this point in the history
CSS files included in HTML should have a path in posix style, it should
not be different for Windows.

Differential Revision: https://reviews.llvm.org/D65309

llvm-svn: 367137
  • Loading branch information
DiegoAstiazaran committed Jul 26, 2019
1 parent 51dcb29 commit d6cdd98
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
2 changes: 2 additions & 0 deletions clang-tools-extra/clang-doc/HTMLGenerator.cpp
Expand Up @@ -231,6 +231,8 @@ genStylesheetsHTML(StringRef InfoPath, const ClangDocContext &CDCtx) {
SmallString<128> StylesheetPath = computeRelativePath("", InfoPath);
llvm::sys::path::append(StylesheetPath,
llvm::sys::path::filename(FilePath));
// Paths in HTML must be in posix-style
llvm::sys::path::native(StylesheetPath, llvm::sys::path::Style::posix);
LinkNode->Attributes.try_emplace("href", StylesheetPath);
Out.emplace_back(std::move(LinkNode));
}
Expand Down
17 changes: 3 additions & 14 deletions clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
Expand Up @@ -110,34 +110,23 @@ TEST(HTMLGeneratorTest, emitRecordHTML) {
ClangDocContext CDCtx = getClangDocContext();
auto Err = G->generateDocForInfo(&I, Actual, CDCtx);
assert(!Err);
SmallString<16> PathToF;
llvm::sys::path::native("../../../path/to/F.html", PathToF);
SmallString<16> PathToInt;
llvm::sys::path::native("../int.html", PathToInt);
SmallString<16> PathToSylesheet;
llvm::sys::path::native("../../../clang-doc-default-stylesheet.css",
PathToSylesheet);
std::string Expected = R"raw(<!DOCTYPE html>
<meta charset="utf-8"/>
<title>class r</title>
<link rel="stylesheet" href=")raw" +
std::string(PathToSylesheet.str()) +
R"raw("/>
<link rel="stylesheet" href="../../../clang-doc-default-stylesheet.css"/>
<div>
<h1>class r</h1>
<p>Defined at line 10 of test.cpp</p>
<p>
Inherits from
<a href=")raw" + std::string(PathToF.str()) +
R"raw(">F</a>
<a href="../../../path/to/F.html">F</a>
, G
</p>
<h2>Members</h2>
<ul>
<li>
private
<a href=")raw" + std::string(PathToInt.str()) +
R"raw(">int</a>
<a href="../int.html">int</a>
X
</li>
</ul>
Expand Down

0 comments on commit d6cdd98

Please sign in to comment.