Doxygen
Loading...
Searching...
No Matches
ftvhelp.cpp File Reference
#include "ftvhelp.h"
#include <memory>
#include <variant>
#include <vector>
#include "classdef.h"
#include "config.h"
#include "docparser.h"
#include "doxygen.h"
#include "filedef.h"
#include "htmldocvisitor.h"
#include "language.h"
#include "layout.h"
#include "message.h"
#include "outputlist.h"
#include "pagedef.h"
#include "portable.h"
#include "resourcemgr.h"
#include "threadpool.h"
#include "util.h"
Include dependency graph for ftvhelp.cpp:

Go to the source code of this file.

Classes

struct  FTVNode
struct  FTVHelp::Private
struct  NavIndexEntry
class  NavIndexEntryList
struct  JSTreeFile

Typedefs

using FTVNodePtr = std::shared_ptr<FTVNode>
using FTVNodeWeakPtr = std::weak_ptr<FTVNode>
using FTVNodes = std::vector<FTVNodePtr>
using JSTreeFiles = std::vector<JSTreeFile>

Functions

static DString node2URL (const FTVNodePtr &n, bool overruleFile=false, bool srcLink=false)
static DString generateIndentLabel (const FTVNodePtr &n, int level)
static void generateIndent (TextStream &t, const FTVNodePtr &n, bool opened)
static void generateBriefDoc (TextStream &t, const Definition *def)
static char compoundIcon (const ClassDef *cd)
static DString pathToNode (const FTVNodePtr &leaf, const FTVNodePtr &n)
static bool dupOfParent (const FTVNodePtr &n)
static void generateJSLink (TextStream &t, const FTVNodePtr &n)
static DString convertFileId2Var (const DString &fileId)
static void collectJSTreeFiles (const FTVNodes &nl, JSTreeFiles &files)
static bool generateJSTree (NavIndexEntryList &navIndex, TextStream &t, const FTVNodes &nl, int level, bool &first)
static void generateJSTreeFiles (NavIndexEntryList &navIndex, TextStream &t, const FTVNodes &nodeList)
static void generateJSNavTree (const FTVNodes &nodeList)

Variables

static int folderId =1
static std::mutex g_navIndexMutex

Typedef Documentation

◆ FTVNodePtr

using FTVNodePtr = std::shared_ptr<FTVNode>

Definition at line 50 of file ftvhelp.cpp.

◆ FTVNodes

using FTVNodes = std::vector<FTVNodePtr>

Definition at line 52 of file ftvhelp.cpp.

◆ FTVNodeWeakPtr

using FTVNodeWeakPtr = std::weak_ptr<FTVNode>

Definition at line 51 of file ftvhelp.cpp.

◆ JSTreeFiles

using JSTreeFiles = std::vector<JSTreeFile>

Definition at line 595 of file ftvhelp.cpp.

Function Documentation

◆ collectJSTreeFiles()

void collectJSTreeFiles ( const FTVNodes & nl,
JSTreeFiles & files )
static

Definition at line 597 of file ftvhelp.cpp.

598{
599 DString htmlOutput = Config_getString(HTML_OUTPUT);
600 for (const auto &n : nl)
601 {
602 if (n->separateIndex) // add new file if there are children
603 {
604 if (!n->children.empty())
605 {
606 DString fileId = n->file;
607 files.emplace_back(fileId,n);
608 collectJSTreeFiles(n->children,files);
609 }
610 }
611 else // traverse without adding a new file
612 {
613 collectJSTreeFiles(n->children,files);
614 }
615 }
616}
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:84
#define Config_getString(name)
Definition config.h:32
static void collectJSTreeFiles(const FTVNodes &nl, JSTreeFiles &files)
Definition ftvhelp.cpp:597

References collectJSTreeFiles(), and Config_getString.

Referenced by collectJSTreeFiles(), and generateJSTreeFiles().

◆ compoundIcon()

char compoundIcon ( const ClassDef * cd)
static

Definition at line 360 of file ftvhelp.cpp.

361{
362 char icon='C';
363 if (cd->getLanguage() == SrcLangExt::Slice)
364 {
366 {
367 icon='I';
368 }
369 else if (cd->compoundType()==ClassDef::Struct)
370 {
371 icon='S';
372 }
373 else if (cd->compoundType()==ClassDef::Exception)
374 {
375 icon='E';
376 }
377 }
378 return icon;
379}
@ Interface
Definition classdef.h:108
@ Exception
Definition classdef.h:111
virtual CompoundType compoundType() const =0
Returns the type of compound this is, i.e. class/struct/union/...
virtual SrcLangExt getLanguage() const =0
Returns the programming language this definition was written in.

References ClassDef::compoundType(), ClassDef::Exception, Definition::getLanguage(), ClassDef::Interface, and ClassDef::Struct.

Referenced by FTVHelp::Private::generateTree().

◆ convertFileId2Var()

DString convertFileId2Var ( const DString & fileId)
static

Definition at line 577 of file ftvhelp.cpp.

578{
579 DString varId = fileId;
580 size_t i=varId.rfind('/');
581 if (i!=DString::npos) varId = varId.mid(i+1);
582 if (isdigit(varId[0])) varId.prepend("_");
583
584 return substitute(varId,"-","_");
585}
size_t rfind(char c, size_t pos=npos) const
Definition dstring.h:244
DString mid(size_t index, size_t len=npos) const
Definition dstring.h:318
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
Definition dstring.h:178
DString & prepend(const char *s)
Definition dstring.h:515
DString substitute(const DString &s, const DString &src, const DString &dst)
substitute all occurrences of src in s by dst
Definition dstring.cpp:485

References DString::mid(), DString::npos, DString::prepend(), DString::rfind(), and substitute().

Referenced by generateJSTreeFiles().

◆ dupOfParent()

bool dupOfParent ( const FTVNodePtr & n)
static

Definition at line 550 of file ftvhelp.cpp.

551{
552 auto parent = n->parent.lock();
553 if (!parent) return false;
554 if (n->file==parent->file) return true;
555 return false;
556}
constexpr DocNodeVariant * parent(DocNodeVariant *n)
returns the parent node of a given node n or nullptr if the node has no parent.
Definition docnode.h:1335

References parent().

Referenced by generateJSTree(), and generateJSTreeFiles().

◆ generateBriefDoc()

void generateBriefDoc ( TextStream & t,
const Definition * def )
static

Definition at line 331 of file ftvhelp.cpp.

332{
333 DString brief = def->briefDescription(true);
334 //printf("*** %p: generateBriefDoc(%s)='%s'\n",def,qPrint(def->name()),qPrint(brief));
335 if (!brief.empty())
336 {
337 auto parser { createDocParser() };
338 auto ast { validatingParseDoc(*parser.get(),
339 def->briefFile(),
340 def->briefLine(),
341 def,
342 nullptr,
343 brief,
344 DocOptions()
345 .setSingleLine(true)
346 .setLinkFromIndex(true))
347 };
348 const DocNodeAST *astImpl = dynamic_cast<const DocNodeAST*>(ast.get());
349 if (astImpl)
350 {
352 OutputCodeList htmlList;
353 htmlList.add<HtmlCodeGenerator>(&t,relPath);
354 HtmlDocVisitor visitor(t,htmlList,def);
355 std::visit(visitor,astImpl->root);
356 }
357 }
358}
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:148
virtual DString briefDescription(bool abbreviate=false) const =0
virtual DString briefFile() const =0
virtual int briefLine() const =0
virtual DString getOutputFileBase() const =0
Class representing the abstract syntax tree of a documentation block.
Definition docnode.h:1471
DocNodeVariant root
Definition docnode.h:1496
Generator for HTML code fragments.
Definition htmlgen.h:23
Concrete visitor implementation for HTML output.
Class representing a list of different code generators.
Definition outputlist.h:162
void add(OutputCodeIntfPtr &&p)
Definition outputlist.h:192
IDocParserPtr createDocParser()
factory function to create a parser
Definition docparser.cpp:59
IDocNodeASTPtr validatingParseDoc(IDocParser &parserIntf, const DString &fileName, int startLine, const Definition *ctx, const MemberDef *md, const DString &input, const DocOptions &options)
Helper class to pass options when calling OutputList::generateDoc().
Definition docoptions.h:24
DString relativePathToRoot(const DString &name)
Definition util.cpp:2912

References OutputCodeList::add(), Definition::briefDescription(), Definition::briefFile(), Definition::briefLine(), createDocParser(), DString::empty(), Definition::getOutputFileBase(), relativePathToRoot(), DocNodeAST::root, and validatingParseDoc().

Referenced by FTVHelp::Private::generateTree().

◆ generateIndent()

void generateIndent ( TextStream & t,
const FTVNodePtr & n,
bool opened )
static

Definition at line 263 of file ftvhelp.cpp.

264{
265 bool dynamicSections = Config_getBool(HTML_DYNAMIC_SECTIONS);
266 int indent=0;
267 auto parent = n->parent.lock();
268 while (parent) { indent++; parent=parent->parent.lock(); }
269 if (n->isDir && dynamicSections)
270 {
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\">&#160;</span>";
275 t << "<span id=\"arr_" << generateIndentLabel(n,0) << "\" class=\"arrow\">" << dir
276 << "</span>";
277 }
278 else
279 {
280 for(int i=0;i<=indent;i++) t << "<span class=\"spacer\">&#160;</span>";
281 }
282}
#define Config_getBool(name)
Definition config.h:33
static DString generateIndentLabel(const FTVNodePtr &n, int level)
Definition ftvhelp.cpp:251

References Config_getBool, generateIndentLabel(), and parent().

Referenced by FTVHelp::Private::generateTree().

◆ generateIndentLabel()

DString generateIndentLabel ( const FTVNodePtr & n,
int level )
static

Definition at line 251 of file ftvhelp.cpp.

252{
253 DString result;
254 auto parent = n->parent.lock();
255 if (parent)
256 {
257 result=generateIndentLabel(parent,level+1);
258 }
259 result+=DString().setNum(n->index)+"_";
260 return result;
261}
DString & setNum(short n)
Definition dstring.h:552

References generateIndentLabel(), parent(), and DString::setNum().

Referenced by generateIndent(), generateIndentLabel(), and FTVHelp::Private::generateTree().

◆ generateJSLink()

void generateJSLink ( TextStream & t,
const FTVNodePtr & n )
static

Definition at line 558 of file ftvhelp.cpp.

559{
560 bool nameAsHtml = !n->nameAsHtml.empty();
561 DString link = nameAsHtml ? convertToJSString(n->nameAsHtml,true) : convertToJSString(n->name);
562 if (Config_getBool(HIDE_SCOPE_NAMES)) link=stripScope(link);
563 link = substitute(link,"\n","");
564 if (n->file.empty()) // no link
565 {
566 t << "\"" << link << "\", null, ";
567 }
568 else // link into other page
569 {
570 t << "\"" << link << "\", \"";
571 t << externalRef("",n->ref);
572 t << node2URL(n);
573 t << "\", ";
574 }
575}
static DString node2URL(const FTVNodePtr &n, bool overruleFile=false, bool srcLink=false)
Definition ftvhelp.cpp:219
DString convertToJSString(const DString &s, bool keepEntities, bool singleQuotes)
Definition util.cpp:3351
DString stripScope(const DString &name)
Definition util.cpp:3109
DString externalRef(const DString &relPath, const DString &ref)
Definition util.cpp:4538

References Config_getBool, convertToJSString(), externalRef(), node2URL(), stripScope(), and substitute().

Referenced by generateJSTree().

◆ generateJSNavTree()

void generateJSNavTree ( const FTVNodes & nodeList)
static

Definition at line 752 of file ftvhelp.cpp.

753{
754 DString htmlOutput = Config_getString(HTML_OUTPUT);
755 std::ofstream f = Portable::openOutputStream(htmlOutput+"/navtreedata.js");
756 NavIndexEntryList navIndex;
757 if (f.is_open())
758 {
759 TextStream t(&f);
760 //TextStream tidx(&fidx);
761 //tidx << "var NAVTREEINDEX =\n";
762 //tidx << "{\n";
764 t << "var NAVTREE =\n";
765 t << "[\n";
766 t << " [ ";
767 DString projName = Config_getString(PROJECT_NAME);
768 if (projName.empty())
769 {
770 if (mainPageHasTitle()) // Use title of main page as root
771 {
772 t << "\"" << convertToJSString(Doxygen::mainPage->title()) << "\", ";
773 }
774 else // Use default section title as root
775 {
776 LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::MainPage);
777 t << "\"" << convertToJSString(lne->title()) << "\", ";
778 }
779 }
780 else // use PROJECT_NAME as root tree element
781 {
782 t << "\"" << convertToJSString(projName) << "\", ";
783 }
784 t << "\"index" << Doxygen::htmlFileExtension << "\", ";
785
786 // add special entry for index page
787 navIndex.emplace_back("index"+Doxygen::htmlFileExtension,"");
788 // related page index is written as a child of index.html, so add this as well
789 navIndex.emplace_back("pages"+Doxygen::htmlFileExtension,"");
790
791 bool first=true;
792 generateJSTree(navIndex,t,nodeList,1,first);
793 generateJSTreeFiles(navIndex,t,nodeList);
794
795 if (first)
796 t << "]\n";
797 else
798 t << "\n ] ]\n";
799 t << "];\n\n";
800
801 // write the navigation index (and sub-indices)
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)); });
804
805 int subIndex=0;
806 int elemCount=0;
807 const int maxElemCount=250;
808 std::ofstream tsidx = Portable::openOutputStream(htmlOutput+"/navtreeindex0.js");
809 if (tsidx.is_open())
810 {
811 t << "var NAVTREEINDEX =\n";
812 t << "[\n";
813 tsidx << "var NAVTREEINDEX" << subIndex << " =\n";
814 tsidx << "{\n";
815 first=true;
816 auto it = navIndex.begin();
817 while (it!=navIndex.end())
818 {
819 const NavIndexEntry &e = *it;
820 if (elemCount==0)
821 {
822 if (!first)
823 {
824 t << ",\n";
825 }
826 else
827 {
828 first=false;
829 }
830 t << "\"" << e.url << "\"";
831 }
832 tsidx << "\"" << e.url << "\":[" << e.path << "]";
833 ++it;
834 if (it!=navIndex.end() && elemCount<maxElemCount-1) tsidx << ","; // not last entry
835 tsidx << "\n";
836
837 elemCount++;
838 if (it!=navIndex.end() && elemCount>=maxElemCount) // switch to new sub-index
839 {
840 tsidx << "};\n";
841 elemCount=0;
842 tsidx.close();
843 subIndex++;
844 DString fileName = htmlOutput+"/navtreeindex"+DString().setNum(subIndex)+".js";
845 tsidx = Portable::openOutputStream(fileName);
846 if (!tsidx.is_open()) break;
847 tsidx << "var NAVTREEINDEX" << subIndex << " =\n";
848 tsidx << "{\n";
849 }
850 }
851 tsidx << "};\n";
852 t << "\n];\n";
853 }
854 t << "\nconst SYNCONMSG = '" << theTranslator->trPanelSynchronisationTooltip(false) << "';";
855 t << "\nconst SYNCOFFMSG = '" << theTranslator->trPanelSynchronisationTooltip(true) << "';";
856 t << "\nconst LISTOFALLMEMBERS = '" << theTranslator->trListOfAllMembers() << "';";
857 }
858
859 auto &mgr = ResourceMgr::instance();
860 {
861 std::ofstream fn = Portable::openOutputStream(htmlOutput+"/navtree.js");
862 if (fn.is_open())
863 {
864 TextStream t(&fn);
865 t << substitute(
866 substitute(mgr.getAsString("navtree.js"),
867 "$TREEVIEW_WIDTH", DString().setNum(Config_getInt(TREEVIEW_WIDTH))),
868 "$PROJECTID",getProjectId());
869 }
870 }
871}
static std::unique_ptr< PageDef > mainPage
Definition doxygen.h:93
static DString htmlFileExtension
Definition doxygen.h:115
static LayoutDocManager & instance()
Returns a reference to this singleton.
Definition layout.cpp:1438
LayoutNavEntry * rootNavEntry() const
returns the (invisible) root of the navigation tree.
Definition layout.cpp:1449
Definition ftvhelp.cpp:534
static ResourceMgr & instance()
Returns the one and only instance of this class.
Text streaming class that buffers data.
Definition textstream.h:36
virtual DString trPanelSynchronisationTooltip(bool enable)=0
virtual DString trListOfAllMembers()=0
#define Config_getInt(name)
Definition config.h:34
static bool generateJSTree(NavIndexEntryList &navIndex, TextStream &t, const FTVNodes &nl, int level, bool &first)
Definition ftvhelp.cpp:620
static void generateJSTreeFiles(NavIndexEntryList &navIndex, TextStream &t, const FTVNodes &nodeList)
Definition ftvhelp.cpp:701
constexpr auto JAVASCRIPT_LICENSE_TEXT
Definition ftvhelp.h:72
Translator * theTranslator
Definition language.cpp:76
std::ofstream openOutputStream(const DString &name, bool append=false)
Definition portable.cpp:681
Base class for the layout of a navigation item at the top of the HTML pages.
Definition layout.h:155
LayoutNavEntry * find(LayoutNavEntry::Kind k, const DString &file=DString()) const
Definition layout.cpp:135
DString title() const
Definition layout.h:215
Definition ftvhelp.cpp:527
DString path
Definition ftvhelp.cpp:530
DString url
Definition ftvhelp.cpp:529
bool mainPageHasTitle()
Definition util.cpp:4959
DString getProjectId()
Definition util.cpp:5285

References Config_getInt, Config_getString, convertToJSString(), DString::empty(), LayoutNavEntry::find(), generateJSTree(), generateJSTreeFiles(), getProjectId(), Doxygen::htmlFileExtension, LayoutDocManager::instance(), ResourceMgr::instance(), JAVASCRIPT_LICENSE_TEXT, Doxygen::mainPage, mainPageHasTitle(), Portable::openOutputStream(), NavIndexEntry::path, LayoutDocManager::rootNavEntry(), DString::setNum(), substitute(), theTranslator, LayoutNavEntry::title(), Translator::trListOfAllMembers(), Translator::trPanelSynchronisationTooltip(), and NavIndexEntry::url.

Referenced by FTVHelp::generateTreeViewScripts().

◆ generateJSTree()

bool generateJSTree ( NavIndexEntryList & navIndex,
TextStream & t,
const FTVNodes & nl,
int level,
bool & first )
static

Definition at line 620 of file ftvhelp.cpp.

622{
623 DString htmlOutput = Config_getString(HTML_OUTPUT);
624 DString indentStr;
625 indentStr.fill(' ',level*2);
626
627 bool found=false;
628 for (const auto &n : nl)
629 {
630 // terminate previous entry
631 if (!first) t << ",\n";
632 first=false;
633
634 // start entry
635 if (!found)
636 {
637 t << "[\n";
638 }
639 found=true;
640
641 if (n->addToNavIndex) // add entry to the navigation index
642 {
643 std::lock_guard lock(g_navIndexMutex);
644 if (n->def && n->def->definitionType()==Definition::TypeFile)
645 {
646 const FileDef *fd = toFileDef(n->def);
647 bool src = false;
648 bool doc = fd->visibleInIndex(src);
649 if (doc)
650 {
651 navIndex.emplace_back(node2URL(n,true,false),pathToNode(n,n));
652 }
653 if (src)
654 {
655 navIndex.emplace_back(node2URL(n,true,true),pathToNode(n,n));
656 }
657 }
658 else
659 {
660 navIndex.emplace_back(node2URL(n),pathToNode(n,n));
661 }
662 }
663
664 if (n->separateIndex) // store items in a separate file for dynamic loading
665 {
666 t << indentStr << " [ ";
667 generateJSLink(t,n);
668 if (!n->children.empty()) // write children to separate file for dynamic loading
669 {
670 DString fileId = n->file;
671 if (!n->anchor.empty())
672 {
673 fileId+="_"+n->anchor;
674 }
675 if (dupOfParent(n))
676 {
677 fileId+="_dup";
678 }
679 t << "\"" << fileId << "\" ]";
680 }
681 else // no children
682 {
683 t << "null ]";
684 }
685 }
686 else // show items in this file
687 {
688 bool firstChild=true;
689 t << indentStr << " [ ";
690 generateJSLink(t,n);
691 bool emptySection = !generateJSTree(navIndex,t,n->children,level+1,firstChild);
692 if (emptySection)
693 t << "null ]";
694 else
695 t << "\n" << indentStr << " ] ]";
696 }
697 }
698 return found;
699}
DString fill(char c, size_t len)
Fills a string with a predefined character.
Definition dstring.h:278
A model of a file symbol.
Definition filedef.h:97
virtual bool visibleInIndex(bool &genSourceFile) const =0
Returns true if this file is visible in the index.
FileDef * toFileDef(Definition *d)
Definition filedef.cpp:2028
static DString pathToNode(const FTVNodePtr &leaf, const FTVNodePtr &n)
Definition ftvhelp.cpp:537
static bool dupOfParent(const FTVNodePtr &n)
Definition ftvhelp.cpp:550
static void generateJSLink(TextStream &t, const FTVNodePtr &n)
Definition ftvhelp.cpp:558
static std::mutex g_navIndexMutex
Definition ftvhelp.cpp:618

References Config_getString, dupOfParent(), DString::fill(), g_navIndexMutex, generateJSLink(), generateJSTree(), node2URL(), pathToNode(), toFileDef(), Definition::TypeFile, and FileDef::visibleInIndex().

Referenced by generateJSNavTree(), generateJSTree(), and generateJSTreeFiles().

◆ generateJSTreeFiles()

void generateJSTreeFiles ( NavIndexEntryList & navIndex,
TextStream & t,
const FTVNodes & nodeList )
static

Definition at line 701 of file ftvhelp.cpp.

702{
703 DString htmlOutput = Config_getString(HTML_OUTPUT);
704
705 auto getVarName = [](const FTVNodePtr n)
706 {
707 DString fileId = n->file;
708 if (!n->anchor.empty()) fileId+="_"+n->anchor;
709 if (dupOfParent(n)) fileId+="_dup";
710 return fileId;
711 };
712
713 auto generateJSFile = [&](const JSTreeFile &tf)
714 {
715 DString fileId = getVarName(tf.node);
716 DString fileName = htmlOutput+"/"+fileId+".js";
717 std::ofstream ff = Portable::openOutputStream(fileName);
718 if (ff.is_open())
719 {
720 bool firstChild = true;
721 TextStream tt(&ff);
722 tt << "var " << convertFileId2Var(fileId) << " =\n";
723 generateJSTree(navIndex,tt,tf.node->children,1,firstChild);
724 tt << "\n];";
725 }
726 };
727
728 JSTreeFiles jsTreeFiles;
729 collectJSTreeFiles(nodeList,jsTreeFiles);
730
731 std::size_t numThreads = static_cast<std::size_t>(Config_getInt(NUM_PROC_THREADS));
732 if (numThreads>1) // multi threaded version
733 {
734 ThreadPool threadPool(numThreads);
735 std::vector< std::future<void> > results;
736 for (const auto &tf : jsTreeFiles)
737 {
738 results.emplace_back(threadPool.queue([&](){ generateJSFile(tf); }));
739 }
740 // wait for the results
741 for (auto &f : results) f.get();
742 }
743 else // single threaded version
744 {
745 for (const auto &tf : jsTreeFiles)
746 {
747 generateJSFile(tf);
748 }
749 }
750}
Class managing a pool of worker threads.
Definition threadpool.h:48
static DString convertFileId2Var(const DString &fileId)
Definition ftvhelp.cpp:577
std::shared_ptr< FTVNode > FTVNodePtr
Definition ftvhelp.cpp:50
std::vector< JSTreeFile > JSTreeFiles
Definition ftvhelp.cpp:595

References collectJSTreeFiles(), Config_getInt, Config_getString, convertFileId2Var(), dupOfParent(), generateJSTree(), Portable::openOutputStream(), and ThreadPool::queue().

Referenced by generateJSNavTree().

◆ node2URL()

DString node2URL ( const FTVNodePtr & n,
bool overruleFile = false,
bool srcLink = false )
static

Definition at line 219 of file ftvhelp.cpp.

220{
221 DString url = n->file;
222 if (!url.empty() && url.at(0)=='!') // relative URL
223 {
224 // remove leading !
225 url = url.mid(1);
226 }
227 else if (!url.empty() && url.at(0)=='^') // absolute URL
228 {
229 // skip, keep ^ in the output
230 }
231 else // local file (with optional anchor)
232 {
233 if (overruleFile && n->def && n->def->definitionType()==Definition::TypeFile)
234 {
235 const FileDef *fd = toFileDef(n->def);
236 if (srcLink)
237 {
238 url = fd->getSourceFileBase();
239 }
240 else
241 {
242 url = fd->getOutputFileBase();
243 }
244 }
246 if (!n->anchor.empty()) url+="#"+n->anchor;
247 }
248 return url;
249}
char & at(size_t i)
Returns a reference to the character at index i.
Definition dstring.h:686
virtual DString getSourceFileBase() const =0
void addHtmlExtensionIfMissing(DString &fName)
Definition util.cpp:3931

References addHtmlExtensionIfMissing(), DString::at(), DString::empty(), Definition::getOutputFileBase(), Definition::getSourceFileBase(), DString::mid(), toFileDef(), and Definition::TypeFile.

Referenced by generateJSLink(), generateJSTree(), and FTVHelp::Private::generateLink().

◆ pathToNode()

DString pathToNode ( const FTVNodePtr & leaf,
const FTVNodePtr & n )
static

Definition at line 537 of file ftvhelp.cpp.

538{
539 DString result;
540 auto parent = n->parent.lock();
541 if (parent)
542 {
543 result+=pathToNode(leaf,parent);
544 }
545 result+=DString().setNum(n->index);
546 if (leaf!=n) result+=",";
547 return result;
548}

References parent(), pathToNode(), and DString::setNum().

Referenced by generateJSTree(), and pathToNode().

Variable Documentation

◆ folderId

int folderId =1
static

Definition at line 46 of file ftvhelp.cpp.

Referenced by FTVHelp::Private::generateTree().

◆ g_navIndexMutex

std::mutex g_navIndexMutex
static

Definition at line 618 of file ftvhelp.cpp.

Referenced by generateJSTree().