Doxygen
reflist.cpp
浏览该文件的文档.
1 /******************************************************************************
2  *
3  * Copyright (C) 1997-2020 by Dimitri van Heesch.
4  *
5  * Permission to use, copy, modify, and distribute this software and its
6  * documentation under the terms of the GNU General Public License is hereby
7  * granted. No representations are made about the suitability of this software
8  * for any purpose. It is provided "as is" without express or implied warranty.
9  * See the GNU General Public License for more details.
10  *
11  * Documents produced by Doxygen are derivative works derived from the
12  * input used in their production; they are not affected by this license.
13  *
14  */
15 
16 #include <algorithm>
17 #include <stdio.h>
18 
19 #include "reflist.h"
20 #include "util.h"
21 #include "definition.h"
22 #include "config.h"
23 
24 RefList::RefList(const QCString &listName, const QCString &pageTitle, const QCString &secTitle) :
25  m_listName(listName), m_fileName(convertNameToFile(listName,FALSE,TRUE)),
26  m_pageTitle(pageTitle), m_secTitle(secTitle)
27 {
28 }
29 
31 {
32  m_id++;
33  std::unique_ptr<RefItem> item = std::make_unique<RefItem>(m_id,this);
34  RefItem *result = item.get();
35  m_entries.push_back(std::move(item));
36  m_lookup.insert({m_id,result});
37  return result;
38 }
39 
40 RefItem *RefList::find(int itemId)
41 {
42  auto it = m_lookup.find(itemId);
43  return it!=m_lookup.end() ? it->second : nullptr;
44 }
45 
46 bool RefList::isEnabled() const
47 {
48  if (m_listName=="todo" && !Config_getBool(GENERATE_TODOLIST)) return false;
49  else if (m_listName=="test" && !Config_getBool(GENERATE_TESTLIST)) return false;
50  else if (m_listName=="bug" && !Config_getBool(GENERATE_BUGLIST)) return false;
51  else if (m_listName=="deprecated" && !Config_getBool(GENERATE_DEPRECATEDLIST)) return false;
52  return true;
53 }
54 
56 {
57  if (!isEnabled()) return;
58 
59  std::sort(m_entries.begin(),m_entries.end(),
60  [](std::unique_ptr<RefItem> &left,std::unique_ptr<RefItem> &right)
61  { return qstricmp(left->title(),right->title()) < 0; });
62  //RefItem *item;
63  QCString doc;
64  int cnt = 0;
65  doc += "<dl class=\"reflist\">";
66  QCString lastGroup;
67  bool first=true;
68  for (const std::unique_ptr<RefItem> &item : m_entries)
69  {
70  if (item->name().isEmpty()) continue;
71  cnt++;
72  bool startNewGroup = item->group()!=lastGroup;
73  if (startNewGroup)
74  {
75  if (!first)
76  {
77  doc += "</dd>";
78  }
79  first=false;
80  doc += " <dt>";
81  doc += "\n";
82  if (item->scope())
83  {
84  if (item->scope()->name() != "<globalScope>")
85  {
86  doc += "\\_setscope ";
87  doc += item->scope()->name();
88  doc += " ";
89  }
90  }
91  doc += item->prefix();
92  doc += " \\_internalref ";
93  doc += item->name();
94  // escape \'s in title, see issue #5901
95  QCString escapedTitle = substitute(item->title(),"\\","\\\\");
96  doc += " \""+escapedTitle+"\" ";
97  // write declaration in case a function with arguments
98  if (!item->args().isEmpty())
99  {
100  // escape @'s in argument list, needed for Java annotations (see issue #6208)
101  // escape \'s in argument list (see issue #6533)
102  doc += substitute(substitute(item->args(),"@","@@"),"\\","\\\\");
103  }
104  doc += "</dt><dd>";
105  }
106  else
107  {
108  doc += "<p>";
109  }
110  doc += " \\anchor ";
111  doc += item->anchor();
112  doc += " ";
113  doc += item->text();
114  lastGroup = item->group();
115  first = false;
116  }
117  if (!first)
118  {
119  doc += "</dd>";
120  }
121  doc += "</dl>\n";
122  //printf("generatePage('%s')\n",doc.data());
123  if (cnt>0)
124  {
126  }
127 }
RefList::m_id
int m_id
Definition: reflist.h:108
addRelatedPage
static void addRelatedPage(Entry *root)
Definition: doxygen.cpp:303
RefItem
This struct represents an item in the list of references.
Definition: reflist.h:30
RefList::add
RefItem * add()
Definition: reflist.cpp:30
RefList::RefList
RefList(const QCString &listName, const QCString &pageTitle, const QCString &secTitle)
Definition: reflist.cpp:24
RefList::generatePage
void generatePage()
Definition: reflist.cpp:55
RefList::m_entries
std::vector< std::unique_ptr< RefItem > > m_entries
Definition: reflist.h:113
RefList::find
RefItem * find(int itemId)
Definition: reflist.cpp:40
TRUE
#define TRUE
Definition: qcstring.h:36
reflist.h
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
RefItemVector
std::vector< RefItem * > RefItemVector
Definition: reflist.h:132
RefList::m_listName
QCString m_listName
Definition: reflist.h:109
RefList::m_fileName
QCString m_fileName
Definition: reflist.h:110
Config_getBool
#define Config_getBool(name)
Definition: config.h:33
definition.h
RefList::m_lookup
std::unordered_map< int, RefItem * > m_lookup
Definition: reflist.h:114
RefList::isEnabled
bool isEnabled() const
Definition: reflist.cpp:46
convertNameToFile
QCString convertNameToFile(const QCString &name, bool allowDots, bool allowUnderscore)
Definition: util.cpp:3604
config.h
RefList::m_pageTitle
QCString m_pageTitle
Definition: reflist.h:111
util.h
A bunch of utility functions.
FALSE
#define FALSE
Definition: qcstring.h:33
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108