83 if (!n->children.empty())
85 int d = n->computeTreeDepth(level+1);
86 if (d>maxDepth) maxDepth=d;
100 num+=n->numNodesAtLevel(level+1,maxLevel);
150 p->indentNodes.resize(
p->indent+1);
164 auto &nl =
p->indentNodes[
p->indent];
168 auto &children =
p->indentNodes[
p->indent+1];
169 for (
const auto &child : children)
171 parent->children.push_back(child);
201 auto &nl =
p->indentNodes[
p->indent];
204 nl.back()->isLast=
false;
206 auto newNode = std::make_shared<FTVNode>(isDir,ref,file,anchor,name,separateIndex,addToNavIndex,def,nameAsHtml);
207 nl.push_back(newNode);
208 newNode->index =
static_cast<int>(nl.size()-1);
211 auto &pnl =
p->indentNodes[
p->indent-1];
214 newNode->parent = pnl.back();
222 if (!url.
empty() && url.
at(0)==
'!')
227 else if (!url.
empty() && url.
at(0)==
'^')
246 if (!n->anchor.empty()) url+=
"#"+n->anchor;
254 auto parent = n->parent.lock();
267 auto parent = n->parent.lock();
269 if (n->isDir && dynamicSections)
271 const char *ARROW_DOWN =
"<span class=\"arrowhead opened\"></span>";
272 const char *ARROW_RIGHT =
"<span class=\"arrowhead closed\"></span>";
273 DString dir = opened ? ARROW_DOWN : ARROW_RIGHT;
274 for(
int i=0;i<indent;i++) t <<
"<span class=\"spacer\"> </span>";
280 for(
int i=0;i<=indent;i++) t <<
"<span class=\"spacer\"> </span>";
288 bool setTarget =
false;
289 bool nameAsHtml = !n->nameAsHtml.empty();
293 t <<
"<b>" << text <<
"</b>";
299 t <<
"<a class=\"elRef\" ";
301 if (result !=
"") setTarget =
true;
306 t <<
"<a class=\"el\" ";
314 t <<
"\" target=\"basefrm\">";
316 t <<
"\" target=\"_self\">";
326 t <<
" [external]";
346 .setLinkFromIndex(
true))
355 std::visit(visitor,astImpl->
root);
384 for (
const auto &n : nl)
392 if (level>=maxLevel && dynamicSections)
397 t <<
"><td class=\"entry\">";
398 bool nodeOpened = level+1<maxLevel;
412 if ((n->def->getLanguage() == SrcLangExt::Slice) || (n->def->getLanguage() == SrcLangExt::Fortran))
414 t <<
"<span class=\"icona\"><span class=\"icon\">M</span></span>";
416 else if ((n->def->getLanguage() == SrcLangExt::Java) || (n->def->getLanguage() == SrcLangExt::VHDL))
418 t <<
"<span class=\"icona\"><span class=\"icon\">P</span></span>";
422 t <<
"<span class=\"icona\"><span class=\"icon\">N</span></span>";
427 t <<
"<span class=\"icona\"><span class=\"icon\">M</span></span>";
432 t <<
"<span class=\"icona\"><span class=\"icon\">" << icon <<
"</span></span>";
434 else if (dynamicSections)
437 <<
"<div class=\"folder-icon"
438 << (nodeOpened ?
" open" :
"")
439 <<
"\"></div></span>";
442 t <<
"</td><td class=\"desc\">";
455 (
toFileDef(n->def))->generateSourceFile())
463 t <<
"<a href=\"" << fn <<
"\">";
475 if ((n->def->getLanguage() == SrcLangExt::Slice) || (n->def->getLanguage() == SrcLangExt::Fortran))
477 t <<
"<span class=\"icona\"><span class=\"icon\">M</span></span>";
479 else if ((n->def->getLanguage() == SrcLangExt::Java) || (n->def->getLanguage() == SrcLangExt::VHDL))
481 t <<
"<span class=\"icona\"><span class=\"icon\">P</span></span>";
485 t <<
"<span class=\"icona\"><span class=\"icon\">N</span></span>";
490 t <<
"<span class=\"icona\"><span class=\"icon\">M</span></span>";
495 t <<
"<span class=\"icona\"><span class=\"icon\">" << icon <<
"</span></span>";
499 t <<
"<span class=\"icona\"><span class=\"icon\">R</span></span>";
503 t <<
"<span class=\"iconfolder\"><div class=\"folder-icon\"></div></span>";
507 t <<
"<span class=\"icondoc\"><div class=\"doc-icon\"></div></span>";
514 t <<
"</td><td class=\"desc\">";
540 auto parent = n->parent.lock();
546 if (leaf!=n) result+=
",";
552 auto parent = n->parent.lock();
553 if (!
parent)
return false;
554 if (n->file==
parent->file)
return true;
560 bool nameAsHtml = !n->nameAsHtml.empty();
566 t <<
"\"" << link <<
"\", null, ";
570 t <<
"\"" << link <<
"\", \"";
580 size_t i=varId.
rfind(
'/');
582 if (isdigit(varId[0])) varId.
prepend(
"_");
600 for (
const auto &n : nl)
602 if (n->separateIndex)
604 if (!n->children.empty())
607 files.emplace_back(fileId,n);
621 const FTVNodes &nl,
int level,
bool &first)
625 indentStr.
fill(
' ',level*2);
628 for (
const auto &n : nl)
631 if (!first) t <<
",\n";
641 if (n->addToNavIndex)
664 if (n->separateIndex)
666 t << indentStr <<
" [ ";
668 if (!n->children.empty())
671 if (!n->anchor.empty())
673 fileId+=
"_"+n->anchor;
679 t <<
"\"" << fileId <<
"\" ]";
688 bool firstChild=
true;
689 t << indentStr <<
" [ ";
691 bool emptySection = !
generateJSTree(navIndex,t,n->children,level+1,firstChild);
695 t <<
"\n" << indentStr <<
" ] ]";
708 if (!n->anchor.empty()) fileId+=
"_"+n->anchor;
713 auto generateJSFile = [&](
const JSTreeFile &tf)
715 DString fileId = getVarName(tf.node);
716 DString fileName = htmlOutput+
"/"+fileId+
".js";
720 bool firstChild =
true;
731 std::size_t numThreads =
static_cast<std::size_t
>(
Config_getInt(NUM_PROC_THREADS));
735 std::vector< std::future<void> > results;
736 for (
const auto &tf : jsTreeFiles)
738 results.emplace_back(threadPool.
queue([&](){ generateJSFile(tf); }));
741 for (
auto &f : results) f.get();
745 for (
const auto &tf : jsTreeFiles)
764 t <<
"var NAVTREE =\n";
768 if (projName.
empty())
802 std::stable_sort(navIndex.begin(),navIndex.end(),[](
const auto &n1,
const auto &n2)
803 { return !n1.url.empty() && (n2.url.empty() || (n1.url<n2.url)); });
807 const int maxElemCount=250;
811 t <<
"var NAVTREEINDEX =\n";
813 tsidx <<
"var NAVTREEINDEX" << subIndex <<
" =\n";
816 auto it = navIndex.begin();
817 while (it!=navIndex.end())
830 t <<
"\"" << e.
url <<
"\"";
832 tsidx <<
"\"" << e.
url <<
"\":[" << e.
path <<
"]";
834 if (it!=navIndex.end() && elemCount<maxElemCount-1) tsidx <<
",";
838 if (it!=navIndex.end() && elemCount>=maxElemCount)
846 if (!tsidx.is_open())
break;
847 tsidx <<
"var NAVTREEINDEX" << subIndex <<
" =\n";
888 int preferredNumEntries =
Config_getInt(HTML_INDEX_NUM_ENTRIES);
889 t <<
"<div class=\"directory\">\n";
891 for (
const auto &n :
p->indentNodes[0])
893 if (!n->children.empty())
895 d = n->computeTreeDepth(2);
896 if (d>depth) depth=d;
899 int preferredDepth = depth;
905 t <<
"<div class=\"levels\">[";
908 for (
int i=1;i<=depth;i++)
910 t <<
"<span class=\"dyn-level-" << i <<
"\">" << i <<
"</span>";
915 if (preferredNumEntries>0)
918 for (
int i=1;i<=depth;i++)
921 for (
const auto &n :
p->indentNodes[0])
923 num+=n->numNodesAtLevel(0,i);
925 if (num<=preferredNumEntries)
938 if (!
p->indentNodes[0].empty())
940 t <<
"<table class=\"directory\">\n";
942 p->generateTree(t,
p->indentNodes[0],0,preferredDepth,index);
946 t <<
"</div><!-- directory -->\n";
A abstract class representing of a compound symbol.
virtual CompoundType compoundType() const =0
Returns the type of compound this is, i.e. class/struct/union/...
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
DString & setNum(short n)
size_t rfind(char c, size_t pos=npos) const
DString fill(char c, size_t len)
Fills a string with a predefined character.
DString mid(size_t index, size_t len=npos) const
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
char & at(size_t i)
Returns a reference to the character at index i.
DString & prepend(const char *s)
The common base class of all entity definitions found in the sources.
virtual DString briefDescription(bool abbreviate=false) const =0
virtual DString briefFile() const =0
virtual SrcLangExt getLanguage() const =0
Returns the programming language this definition was written in.
virtual int briefLine() const =0
virtual DString getSourceFileBase() const =0
virtual DString getOutputFileBase() const =0
Class representing the abstract syntax tree of a documentation block.
static std::unique_ptr< PageDef > mainPage
static DString htmlFileExtension
std::unique_ptr< Private > p
void addContentsItem(bool isDir, const DString &name, const DString &ref, const DString &file, const DString &anchor, bool separateIndex, bool addToNavIndex, const Definition *def, const DString &nameAsHtml=DString())
void generateTreeViewScripts()
void generateTreeViewInline(TextStream &t)
A model of a file symbol.
virtual bool visibleInIndex(bool &genSourceFile) const =0
Returns true if this file is visible in the index.
Generator for HTML code fragments.
Concrete visitor implementation for HTML output.
static LayoutDocManager & instance()
Returns a reference to this singleton.
LayoutNavEntry * rootNavEntry() const
returns the (invisible) root of the navigation tree.
Class representing a list of different code generators.
void add(OutputCodeIntfPtr &&p)
static ResourceMgr & instance()
Returns the one and only instance of this class.
Text streaming class that buffers data.
Class managing a pool of worker threads.
auto queue(F &&f, Args &&... args) -> std::future< decltype(f(args...))>
Queue the callable function f for the threads to execute.
virtual DString trDetailLevel()=0
virtual DString trPanelSynchronisationTooltip(bool enable)=0
virtual DString trListOfAllMembers()=0
ClassDef * toClassDef(Definition *d)
#define Config_getInt(name)
#define Config_getBool(name)
#define Config_getString(name)
constexpr DocNodeVariant * parent(DocNodeVariant *n)
returns the parent node of a given node n or nullptr if the node has no parent.
IDocParserPtr createDocParser()
factory function to create a parser
IDocNodeASTPtr validatingParseDoc(IDocParser &parserIntf, const DString &fileName, int startLine, const Definition *ctx, const MemberDef *md, const DString &input, const DocOptions &options)
DString substitute(const DString &s, const DString &src, const DString &dst)
substitute all occurrences of src in s by dst
FileDef * toFileDef(Definition *d)
static DString node2URL(const FTVNodePtr &n, bool overruleFile=false, bool srcLink=false)
static DString pathToNode(const FTVNodePtr &leaf, const FTVNodePtr &n)
static bool dupOfParent(const FTVNodePtr &n)
static bool generateJSTree(NavIndexEntryList &navIndex, TextStream &t, const FTVNodes &nl, int level, bool &first)
static void generateJSLink(TextStream &t, const FTVNodePtr &n)
static DString convertFileId2Var(const DString &fileId)
static void generateBriefDoc(TextStream &t, const Definition *def)
static void collectJSTreeFiles(const FTVNodes &nl, JSTreeFiles &files)
static char compoundIcon(const ClassDef *cd)
static std::mutex g_navIndexMutex
std::vector< FTVNodePtr > FTVNodes
std::weak_ptr< FTVNode > FTVNodeWeakPtr
static void generateIndent(TextStream &t, const FTVNodePtr &n, bool opened)
static DString generateIndentLabel(const FTVNodePtr &n, int level)
std::shared_ptr< FTVNode > FTVNodePtr
static void generateJSTreeFiles(NavIndexEntryList &navIndex, TextStream &t, const FTVNodes &nodeList)
std::vector< JSTreeFile > JSTreeFiles
static void generateJSNavTree(const FTVNodes &nodeList)
constexpr auto JAVASCRIPT_LICENSE_TEXT
Translator * theTranslator
std::ofstream openOutputStream(const DString &name, bool append=false)
Portable versions of functions that are platform dependent.
Helper class to pass options when calling OutputList::generateDoc().
void generateTree(TextStream &t, const FTVNodes &nl, int level, int maxLevel, int &index)
void generateLink(TextStream &t, const FTVNodePtr &n)
std::vector< FTVNodes > indentNodes
int numNodesAtLevel(int level, int maxLevel) const
FTVNode(bool dir, const DString &r, const DString &f, const DString &a, const DString &n, bool sepIndex, bool navIndex, const Definition *df, const DString &nameAsHtml_)
int computeTreeDepth(int level) const
JSTreeFile(const DString &fi, const FTVNodePtr &n)
Base class for the layout of a navigation item at the top of the HTML pages.
LayoutNavEntry * find(LayoutNavEntry::Kind k, const DString &file=DString()) const
NavIndexEntry(const DString &u, const DString &p)
DString externalLinkTarget(const bool parent)
DString convertToJSString(const DString &s, bool keepEntities, bool singleQuotes)
DString stripScope(const DString &name)
DString convertToHtml(const DString &s, bool keepEntities)
void addHtmlExtensionIfMissing(DString &fName)
DString relativePathToRoot(const DString &name)
DString externalRef(const DString &relPath, const DString &ref)
A bunch of utility functions.