[clang-format] Fix style of css file paths

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
This commit is contained in:
Diego Astiazaran 2019-07-26 18:02:42 +00:00
parent 51dcb292cc
commit d6cdd98a25
2 changed files with 5 additions and 14 deletions

View File

@ -231,6 +231,8 @@ genStylesheetsHTML(StringRef InfoPath, const ClangDocContext &CDCtx) {
SmallString<128> StylesheetPath = computeRelativePath("", InfoPath); SmallString<128> StylesheetPath = computeRelativePath("", InfoPath);
llvm::sys::path::append(StylesheetPath, llvm::sys::path::append(StylesheetPath,
llvm::sys::path::filename(FilePath)); 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); LinkNode->Attributes.try_emplace("href", StylesheetPath);
Out.emplace_back(std::move(LinkNode)); Out.emplace_back(std::move(LinkNode));
} }

View File

@ -110,34 +110,23 @@ TEST(HTMLGeneratorTest, emitRecordHTML) {
ClangDocContext CDCtx = getClangDocContext(); ClangDocContext CDCtx = getClangDocContext();
auto Err = G->generateDocForInfo(&I, Actual, CDCtx); auto Err = G->generateDocForInfo(&I, Actual, CDCtx);
assert(!Err); 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> std::string Expected = R"raw(<!DOCTYPE html>
<meta charset="utf-8"/> <meta charset="utf-8"/>
<title>class r</title> <title>class r</title>
<link rel="stylesheet" href=")raw" + <link rel="stylesheet" href="../../../clang-doc-default-stylesheet.css"/>
std::string(PathToSylesheet.str()) +
R"raw("/>
<div> <div>
<h1>class r</h1> <h1>class r</h1>
<p>Defined at line 10 of test.cpp</p> <p>Defined at line 10 of test.cpp</p>
<p> <p>
Inherits from Inherits from
<a href=")raw" + std::string(PathToF.str()) + <a href="../../../path/to/F.html">F</a>
R"raw(">F</a>
, G , G
</p> </p>
<h2>Members</h2> <h2>Members</h2>
<ul> <ul>
<li> <li>
private private
<a href=")raw" + std::string(PathToInt.str()) + <a href="../int.html">int</a>
R"raw(">int</a>
X X
</li> </li>
</ul> </ul>