brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · 6ed5603 Raw
61 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "Utils.h"10#include "llvm/ADT/SmallString.h"11#include "llvm/ADT/StringRef.h"12#include "llvm/Support/FileSystem.h"13#include "llvm/Support/Path.h"14 15using namespace llvm;16 17SmallString<128> appendPathNative(StringRef Base, StringRef Path) {18  SmallString<128> Default;19  sys::path::native(Base, Default);20  sys::path::append(Default, Path);21  return Default;22}23 24SmallString<128> appendPathPosix(StringRef Base, StringRef Path) {25  SmallString<128> Default;26  sys::path::native(Base, Default, sys::path::Style::posix);27  sys::path::append(Default, Path);28  return Default;29}30 31void getMustacheHtmlFiles(StringRef AssetsPath,32                          clang::doc::ClangDocContext &CDCtx) {33  assert(!AssetsPath.empty());34  assert(sys::fs::is_directory(AssetsPath));35 36  SmallString<128> DefaultStylesheet =37      appendPathPosix(AssetsPath, "clang-doc-mustache.css");38  SmallString<128> NamespaceTemplate =39      appendPathPosix(AssetsPath, "namespace-template.mustache");40  SmallString<128> ClassTemplate =41      appendPathPosix(AssetsPath, "class-template.mustache");42  SmallString<128> EnumTemplate =43      appendPathPosix(AssetsPath, "enum-template.mustache");44  SmallString<128> FunctionTemplate =45      appendPathPosix(AssetsPath, "function-template.mustache");46  SmallString<128> CommentTemplate =47      appendPathPosix(AssetsPath, "comment-template.mustache");48  SmallString<128> IndexJS = appendPathPosix(AssetsPath, "mustache-index.js");49 50  CDCtx.JsScripts.insert(CDCtx.JsScripts.begin(), IndexJS.c_str());51  CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(),52                               DefaultStylesheet.c_str());53  CDCtx.MustacheTemplates.insert(54      {"namespace-template", NamespaceTemplate.c_str()});55  CDCtx.MustacheTemplates.insert({"class-template", ClassTemplate.c_str()});56  CDCtx.MustacheTemplates.insert({"enum-template", EnumTemplate.c_str()});57  CDCtx.MustacheTemplates.insert(58      {"function-template", FunctionTemplate.c_str()});59  CDCtx.MustacheTemplates.insert({"comment-template", CommentTemplate.c_str()});60}61