コード例 #1
0
ファイル: ftvhelp.cpp プロジェクト: LianYangCn/doxygen
static void generateJSNavTree(const QList<FTVNode> &nodeList)
{
    QCString htmlOutput = Config_getString("HTML_OUTPUT");
    QFile f(htmlOutput+"/navtreedata.js");
    NavIndexEntryList navIndex;
    if (f.open(IO_WriteOnly) /*&& fidx.open(IO_WriteOnly)*/)
    {
        //FTextStream tidx(&fidx);
        //tidx << "var NAVTREEINDEX =" << endl;
        //tidx << "{" << endl;
        FTextStream t(&f);
        t << "var NAVTREE =" << endl;
        t << "[" << endl;
        t << "  [ ";
        QCString &projName = Config_getString("PROJECT_NAME");
        if (projName.isEmpty())
        {
            if (Doxygen::mainPage && !Doxygen::mainPage->title().isEmpty()) // Use title of main page as root
            {
                t << "\"" << convertToJSString(Doxygen::mainPage->title()) << "\", ";
            }
            else // Use default section title as root
            {
                LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::MainPage);
                t << "\"" << convertToJSString(lne->title()) << "\", ";
            }
        }
        else // use PROJECT_NAME as root tree element
        {
            t << "\"" << convertToJSString(projName) << "\", ";
        }
        t << "\"index" << Doxygen::htmlFileExtension << "\", ";

        // add special entry for index page
        navIndex.append(new NavIndexEntry("index"+Doxygen::htmlFileExtension,""));
        // related page index is written as a child of index.html, so add this as well
        navIndex.append(new NavIndexEntry("pages"+Doxygen::htmlFileExtension,""));

        bool first=TRUE;
        generateJSTree(navIndex,t,nodeList,1,first);

        if (first)
            t << "]" << endl;
        else
            t << endl << "  ] ]" << endl;
        t << "];" << endl << endl;

        // write the navigation index (and sub-indices)
        navIndex.sort();
        int subIndex=0;
        int elemCount=0;
        const int maxElemCount=250;
        //QFile fidx(htmlOutput+"/navtreeindex.js");
        QFile fsidx(htmlOutput+"/navtreeindex0.js");
        if (/*fidx.open(IO_WriteOnly) &&*/ fsidx.open(IO_WriteOnly))
        {
            //FTextStream tidx(&fidx);
            FTextStream tsidx(&fsidx);
            t << "var NAVTREEINDEX =" << endl;
            t << "[" << endl;
            tsidx << "var NAVTREEINDEX" << subIndex << " =" << endl;
            tsidx << "{" << endl;
            QListIterator<NavIndexEntry> li(navIndex);
            NavIndexEntry *e;
            bool first=TRUE;
            for (li.toFirst(); (e=li.current());) // for each entry
            {
                if (elemCount==0)
                {
                    if (!first)
                    {
                        t << "," << endl;
                    }
                    else
                    {
                        first=FALSE;
                    }
                    t << "\"" << e->url << "\"";
                }
                tsidx << "\"" << e->url << "\":[" << e->path << "]";
                ++li;
                if (li.current() && elemCount<maxElemCount-1) tsidx << ","; // not last entry
                tsidx << endl;

                elemCount++;
                if (li.current() && elemCount>=maxElemCount) // switch to new sub-index
                {
                    tsidx << "};" << endl;
                    elemCount=0;
                    fsidx.close();
                    subIndex++;
                    fsidx.setName(htmlOutput+"/navtreeindex"+QCString().setNum(subIndex)+".js");
                    if (!fsidx.open(IO_WriteOnly)) break;
                    tsidx.setDevice(&fsidx);
                    tsidx << "var NAVTREEINDEX" << subIndex << " =" << endl;
                    tsidx << "{" << endl;
                }
            }
            tsidx << "};" << endl;
            t << endl << "];" << endl;
        }
        t << endl << "var SYNCONMSG = '"  << theTranslator->trPanelSynchronisationTooltip(FALSE) << "';";
        t << endl << "var SYNCOFFMSG = '" << theTranslator->trPanelSynchronisationTooltip(TRUE)  << "';";
    }
    ResourceMgr::instance().copyResource("navtree.js",htmlOutput);
}
コード例 #2
0
ファイル: ftvhelp.cpp プロジェクト: LianYangCn/doxygen
static bool generateJSTree(NavIndexEntryList &navIndex,FTextStream &t,
                           const QList<FTVNode> &nl,int level,bool &first)
{
    static QCString htmlOutput = Config_getString("HTML_OUTPUT");
    QCString indentStr;
    indentStr.fill(' ',level*2);
    bool found=FALSE;
    QListIterator<FTVNode> nli(nl);
    FTVNode *n;
    for (nli.toFirst(); (n=nli.current()); ++nli)
    {
        // terminate previous entry
        if (!first) t << "," << endl;
        first=FALSE;

        // start entry
        if (!found)
        {
            t << "[" << endl;
        }
        found=TRUE;

        if (n->addToNavIndex) // add entry to the navigation index
        {
            if (n->def && n->def->definitionType()==Definition::TypeFile)
            {
                FileDef *fd = (FileDef*)n->def;
                bool doc,src;
                doc = fileVisibleInIndex(fd,src);
                if (doc)
                {
                    navIndex.append(new NavIndexEntry(node2URL(n,TRUE,FALSE),pathToNode(n,n)));
                }
                if (src)
                {
                    navIndex.append(new NavIndexEntry(node2URL(n,TRUE,TRUE),pathToNode(n,n)));
                }
            }
            else
            {
                navIndex.append(new NavIndexEntry(node2URL(n),pathToNode(n,n)));
            }
        }

        if (n->separateIndex) // store items in a separate file for dynamic loading
        {
            bool firstChild=TRUE;
            t << indentStr << "  [ ";
            generateJSLink(t,n);
            if (n->children.count()>0) // write children to separate file for dynamic loading
            {
                QCString fileId = n->file;
                if (n->anchor)
                {
                    fileId+="_"+n->anchor;
                }
                if (dupOfParent(n))
                {
                    fileId+="_dup";
                }
                QFile f(htmlOutput+"/"+fileId+".js");
                if (f.open(IO_WriteOnly))
                {
                    FTextStream tt(&f);
                    tt << "var " << convertFileId2Var(fileId) << " =" << endl;
                    generateJSTree(navIndex,tt,n->children,1,firstChild);
                    tt << endl << "];";
                }
                t << "\"" << fileId << "\" ]";
            }
            else // no children
            {
                t << "null ]";
            }
        }
        else // show items in this file
        {
            bool firstChild=TRUE;
            t << indentStr << "  [ ";
            generateJSLink(t,n);
            bool emptySection = !generateJSTree(navIndex,t,n->children,level+1,firstChild);
            if (emptySection)
                t << "null ]";
            else
                t << endl << indentStr << "  ] ]";
        }
    }
    return found;
}
コード例 #3
0
static bool generateJSTree(SortedList<NavIndexEntry *> &navIndex, QTextStream &t, const QList<FTVNode *> &nl, int level, bool &omitComma)
{
   static QString htmlOutput   = Config::getString("html-output");   
   static QString mainPageName = Config::getFullName(Config::getString("main-page-name")); 
   static bool mainPageOmit    = Config::getBool("main-page-omit"); 

   QString indentStr;
   indentStr.fill(' ', level * 2);

   bool found = false;

   for (auto node : nl)  {
      // terminate previous entry

      if (! omitComma) {
         t << "," << endl;
      }
      omitComma = false;

      // start entry
      if (! found) {
         t << "[" << endl;
      }
      found = true;

      if (node->addToNavIndex) { 
         // add entry to the navigation index

         if (node->def && node->def->definitionType() == Definition::TypeFile) {            
            QSharedPointer<FileDef> fd = node->def.dynamicCast<FileDef>();
  
            if (! mainPageName.isEmpty() && fd->getFilePath() == mainPageName) {       
               // do not add this file to the navIndex, for \files

            } else {  
                                   
               if (docFileVisibleInIndex(fd)) {
                  navIndex.inSort(new NavIndexEntry(node2URL(node, true, false), pathToNode(node)));
               }
   
               if (srcFileVisibleInIndex(fd)) {
                  navIndex.inSort(new NavIndexEntry(node2URL(node, true, true), pathToNode(node)));
               }
            }

         } else { 
                
            if (mainPageOmit && node->def == Doxy_Globals::mainPage) { 
               // do not add this file to the navIndex 
             
            } else {
               navIndex.inSort(new NavIndexEntry(node2URL(node), pathToNode(node)));
            }
         }
      }

      if (node->separateIndex) { 
         // store some items in a separate file (annotated, modules, namespaces, files)
         bool firstChild   = true;
         bool showMainPage = true;

         if (node->def && node->def->definitionType() == Definition::TypeFile) {            
            QSharedPointer<FileDef> fd = node->def.dynamicCast<FileDef>();

            if (! mainPageName.isEmpty() && fd->getFilePath() == mainPageName) {   
               // do not add this file to the navIndex, for \files

               showMainPage = false;
               omitComma    = true;
            }

         } else { 
                
            if (mainPageOmit && node->def == Doxy_Globals::mainPage) { 
               // do not add this file to the navIndex 

               showMainPage = false;
               omitComma    = true;
            }
         }

         if (showMainPage) {         
            t << indentStr << "  [ ";
            generateJSLink(t, node);
   
            if (node->children.count() > 0) { 
               // write children to separate file for dynamic loading
               QString fileId = node->file;
   
               if (! node->anchor.isEmpty()) {
                  fileId += "_" + node->anchor;
               }
   
               if (dupOfParent(node)) {
                  fileId += "_dup";
               }
   
               QFile fi(htmlOutput + "/" + fileId + ".js");
   
               if (fi.open(QIODevice::WriteOnly)) {
                  QTextStream tt(&fi);
   
                  tt << "var " << convertFileId2Var(fileId) << " =" << endl;
                  generateJSTree(navIndex, tt, node->children, 1, firstChild);
                  tt << endl << "];";
               }
   
               t << "\"" << fileId << "\" ]";            

            } else { 
               // no children
               t << "null ]";
            }
         }

      } else {
         bool firstChild = true;

         if (mainPageOmit && node->def == Doxy_Globals::mainPage) { 
            // omit treeview entries for index page
            omitComma = true;

         } else  {
            t << indentStr << "  [ ";
            generateJSLink(t, node);
   
            bool emptySection = ! generateJSTree(navIndex, t, node->children, level + 1, firstChild);
   
            if (emptySection) {
               t << "null ]";
            } else {
               t << endl << indentStr << "  ] ]";
            }
         }
      }
   }

   return found;
}
コード例 #4
0
static void generateJSNavTree(QList<FTVNode *> &nodeList)
{
   QString htmlOutput = Config::getString("html-output");

   // new JS  
   QFile f(htmlOutput + "/navtreedata.js");
   SortedList<NavIndexEntry *> navIndex;

   if (f.open(QIODevice::WriteOnly)) {
   
      QTextStream t(&f);
      t << "var NAVTREE =" << endl;
      t << "[" << endl;
      t << "  [ ";

      QString projName = Config::getString("project-name");

      if (projName.isEmpty()) {
         if (Doxy_Globals::mainPage && ! Doxy_Globals::mainPage->title().isEmpty()) { 
            // use title of main page as root
            t << "\"" << convertToJSString(Doxy_Globals::mainPage->title()) << "\", ";

         } else { 
            // use default section title as root
            LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::MainPage);
            t << "\"" << convertToJSString(lne->title()) << "\", ";
         }

      } else { 
         // use PROJECT_NAME as root tree element
         t << "\"" << convertToJSString(projName) << "\", ";
      }

      t << "\"index" << Doxy_Globals::htmlFileExtension << "\", ";

      // add special entry for index page
      navIndex.inSort(new NavIndexEntry("index" + Doxy_Globals::htmlFileExtension, ""));

      // related page index, written as a child of index.html
      navIndex.inSort(new NavIndexEntry("pages" + Doxy_Globals::htmlFileExtension, ""));

      // adjust for display output     
      reSortNodes(nodeList);

      bool omitComma = true;
      generateJSTree(navIndex, t, nodeList, 1, omitComma);

      if (omitComma) {
         t << "]" << endl;
      } else {
         t << endl << "  ] ]" << endl;
      }

      t << "];" << endl << endl;
 
      int subIndex  = 0;
      int elemCount = 0;
      const int maxElemCount = 250;

      // new JS     
      QFile fsidx(htmlOutput + "/navtreeindex0.js");

      if (fsidx.open(QIODevice::WriteOnly)) {
         
         QTextStream tsidx(&fsidx);

         t << "var NAVTREEINDEX =" << endl;
         t << "[" << endl;

         tsidx << "var NAVTREEINDEX" << subIndex << " =" << endl;
         tsidx << "{" << endl;

         omitComma = true;     

         auto nextItem  = navIndex.begin();

         for (auto e : navIndex)  {
            // for each entry
            ++nextItem;

            if (elemCount == 0) {
               if (! omitComma) {
                  t << "," << endl;

               } else {
                  omitComma = false;
               }

               t << "\"" << e->m_url << "\"";
            }

            tsidx << "\"" << e->m_url << "\":[" << e->m_indexId << "]";
            
            if (nextItem != navIndex.end() && elemCount < maxElemCount - 1) {
               // not the last entry
               tsidx << ",";   
            }

            tsidx << endl;

            elemCount++;

            if (nextItem != navIndex.end() && elemCount >= maxElemCount) {           
               // switch to new sub-index
               tsidx << "};" << endl;

               elemCount = 0;
               fsidx.close();

               subIndex++;

               fsidx.setFileName(htmlOutput + "/navtreeindex" + QString::number(subIndex) + ".js");

               if (! fsidx.open(QIODevice::WriteOnly)) {
                  break;
               }

               tsidx.setDevice(&fsidx);
               tsidx << "var NAVTREEINDEX" << subIndex << " =" << endl;
               tsidx << "{" << endl;
            }
         }

         tsidx << "};" << endl;
         t << endl << "];" << endl;
      }

      t << endl << "var SYNCONMSG = '"  << theTranslator->trPanelSyncTooltip(false) << "';";
      t << endl << "var SYNCOFFMSG = '" << theTranslator->trPanelSyncTooltip(true)  << "';";
   }

   ResourceMgr::instance().copyResourceAs("html/navtree.js", htmlOutput, "navtree.js");
}
コード例 #5
0
ファイル: ftvhelp.cpp プロジェクト: wtschueller/doxygen
static void generateJSNavTree(const QList<FTVNode> &nodeList)
{
  QCString htmlOutput = Config_getString(HTML_OUTPUT);
  QFile f(htmlOutput+"/navtreedata.js");
  NavIndexEntryList navIndex;
  if (f.open(IO_WriteOnly) /*&& fidx.open(IO_WriteOnly)*/)
  {
    //FTextStream tidx(&fidx);
    //tidx << "var NAVTREEINDEX =" << endl;
    //tidx << "{" << endl;
    FTextStream t(&f);
		t << "/*\n@ @licstart  The following is the entire license notice for the\n"
			"JavaScript code in this file.\n\nCopyright (C) 1997-2017 by Dimitri van Heesch\n\n"
			"This program is free software; you can redistribute it and/or modify\n"
			"it under the terms of the GNU General Public License as published by\n"
			"the Free Software Foundation; either version 2 of the License, or\n"
			"(at your option) any later version.\n\n"
			"This program is distributed in the hope that it will be useful,\n"
			"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
			" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
			" GNU General Public License for more details.\n\n"
			"You should have received a copy of the GNU General Public License along\n"
			"with this program; if not, write to the Free Software Foundation, Inc.,\n"
			"51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n\n"
			"@licend  The above is the entire license notice\n"
			"for the JavaScript code in this file\n"
			"*/\n";
    t << "var NAVTREE =" << endl;
    t << "[" << endl;
    t << "  [ ";
    QCString &projName = Config_getString(PROJECT_NAME);
    if (projName.isEmpty())
    {
      if (Doxygen::mainPage && !Doxygen::mainPage->title().isEmpty()) // Use title of main page as root
      {
        t << "\"" << convertToJSString(Doxygen::mainPage->title()) << "\", ";
      }
      else // Use default section title as root
      {
        LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::MainPage);
        t << "\"" << convertToJSString(lne->title()) << "\", ";
      }
    }
    else // use PROJECT_NAME as root tree element
    {
      t << "\"" << convertToJSString(projName) << "\", ";
    }
    t << "\"index" << Doxygen::htmlFileExtension << "\", ";

    // add special entry for index page
    navIndex.append(new NavIndexEntry("index"+Doxygen::htmlFileExtension,""));
    // related page index is written as a child of index.html, so add this as well
    navIndex.append(new NavIndexEntry("pages"+Doxygen::htmlFileExtension,""));

    bool first=TRUE;
    generateJSTree(navIndex,t,nodeList,1,first);

    if (first)
      t << "]" << endl;
    else
      t << endl << "  ] ]" << endl;
    t << "];" << endl << endl;

    // write the navigation index (and sub-indices)
    navIndex.sort();
    int subIndex=0;
    int elemCount=0;
    const int maxElemCount=250;
    //QFile fidx(htmlOutput+"/navtreeindex.js");
    QFile fsidx(htmlOutput+"/navtreeindex0.js");
    if (/*fidx.open(IO_WriteOnly) &&*/ fsidx.open(IO_WriteOnly))
    {
      //FTextStream tidx(&fidx);
      FTextStream tsidx(&fsidx);
      t << "var NAVTREEINDEX =" << endl;
      t << "[" << endl;
      tsidx << "var NAVTREEINDEX" << subIndex << " =" << endl;
      tsidx << "{" << endl;
      QListIterator<NavIndexEntry> li(navIndex);
      NavIndexEntry *e;
      bool first=TRUE;
      for (li.toFirst();(e=li.current());) // for each entry
      {
        if (elemCount==0)
        {
          if (!first)
          {
            t << "," << endl;
          }
          else
          {
            first=FALSE;
          }
          t << "\"" << e->url << "\"";
        }
        tsidx << "\"" << e->url << "\":[" << e->path << "]";
        ++li;
        if (li.current() && elemCount<maxElemCount-1) tsidx << ","; // not last entry
        tsidx << endl;

        elemCount++;
        if (li.current() && elemCount>=maxElemCount) // switch to new sub-index
        {
          tsidx << "};" << endl;
          elemCount=0;
          fsidx.close();
          subIndex++;
          fsidx.setName(htmlOutput+"/navtreeindex"+QCString().setNum(subIndex)+".js");
          if (!fsidx.open(IO_WriteOnly)) break;
          tsidx.setDevice(&fsidx);
          tsidx << "var NAVTREEINDEX" << subIndex << " =" << endl;
          tsidx << "{" << endl;
        }
      }
      tsidx << "};" << endl;
      t << endl << "];" << endl;
    }
    t << endl << "var SYNCONMSG = '"  << theTranslator->trPanelSynchronisationTooltip(FALSE) << "';";
    t << endl << "var SYNCOFFMSG = '" << theTranslator->trPanelSynchronisationTooltip(TRUE)  << "';";
  }
  ResourceMgr::instance().copyResource("navtree.js",htmlOutput);
}