Doxygen
ftvhelp.cpp 文件参考
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include "ftvhelp.h"
#include "config.h"
#include "message.h"
#include "doxygen.h"
#include "language.h"
#include "htmlgen.h"
#include "layout.h"
#include "pagedef.h"
#include "docparser.h"
#include "htmldocvisitor.h"
#include "filedef.h"
#include "classdef.h"
#include "util.h"
#include "resourcemgr.h"
+ ftvhelp.cpp 的引用(Include)关系图:

浏览源代码.

struct  FTVNode
 
struct  NavIndexEntry
 
class  NavIndexEntryList
 

函数

static QCString node2URL (const FTVNode *n, bool overruleFile=FALSE, bool srcLink=FALSE)
 
static void generateBriefDoc (TextStream &t, const Definition *def)
 
static char compoundIcon (const ClassDef *cd)
 
static QCString pathToNode (const FTVNode *leaf, const FTVNode *n)
 
static bool dupOfParent (const FTVNode *n)
 
static void generateJSLink (TextStream &t, const FTVNode *n)
 
static QCString convertFileId2Var (const QCString &fileId)
 
static bool generateJSTree (NavIndexEntryList &navIndex, TextStream &t, const std::vector< FTVNode * > &nl, int level, bool &first)
 
static void generateJSNavTree (const std::vector< FTVNode * > &nodeList)
 

变量

static int folderId =1
 
const char * JAVASCRIPT_LICENSE_TEXT
 

函数说明

◆ compoundIcon()

static char compoundIcon ( const ClassDef cd)
static

在文件 ftvhelp.cpp365 行定义.

366 {
367  char icon='C';
368  if (cd->getLanguage() == SrcLangExt_Slice)
369  {
371  {
372  icon='I';
373  }
374  else if (cd->compoundType()==ClassDef::Struct)
375  {
376  icon='S';
377  }
378  else if (cd->compoundType()==ClassDef::Exception)
379  {
380  icon='E';
381  }
382  }
383  return icon;
384 }

引用了 ClassDef::compoundType(), ClassDef::Exception, Definition::getLanguage(), ClassDef::Interface, SrcLangExt_Slice , 以及 ClassDef::Struct.

被这些函数引用 FTVHelp::generateTree().

◆ convertFileId2Var()

static QCString convertFileId2Var ( const QCString fileId)
static

在文件 ftvhelp.cpp555 行定义.

556 {
557  QCString varId = fileId;
558  int i=varId.findRev('/');
559  if (i>=0) varId = varId.mid(i+1);
560  return substitute(varId,"-","_");
561 }

引用了 QCString::findRev(), QCString::mid() , 以及 substitute().

被这些函数引用 generateJSTree().

◆ dupOfParent()

static bool dupOfParent ( const FTVNode n)
static

在文件 ftvhelp.cpp533 行定义.

534 {
535  if (n->parent==0) return FALSE;
536  if (n->file==n->parent->file) return TRUE;
537  return FALSE;
538 }

引用了 FALSE, FTVNode::file, FTVNode::parent , 以及 TRUE.

被这些函数引用 generateJSTree().

◆ generateBriefDoc()

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

在文件 ftvhelp.cpp347 行定义.

348 {
349  QCString brief = def->briefDescription(TRUE);
350  //printf("*** %p: generateBriefDoc(%s)='%s'\n",def,qPrint(def->name()),qPrint(brief));
351  if (!brief.isEmpty())
352  {
353  std::unique_ptr<IDocParser> parser { createDocParser() };
354  std::unique_ptr<DocRoot> root { validatingParseDoc(*parser.get(),
355  def->briefFile(),def->briefLine(),
356  def,0,brief,FALSE,FALSE,
357  QCString(),TRUE,TRUE,Config_getBool(MARKDOWN_SUPPORT)) };
359  HtmlCodeGenerator htmlGen(t,relPath);
360  auto visitor = std::make_unique<HtmlDocVisitor>(t,htmlGen,def);
361  root->accept(visitor.get());
362  }
363 }

引用了 Definition::briefDescription(), Definition::briefFile(), Definition::briefLine(), Config_getBool, createDocParser(), FALSE, Definition::getOutputFileBase(), QCString::isEmpty(), relativePathToRoot(), TRUE , 以及 validatingParseDoc().

被这些函数引用 FTVHelp::generateTree().

◆ generateJSLink()

static void generateJSLink ( TextStream t,
const FTVNode n 
)
static

在文件 ftvhelp.cpp540 行定义.

541 {
542  if (n->file.isEmpty()) // no link
543  {
544  t << "\"" << convertToJSString(n->name) << "\", null, ";
545  }
546  else // link into other page
547  {
548  t << "\"" << convertToJSString(n->name) << "\", \"";
549  t << externalRef("",n->ref,TRUE);
550  t << node2URL(n);
551  t << "\", ";
552  }
553 }

引用了 convertToJSString(), externalRef(), FTVNode::file, QCString::isEmpty(), FTVNode::name, node2URL(), FTVNode::ref , 以及 TRUE.

被这些函数引用 generateJSTree().

◆ generateJSNavTree()

static void generateJSNavTree ( const std::vector< FTVNode * > &  nodeList)
static

在文件 ftvhelp.cpp653 行定义.

654 {
655  QCString htmlOutput = Config_getString(HTML_OUTPUT);
656  std::ofstream f(htmlOutput.str()+"/navtreedata.js",std::ofstream::out | std::ofstream::binary);
657  NavIndexEntryList navIndex;
658  if (f.is_open())
659  {
660  TextStream t(&f);
661  //TextStream tidx(&fidx);
662  //tidx << "var NAVTREEINDEX =\n";
663  //tidx << "{\n";
665  t << "var NAVTREE =\n";
666  t << "[\n";
667  t << " [ ";
668  QCString projName = Config_getString(PROJECT_NAME);
669  if (projName.isEmpty())
670  {
671  if (mainPageHasTitle()) // Use title of main page as root
672  {
673  t << "\"" << convertToJSString(Doxygen::mainPage->title()) << "\", ";
674  }
675  else // Use default section title as root
676  {
678  t << "\"" << convertToJSString(lne->title()) << "\", ";
679  }
680  }
681  else // use PROJECT_NAME as root tree element
682  {
683  t << "\"" << convertToJSString(projName) << "\", ";
684  }
685  t << "\"index" << Doxygen::htmlFileExtension << "\", ";
686 
687  // add special entry for index page
688  navIndex.emplace_back("index"+Doxygen::htmlFileExtension,"");
689  // related page index is written as a child of index.html, so add this as well
690  navIndex.emplace_back("pages"+Doxygen::htmlFileExtension,"");
691 
692  bool first=TRUE;
693  generateJSTree(navIndex,t,nodeList,1,first);
694 
695  if (first)
696  t << "]\n";
697  else
698  t << "\n ] ]\n";
699  t << "];\n\n";
700 
701  // write the navigation index (and sub-indices)
702  std::sort(navIndex.begin(),navIndex.end(),[](const auto &n1,const auto &n2)
703  { return !n1.url.isEmpty() && (n2.url.isEmpty() || (n1.url<n2.url)); });
704 
705  int subIndex=0;
706  int elemCount=0;
707  const int maxElemCount=250;
708  std::ofstream tsidx(htmlOutput.str()+"/navtreeindex0.js",std::ofstream::out | std::ofstream::binary);
709  if (tsidx.is_open())
710  {
711  t << "var NAVTREEINDEX =\n";
712  t << "[\n";
713  tsidx << "var NAVTREEINDEX" << subIndex << " =\n";
714  tsidx << "{\n";
715  first=TRUE;
716  auto it = navIndex.begin();
717  while (it!=navIndex.end())
718  {
719  const NavIndexEntry &e = *it;
720  if (elemCount==0)
721  {
722  if (!first)
723  {
724  t << ",\n";
725  }
726  else
727  {
728  first=FALSE;
729  }
730  t << "\"" << e.url << "\"";
731  }
732  tsidx << "\"" << e.url << "\":[" << e.path << "]";
733  ++it;
734  if (it!=navIndex.end() && elemCount<maxElemCount-1) tsidx << ","; // not last entry
735  tsidx << "\n";
736 
737  elemCount++;
738  if (it!=navIndex.end() && elemCount>=maxElemCount) // switch to new sub-index
739  {
740  tsidx << "};\n";
741  elemCount=0;
742  tsidx.close();
743  subIndex++;
744  QCString fileName = htmlOutput+"/navtreeindex"+QCString().setNum(subIndex)+".js";
745  tsidx.open(fileName.str(),std::ofstream::out | std::ofstream::binary);
746  if (!tsidx.is_open()) break;
747  tsidx << "var NAVTREEINDEX" << subIndex << " =\n";
748  tsidx << "{\n";
749  }
750  }
751  tsidx << "};\n";
752  t << "\n];\n";
753  }
754  t << "\nvar SYNCONMSG = '" << theTranslator->trPanelSynchronisationTooltip(FALSE) << "';";
755  t << "\nvar SYNCOFFMSG = '" << theTranslator->trPanelSynchronisationTooltip(TRUE) << "';";
756  }
757  ResourceMgr::instance().copyResource("navtree.js",htmlOutput);
758 }

引用了 Config_getString, convertToJSString(), ResourceMgr::copyResource(), FALSE, LayoutNavEntry::find(), generateJSTree(), Doxygen::htmlFileExtension, ResourceMgr::instance(), LayoutDocManager::instance(), QCString::isEmpty(), JAVASCRIPT_LICENSE_TEXT, Doxygen::mainPage, LayoutNavEntry::MainPage, mainPageHasTitle(), NavIndexEntry::path, LayoutDocManager::rootNavEntry(), QCString::setNum(), QCString::str(), theTranslator, LayoutNavEntry::title(), Translator::trPanelSynchronisationTooltip(), TRUE , 以及 NavIndexEntry::url.

被这些函数引用 FTVHelp::generateTreeViewScripts().

◆ generateJSTree()

static bool generateJSTree ( NavIndexEntryList navIndex,
TextStream t,
const std::vector< FTVNode * > &  nl,
int  level,
bool &  first 
)
static

在文件 ftvhelp.cpp563 行定义.

565 {
566  static QCString htmlOutput = Config_getString(HTML_OUTPUT);
567  QCString indentStr;
568  indentStr.fill(' ',level*2);
569  bool found=FALSE;
570  for (const auto &n : nl)
571  {
572  // terminate previous entry
573  if (!first) t << ",\n";
574  first=FALSE;
575 
576  // start entry
577  if (!found)
578  {
579  t << "[\n";
580  }
581  found=TRUE;
582 
583  if (n->addToNavIndex) // add entry to the navigation index
584  {
585  if (n->def && n->def->definitionType()==Definition::TypeFile)
586  {
587  const FileDef *fd = toFileDef(n->def);
588  bool doc,src;
589  doc = fileVisibleInIndex(fd,src);
590  if (doc)
591  {
592  navIndex.emplace_back(node2URL(n,TRUE,FALSE),pathToNode(n,n));
593  }
594  if (src)
595  {
596  navIndex.emplace_back(node2URL(n,TRUE,TRUE),pathToNode(n,n));
597  }
598  }
599  else
600  {
601  navIndex.emplace_back(node2URL(n),pathToNode(n,n));
602  }
603  }
604 
605  if (n->separateIndex) // store items in a separate file for dynamic loading
606  {
607  bool firstChild=TRUE;
608  t << indentStr << " [ ";
609  generateJSLink(t,n);
610  if (!n->children.empty()) // write children to separate file for dynamic loading
611  {
612  QCString fileId = n->file;
613  if (!n->anchor.isEmpty())
614  {
615  fileId+="_"+n->anchor;
616  }
617  if (dupOfParent(n))
618  {
619  fileId+="_dup";
620  }
621  QCString fileName = htmlOutput+"/"+fileId+".js";
622  std::ofstream f(fileName.str(),std::ofstream::out | std::ofstream::binary);
623  if (f.is_open())
624  {
625  TextStream tt(&f);
626  tt << "var " << convertFileId2Var(fileId) << " =\n";
627  generateJSTree(navIndex,tt,n->children,1,firstChild);
628  tt << "\n];";
629  }
630  f.close();
631  t << "\"" << fileId << "\" ]";
632  }
633  else // no children
634  {
635  t << "null ]";
636  }
637  }
638  else // show items in this file
639  {
640  bool firstChild=TRUE;
641  t << indentStr << " [ ";
642  generateJSLink(t,n);
643  bool emptySection = !generateJSTree(navIndex,t,n->children,level+1,firstChild);
644  if (emptySection)
645  t << "null ]";
646  else
647  t << "\n" << indentStr << " ] ]";
648  }
649  }
650  return found;
651 }

引用了 Config_getString, convertFileId2Var(), dupOfParent(), FALSE, fileVisibleInIndex(), QCString::fill(), generateJSLink(), node2URL(), pathToNode(), QCString::str(), toFileDef(), TRUE , 以及 Definition::TypeFile.

被这些函数引用 generateJSNavTree().

◆ node2URL()

static QCString node2URL ( const FTVNode n,
bool  overruleFile = FALSE,
bool  srcLink = FALSE 
)
static

在文件 ftvhelp.cpp239 行定义.

240 {
241  QCString url = n->file;
242  if (!url.isEmpty() && url.at(0)=='!') // relative URL
243  {
244  // remove leading !
245  url = url.mid(1);
246  }
247  else if (!url.isEmpty() && url.at(0)=='^') // absolute URL
248  {
249  // skip, keep ^ in the output
250  }
251  else // local file (with optional anchor)
252  {
253  if (overruleFile && n->def && n->def->definitionType()==Definition::TypeFile)
254  {
255  const FileDef *fd = toFileDef(n->def);
256  if (srcLink)
257  {
258  url = fd->getSourceFileBase();
259  }
260  else
261  {
262  url = fd->getOutputFileBase();
263  }
264  }
265  url = addHtmlExtensionIfMissing(url);
266  if (!n->anchor.isEmpty()) url+="#"+n->anchor;
267  }
268  return url;
269 }

引用了 addHtmlExtensionIfMissing(), FTVNode::anchor, QCString::at(), FTVNode::def, Definition::definitionType(), FTVNode::file, FileDef::getOutputFileBase(), FileDef::getSourceFileBase(), QCString::isEmpty(), QCString::mid(), toFileDef() , 以及 Definition::TypeFile.

被这些函数引用 generateJSLink(), generateJSTree() , 以及 FTVHelp::generateLink().

◆ pathToNode()

static QCString pathToNode ( const FTVNode leaf,
const FTVNode n 
)
static

在文件 ftvhelp.cpp521 行定义.

522 {
523  QCString result;
524  if (n->parent)
525  {
526  result+=pathToNode(leaf,n->parent);
527  }
528  result+=QCString().setNum(n->index);
529  if (leaf!=n) result+=",";
530  return result;
531 }

引用了 FTVNode::index, FTVNode::parent , 以及 QCString::setNum().

被这些函数引用 generateJSTree().

变量说明

◆ folderId

int folderId =1
static

在文件 ftvhelp.cpp40 行定义.

被这些函数引用 FTVHelp::generateTree().

◆ JAVASCRIPT_LICENSE_TEXT

const char* JAVASCRIPT_LICENSE_TEXT
初始值:
= R"LIC(/*
@licstart The following is the entire license notice for the JavaScript code in this file.
The MIT License (MIT)
Copyright (C) 1997-2020 by Dimitri van Heesch
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@licend The above is the entire license notice for the JavaScript code in this file
*/
)LIC"

在文件 ftvhelp.cpp42 行定义.

被这些函数引用 generateJSNavTree() , 以及 writeMenuData().

ResourceMgr::copyResource
bool copyResource(const QCString &name, const QCString &targetDir) const
Copies a registered resource to a given target directory
Definition: resourcemgr.cpp:180
ResourceMgr::instance
static ResourceMgr & instance()
Returns the one and only instance of this class
Definition: resourcemgr.cpp:32
LayoutNavEntry
Base class for the layout of a navigation item at the top of the HTML pages.
Definition: layout.h:125
NavIndexEntryList
Definition: ftvhelp.cpp:517
FileDef::getSourceFileBase
virtual QCString getSourceFileBase() const =0
LayoutDocManager::rootNavEntry
LayoutNavEntry * rootNavEntry() const
returns the (invisible) root of the navigation tree.
Definition: layout.cpp:1585
Doxygen::mainPage
static std::unique_ptr< PageDef > mainPage
Definition: doxygen.h:83
generateJSLink
static void generateJSLink(TextStream &t, const FTVNode *n)
Definition: ftvhelp.cpp:540
relativePathToRoot
QCString relativePathToRoot(const QCString &name)
Definition: util.cpp:3656
FTVNode::parent
FTVNode * parent
Definition: ftvhelp.cpp:86
NavIndexEntry::path
QCString path
Definition: ftvhelp.cpp:514
pathToNode
static QCString pathToNode(const FTVNode *leaf, const FTVNode *n)
Definition: ftvhelp.cpp:521
QCString::findRev
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition: qcstring.cpp:86
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty
Definition: qcstring.h:144
LayoutNavEntry::find
LayoutNavEntry * find(LayoutNavEntry::Kind k, const QCString &file=QCString()) const
Definition: layout.cpp:107
dupOfParent
static bool dupOfParent(const FTVNode *n)
Definition: ftvhelp.cpp:533
ClassDef::Interface
@ Interface
Definition: classdef.h:110
QCString::str
std::string str() const
Definition: qcstring.h:442
QCString::at
char & at(size_t i)
Returns a reference to the character at index i.
Definition: qcstring.h:477
TextStream
Text streaming class that buffers data.
Definition: textstream.h:33
Definition::briefLine
virtual int briefLine() const =0
Definition::getLanguage
virtual SrcLangExt getLanguage() const =0
Returns the programming language this definition was written in.
mainPageHasTitle
bool mainPageHasTitle()
Definition: util.cpp:7027
FTVNode::file
QCString file
Definition: ftvhelp.cpp:81
generateJSTree
static bool generateJSTree(NavIndexEntryList &navIndex, TextStream &t, const std::vector< FTVNode * > &nl, int level, bool &first)
Definition: ftvhelp.cpp:563
addHtmlExtensionIfMissing
QCString addHtmlExtensionIfMissing(const QCString &fName)
Definition: util.cpp:5275
fileVisibleInIndex
bool fileVisibleInIndex(const FileDef *fd, bool &genSourceFile)
Definition: util.cpp:6712
Definition::TypeFile
@ TypeFile
Definition: definition.h:88
FTVNode::anchor
QCString anchor
Definition: ftvhelp.cpp:82
FTVNode::ref
QCString ref
Definition: ftvhelp.cpp:80
theTranslator
Translator * theTranslator
Definition: language.cpp:156
JAVASCRIPT_LICENSE_TEXT
const char * JAVASCRIPT_LICENSE_TEXT
Definition: ftvhelp.cpp:42
FTVNode::name
QCString name
Definition: ftvhelp.cpp:83
validatingParseDoc
DocRoot * validatingParseDoc(IDocParser &parserIntf, const QCString &fileName, int startLine, const Definition *ctx, const MemberDef *md, const QCString &input, bool indexWords, bool isExample, const QCString &exampleName, bool singleLine, bool linkFromIndex, bool markdownSupport)
Definition: docparser.cpp:7495
FTVNode::index
int index
Definition: ftvhelp.cpp:84
NavIndexEntry::url
QCString url
Definition: ftvhelp.cpp:513
Definition::briefDescription
virtual QCString briefDescription(bool abbreviate=FALSE) const =0
TRUE
#define TRUE
Definition: qcstring.h:36
Definition::getOutputFileBase
virtual QCString getOutputFileBase() const =0
ClassDef::Struct
@ Struct
Definition: classdef.h:108
HtmlCodeGenerator
Definition: htmlgen.h:21
QCString::fill
bool fill(char c, int len=-1)
Fills a string with a predefined character
Definition: qcstring.h:175
Definition::definitionType
virtual DefType definitionType() const =0
Definition::briefFile
virtual QCString briefFile() const =0
ClassDef::compoundType
virtual CompoundType compoundType() const =0
Returns the type of compound this is, i.e.
QCString::setNum
QCString & setNum(short n)
Definition: qcstring.h:372
node2URL
static QCString node2URL(const FTVNode *n, bool overruleFile=FALSE, bool srcLink=FALSE)
Definition: ftvhelp.cpp:239
QCString::mid
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition: qcstring.h:224
substitute
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
Definition: qcstring.cpp:465
Config_getBool
#define Config_getBool(name)
Definition: config.h:33
Doxygen::htmlFileExtension
static QCString htmlFileExtension
Definition: doxygen.h:103
LayoutDocManager::instance
static LayoutDocManager & instance()
Returns a reference to this singleton.
Definition: layout.cpp:1574
Translator::trPanelSynchronisationTooltip
virtual QCString trPanelSynchronisationTooltip(bool enable)=0
Config_getString
#define Config_getString(name)
Definition: config.h:32
FileDef
A model of a file symbol.
Definition: filedef.h:73
LayoutNavEntry::title
QCString title() const
Definition: layout.h:172
convertToJSString
QCString convertToJSString(const QCString &s)
Definition: util.cpp:4123
toFileDef
FileDef * toFileDef(Definition *d)
Definition: filedef.cpp:1778
FTVNode::def
const Definition * def
Definition: ftvhelp.cpp:89
NavIndexEntry
Definition: ftvhelp.cpp:510
externalRef
QCString externalRef(const QCString &relPath, const QCString &ref, bool href)
Definition: util.cpp:6334
ClassDef::Exception
@ Exception
Definition: classdef.h:113
FileDef::getOutputFileBase
virtual QCString getOutputFileBase() const =0
LayoutNavEntry::MainPage
@ MainPage
Definition: layout.h:130
convertFileId2Var
static QCString convertFileId2Var(const QCString &fileId)
Definition: ftvhelp.cpp:555
createDocParser
std::unique_ptr< IDocParser > createDocParser()
Definition: docparser.cpp:179
FALSE
#define FALSE
Definition: qcstring.h:33
SrcLangExt_Slice
@ SrcLangExt_Slice
Definition: types.h:59
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108