Skip to main content

The htmldocvisitor.cpp File Reference

Included Headers

#include "htmldocvisitor.h" #include "docparser.h" #include "language.h" #include "doxygen.h" #include "outputgen.h" #include "outputlist.h" #include "dot.h" #include "message.h" #include "config.h" #include "htmlgen.h" #include "parserintf.h" #include "msc.h" #include "dia.h" #include "util.h" #include "vhdldocgen.h" #include "filedef.h" #include "memberdef.h" #include "htmlentity.h" #include "emoji.h" #include "plantuml.h" #include "formula.h" #include "fileinfo.h" #include "indexlist.h" #include "growbuf.h" #include "portable.h" #include "codefragment.h" #include "cite.h"

Enumerations Index

enum classcontexts_t { ... }

Functions Index

static constexpr const char *contexts (contexts_t type)
static QCStringconvertIndexWordToAnchor (const QCString &word)
static boolmustBeOutsideParagraph (const DocNodeVariant &n)
static boolisDocVerbatimVisible (const DocVerbatim &s)
static boolisDocIncludeVisible (const DocInclude &s)
static boolisDocIncOperatorVisible (const DocIncOperator &s)
static boolisInvisibleNode (const DocNodeVariant &node)
static QCStringmakeShortName (const QCString &name)
static QCStringmakeBaseName (const QCString &name)
template <class Node>
static boolholds_value (const Node *val, const DocNodeVariant &v)
template <class T>
boolisFirstChildNode (const T *parent, const DocPara &node)
template <class T>
boolisLastChildNode (const T *parent, const DocPara &node)
boolisSeparatedParagraph (const DocSimpleSect &parent, const DocPara &par)
static contexts_tgetParagraphContext (const DocPara &p, bool &isFirst, bool &isLast)
static booldetermineIfNeedsTag (const DocPara &p)
static boolinsideStyleChangeThatIsOutsideParagraph (const DocPara *para, DocNodeList::const_iterator it)

Returns TRUE if the child nodes in paragraph para until nodeIndex contain a style change node that is still active and that style change is one that must be located outside of a paragraph, i.e. More...

Variables Index

static const intNUM_HTML_LIST_TYPES = 4
static const charg_types[][NUM_HTML_LIST_TYPES] = {"1", "a", "i", "A"}
static const char *hex ="0123456789ABCDEF"

Enumerations

contexts_t

enum class contexts_t
strong
Enumeration values
NONE
STARTLI
STARTDD
ENDLI
ENDDD
STARTTD
ENDTD
INTERLI
INTERDD
INTERTD

Definition at line 46 of file htmldocvisitor.cpp.

47{
48 NONE, // 0
49 STARTLI, // 1
50 STARTDD, // 2
51 ENDLI, // 3
52 ENDDD, // 4
53 STARTTD, // 5
54 ENDTD, // 6
55 INTERLI, // 7
56 INTERDD, // 8
57 INTERTD // 9
58};

Functions

contexts()

constexpr const char * contexts (contexts_t type)
constexpr static

Definition at line 60 of file htmldocvisitor.cpp.

60static constexpr const char *contexts(contexts_t type)
61{
62 switch (type)
63 {
64 case contexts_t::NONE: return nullptr;
65 case contexts_t::STARTLI: return "startli";
66 case contexts_t::STARTDD: return "startdd";
67 case contexts_t::ENDLI: return "endli";
68 case contexts_t::ENDDD: return "enddd";
69 case contexts_t::STARTTD: return "starttd";
70 case contexts_t::ENDTD: return "endtd";
71 case contexts_t::INTERLI: return "interli";
72 case contexts_t::INTERDD: return "interdd";
73 case contexts_t::INTERTD: return "intertd";
74 default: return nullptr;
75 }
76}

References ENDDD, ENDLI, ENDTD, INTERDD, INTERLI, INTERTD, NONE, STARTDD, STARTLI and STARTTD.

Referenced by HtmlDocVisitor::operator().

convertIndexWordToAnchor()

QCString convertIndexWordToAnchor (const QCString & word)
static

Definition at line 79 of file htmldocvisitor.cpp.

80{
81 static int cnt = 0;
82 QCString result="a";
83 QCString cntStr;
84 result += cntStr.setNum(cnt);
85 result += "_";
86 cnt++;
87 const char *str = word.data();
88 unsigned char c = 0;
89 if (str)
90 {
91 while ((c = *str++))
92 {
93 if ((c >= 'a' && c <= 'z') || // ALPHA
94 (c >= 'A' && c <= 'Z') || // ALPHA
95 (c >= '0' && c <= '9') || // DIGIT
96 c == '-' ||
97 c == '.'
98 )
99 {
100 result += c;
101 }
102 else
103 {
104 char enc[4];
105 enc[0] = '_';
106 enc[1] = hex[(c & 0xf0) >> 4];
107 enc[2] = hex[c & 0xf];
108 enc[3] = 0;
109 result += enc;
110 }
111 }
112 }
113 return result;
114}

References QCString::data, hex and QCString::setNum.

Referenced by HtmlDocVisitor::operator().

determineIfNeedsTag()

bool determineIfNeedsTag (const DocPara & p)
static

Definition at line 1262 of file htmldocvisitor.cpp.

1262static bool determineIfNeedsTag(const DocPara &p)
1263{
1264 bool needsTag = FALSE;
1265 if (p.parent())
1266 {
1280 >(*p.parent()))
1281 {
1282 needsTag = TRUE;
1283 }
1284 else if (std::get_if<DocRoot>(p.parent()))
1285 {
1286 needsTag = !std::get<DocRoot>(*p.parent()).singleLine();
1287 }
1288 }
1289 return needsTag;
1290}

References FALSE, holds_one_of_alternatives, DocNode::parent and TRUE.

Referenced by HtmlDocVisitor::operator().

getParagraphContext()

contexts_t getParagraphContext (const DocPara & p, bool & isFirst, bool & isLast)
static

Definition at line 1130 of file htmldocvisitor.cpp.

1130static contexts_t getParagraphContext(const DocPara &p,bool &isFirst,bool &isLast)
1131{
1133 isFirst=FALSE;
1134 isLast=FALSE;
1135 if (p.parent())
1136 {
1137 const auto parBlock = std::get_if<DocParBlock>(p.parent());
1138 if (parBlock)
1139 {
1140 // hierarchy: node N -> para -> parblock -> para
1141 // adapt return value to kind of N
1142 const DocNodeVariant *p3 = nullptr;
1143 if (::parent(p.parent()) && ::parent(::parent(p.parent())) )
1144 {
1145 p3 = ::parent(::parent(p.parent()));
1146 }
1147 isFirst=isFirstChildNode(parBlock,p);
1148 isLast =isLastChildNode (parBlock,p);
1149 bool isLI = p3!=nullptr && holds_one_of_alternatives<DocHtmlListItem,DocSecRefItem>(*p3);
1151 bool isTD = p3!=nullptr && holds_one_of_alternatives<DocHtmlCell,DocParamList>(*p3);
1153 if (isFirst)
1154 {
1155 if (isLI) t=contexts_t::STARTLI; else if (isDD) t=contexts_t::STARTDD; else if (isTD) t=contexts_t::STARTTD;
1156 }
1157 if (isLast)
1158 {
1159 if (isLI) t=contexts_t::ENDLI; else if (isDD) t=contexts_t::ENDDD; else if (isTD) t=contexts_t::ENDTD;
1160 }
1161 if (!isFirst && !isLast)
1162 {
1163 if (isLI) t=contexts_t::INTERLI; else if (isDD) t=contexts_t::INTERDD; else if (isTD) t=contexts_t::INTERTD;
1164 }
1165 return t;
1166 }
1167 const auto docAutoListItem = std::get_if<DocAutoListItem>(p.parent());
1168 if (docAutoListItem)
1169 {
1170 isFirst=isFirstChildNode(docAutoListItem,p);
1171 isLast =isLastChildNode (docAutoListItem,p);
1172 t=contexts_t::STARTLI; // not used
1173 return t;
1174 }
1175 const auto docSimpleListItem = std::get_if<DocSimpleListItem>(p.parent());
1176 if (docSimpleListItem)
1177 {
1178 isFirst=TRUE;
1179 isLast =TRUE;
1180 t=contexts_t::STARTLI; // not used
1181 return t;
1182 }
1183 const auto docParamList = std::get_if<DocParamList>(p.parent());
1184 if (docParamList)
1185 {
1186 isFirst=TRUE;
1187 isLast =TRUE;
1188 t=contexts_t::STARTLI; // not used
1189 return t;
1190 }
1191 const auto docHtmlListItem = std::get_if<DocHtmlListItem>(p.parent());
1192 if (docHtmlListItem)
1193 {
1194 isFirst=isFirstChildNode(docHtmlListItem,p);
1195 isLast =isLastChildNode (docHtmlListItem,p);
1196 if (isFirst) t=contexts_t::STARTLI;
1197 if (isLast) t=contexts_t::ENDLI;
1198 if (!isFirst && !isLast) t = contexts_t::INTERLI;
1199 return t;
1200 }
1201 const auto docSecRefItem = std::get_if<DocSecRefItem>(p.parent());
1202 if (docSecRefItem)
1203 {
1204 isFirst=isFirstChildNode(docSecRefItem,p);
1205 isLast =isLastChildNode (docSecRefItem,p);
1206 if (isFirst) t=contexts_t::STARTLI;
1207 if (isLast) t=contexts_t::ENDLI;
1208 if (!isFirst && !isLast) t = contexts_t::INTERLI;
1209 return t;
1210 }
1211 const auto docHtmlDescData = std::get_if<DocHtmlDescData>(p.parent());
1212 if (docHtmlDescData)
1213 {
1214 isFirst=isFirstChildNode(docHtmlDescData,p);
1215 isLast =isLastChildNode (docHtmlDescData,p);
1216 if (isFirst) t=contexts_t::STARTDD;
1217 if (isLast) t=contexts_t::ENDDD;
1218 if (!isFirst && !isLast) t = contexts_t::INTERDD;
1219 return t;
1220 }
1221 const auto docXRefItem = std::get_if<DocXRefItem>(p.parent());
1222 if (docXRefItem)
1223 {
1224 isFirst=isFirstChildNode(docXRefItem,p);
1225 isLast =isLastChildNode (docXRefItem,p);
1226 if (isFirst) t=contexts_t::STARTDD;
1227 if (isLast) t=contexts_t::ENDDD;
1228 if (!isFirst && !isLast) t = contexts_t::INTERDD;
1229 return t;
1230 }
1231 const auto docSimpleSect = std::get_if<DocSimpleSect>(p.parent());
1232 if (docSimpleSect)
1233 {
1234 isFirst=isFirstChildNode(docSimpleSect,p);
1235 isLast =isLastChildNode (docSimpleSect,p);
1236 if (isFirst) t=contexts_t::STARTDD;
1237 if (isLast) t=contexts_t::ENDDD;
1238 if (isSeparatedParagraph(*docSimpleSect,p))
1239 // if the paragraph is enclosed with separators it will
1240 // be included in <dd>..</dd> so avoid addition paragraph
1241 // markers
1242 {
1243 isFirst=isLast=TRUE;
1244 }
1245 if (!isFirst && !isLast) t = contexts_t::INTERDD;
1246 return t;
1247 }
1248 const auto docHtmlCell = std::get_if<DocHtmlCell>(p.parent());
1249 if (docHtmlCell)
1250 {
1251 isFirst=isFirstChildNode(docHtmlCell,p);
1252 isLast =isLastChildNode (docHtmlCell,p);
1253 if (isFirst) t=contexts_t::STARTTD;
1254 if (isLast) t=contexts_t::ENDTD;
1255 if (!isFirst && !isLast) t = contexts_t::INTERTD;
1256 return t;
1257 }
1258 }
1259 return t;
1260}

References ENDDD, ENDLI, ENDTD, FALSE, holds_one_of_alternatives, INTERDD, INTERLI, INTERTD, isFirstChildNode, isLastChildNode, isSeparatedParagraph, NONE, DocNode::parent, parent, STARTDD, STARTLI, STARTTD and TRUE.

Referenced by HtmlDocVisitor::forceEndParagraph, HtmlDocVisitor::forceStartParagraph and HtmlDocVisitor::operator().

holds_value()

template <class Node>
bool holds_value (const Node * val, const DocNodeVariant & v)
static

Definition at line 1086 of file htmldocvisitor.cpp.

1086static bool holds_value(const Node *val,const DocNodeVariant &v)
1087{
1088 bool b = std::visit([&](auto &&x) {
1089 //printf("holds_value val=%s (%p) v=%s (%p)\n",
1090 // docNodeName(*val),(void*)val,docNodeName(v),(void *)&x);
1091 return val==static_cast<const DocNode*>(&x);
1092 }, v);
1093 return b;
1094}

Referenced by HtmlDocVisitor::forceEndParagraph, HtmlDocVisitor::forceStartParagraph, isFirstChildNode, isLastChildNode and isSeparatedParagraph.

insideStyleChangeThatIsOutsideParagraph()

bool insideStyleChangeThatIsOutsideParagraph (const DocPara * para, DocNodeList::const_iterator it)
static

Returns TRUE if the child nodes in paragraph para until nodeIndex contain a style change node that is still active and that style change is one that must be located outside of a paragraph, i.e.

it is a center, div, or pre tag. See also bug746162.

Definition at line 2280 of file htmldocvisitor.cpp.

2282{
2283 //printf("insideStyleChangeThatIsOutputParagraph(index=%d)\n",nodeIndex);
2284 int styleMask=0;
2285 bool styleOutsideParagraph=FALSE;
2286 while (!styleOutsideParagraph)
2287 {
2288 const DocNodeVariant *n = &(*it);
2289 const DocStyleChange *sc = std::get_if<DocStyleChange>(n);
2290 if (sc)
2291 {
2292 if (!sc->enable()) // remember styles that has been closed already
2293 {
2294 styleMask|=static_cast<int>(sc->style());
2295 }
2296 bool paraStyle = sc->style()==DocStyleChange::Center ||
2297 sc->style()==DocStyleChange::Div ||
2299 //printf("Found style change %s enabled=%d\n",sc->styleString(),sc->enable());
2300 if (sc->enable() && (styleMask&static_cast<int>(sc->style()))==0 && // style change that is still active
2301 paraStyle
2302 )
2303 {
2304 styleOutsideParagraph=TRUE;
2305 }
2306 }
2307 if (it!=std::begin(para->children()))
2308 {
2309 --it;
2310 }
2311 else
2312 {
2313 break;
2314 }
2315 }
2316 return styleOutsideParagraph;
2317}

References DocStyleChange::Center, DocCompoundNode::children, DocStyleChange::Div, DocStyleChange::enable, FALSE, DocStyleChange::Preformatted, DocStyleChange::style and TRUE.

Referenced by HtmlDocVisitor::forceEndParagraph and HtmlDocVisitor::forceStartParagraph.

isDocIncludeVisible()

bool isDocIncludeVisible (const DocInclude & s)
static

isDocIncOperatorVisible()

bool isDocIncOperatorVisible (const DocIncOperator & s)
static

Definition at line 198 of file htmldocvisitor.cpp.

199{
200 switch (s.type())
201 {
203 return FALSE;
204 default:
205 return TRUE;
206 }
207}

References FALSE, DocIncOperator::Skip, TRUE and DocIncOperator::type.

Referenced by isInvisibleNode.

isDocVerbatimVisible()

bool isDocVerbatimVisible (const DocVerbatim & s)
static

Definition at line 167 of file htmldocvisitor.cpp.

167static bool isDocVerbatimVisible(const DocVerbatim &s)
168{
169 switch (s.type())
170 {
176 return FALSE;
177 default:
178 return TRUE;
179 }
180}

References DocVerbatim::DocbookOnly, FALSE, DocVerbatim::LatexOnly, DocVerbatim::ManOnly, DocVerbatim::RtfOnly, TRUE, DocVerbatim::type and DocVerbatim::XmlOnly.

Referenced by isInvisibleNode.

isFirstChildNode()

template <class T>
bool isFirstChildNode (const T * parent, const DocPara & node)

Definition at line 1097 of file htmldocvisitor.cpp.

1097bool isFirstChildNode(const T *parent, const DocPara &node)
1098{
1099 return !parent->children().empty() && holds_value(&node,parent->children().front());
1100}

References holds_value and parent.

Referenced by getParagraphContext.

isInvisibleNode()

bool isInvisibleNode (const DocNodeVariant & node)
static

Definition at line 209 of file htmldocvisitor.cpp.

209static bool isInvisibleNode(const DocNodeVariant &node)
210{
211 //printf("isInvisibleNode(%s)\n",docNodeName(node));
212 // skip over white space
213 const DocWhiteSpace *ws = std::get_if<DocWhiteSpace>(&node);
214 if (ws) return true;
215 // skip over image nodes that are not for HTML output
216 const DocImage *di = std::get_if<DocImage>(&node);
217 if (di) return di->type()!=DocImage::Html;
218 // skip over verbatim nodes that are not visible in the HTML output
219 const DocVerbatim *dv = std::get_if<DocVerbatim>(&node);
220 if (dv) return !isDocVerbatimVisible(*dv);
221 // skip over include nodes that are not visible in the HTML output
222 const DocInclude *dinc = std::get_if<DocInclude>(&node);
223 if (dinc) return !isDocIncludeVisible(*dinc);
224 const DocIncOperator *dio = std::get_if<DocIncOperator>(&node);
225 // skip over include operator nodes that are not visible in the HTML output
226 if (dio) return !isDocIncOperatorVisible(*dio);
227 return false;
228}

References DocImage::Html, isDocIncludeVisible, isDocIncOperatorVisible, isDocVerbatimVisible and DocImage::type.

Referenced by HtmlDocVisitor::forceEndParagraph, HtmlDocVisitor::forceStartParagraph and HtmlDocVisitor::operator().

isLastChildNode()

template <class T>
bool isLastChildNode (const T * parent, const DocPara & node)

Definition at line 1103 of file htmldocvisitor.cpp.

1103bool isLastChildNode(const T *parent, const DocPara &node)
1104{
1105 return !parent->children().empty() && holds_value(&node,parent->children().back());
1106}

References holds_value and parent.

Referenced by getParagraphContext.

isSeparatedParagraph()

bool isSeparatedParagraph (const DocSimpleSect & parent, const DocPara & par)

Definition at line 1108 of file htmldocvisitor.cpp.

1109{
1110 const DocNodeList &nodes = parent.children();
1111 auto it = std::find_if(std::begin(nodes),std::end(nodes),[&par](const auto &n) { return holds_value(&par,n); });
1112 if (it==std::end(nodes)) return FALSE;
1113 size_t count = parent.children().size();
1114 auto isSeparator = [](auto &&it_) { return std::get_if<DocSimpleSectSep>(&(*it_))!=nullptr; };
1115 if (count>1 && it==std::begin(nodes)) // it points to first node
1116 {
1117 return isSeparator(std::next(it));
1118 }
1119 else if (count>1 && it==std::prev(std::end(nodes))) // it points to last node
1120 {
1121 return isSeparator(std::prev(it));
1122 }
1123 else if (count>2 && it!=std::begin(nodes) && it!=std::prev(std::end(nodes))) // it points to intermediate node
1124 {
1125 return isSeparator(std::prev(it)) && isSeparator(std::next(it));
1126 }
1127 return false;
1128}

References FALSE, holds_value and parent.

Referenced by getParagraphContext.

makeBaseName()

QCString makeBaseName (const QCString & name)
static

Definition at line 241 of file htmldocvisitor.cpp.

241static QCString makeBaseName(const QCString &name)
242{
243 QCString baseName = makeShortName(name);
244 int i=baseName.find('.');
245 if (i!=-1)
246 {
247 baseName=baseName.left(i);
248 }
249 return baseName;
250}

References QCString::find, QCString::left and makeShortName.

makeShortName()

QCString makeShortName (const QCString & name)
static

Definition at line 230 of file htmldocvisitor.cpp.

230static QCString makeShortName(const QCString &name)
231{
232 QCString shortName = name;
233 int i = shortName.findRev('/');
234 if (i!=-1)
235 {
236 shortName=shortName.mid(i+1);
237 }
238 return shortName;
239}

References QCString::findRev and QCString::mid.

Referenced by makeBaseName.

mustBeOutsideParagraph()

bool mustBeOutsideParagraph (const DocNodeVariant & n)
static

Definition at line 118 of file htmldocvisitor.cpp.

119{
120 //printf("mustBeOutsideParagraph(%s)=",docNodeName(n));
123 /* <table> */ DocHtmlTable,
124 /* <h?> */ DocSection, DocHtmlHeader,
125 /* \internal */ DocInternal,
126 /* <div> */ DocInclude, DocSecRefList,
127 /* <hr> */ DocHorRuler,
128 /* <blockquote> */ DocHtmlBlockQuote,
129 /* \parblock */ DocParBlock,
130 /* \dotfile */ DocDotFile,
131 /* \mscfile */ DocMscFile,
132 /* \diafile */ DocDiaFile,
133 /* \plantumlfile */ DocPlantUmlFile,
134 /* <details> */ DocHtmlDetails,
135 /* <summary> */ DocHtmlSummary,
136 DocIncOperator >(n))
137 {
138 return TRUE;
139 }
140 const DocVerbatim *dv = std::get_if<DocVerbatim>(&n);
141 if (dv)
142 {
143 DocVerbatim::Type t = dv->type();
145 return t!=DocVerbatim::HtmlOnly || dv->isBlock();
146 }
147 const DocStyleChange *sc = std::get_if<DocStyleChange>(&n);
148 if (sc)
149 {
150 return sc->style()==DocStyleChange::Preformatted ||
153 }
154 const DocFormula *df = std::get_if<DocFormula>(&n);
155 if (df)
156 {
157 return !df->isInline();
158 }
159 const DocImage *di = std::get_if<DocImage>(&n);
160 if (di)
161 {
162 return !di->isInlineImage();
163 }
164 return FALSE;
165}

References DocStyleChange::Center, DocStyleChange::Div, FALSE, holds_one_of_alternatives, DocVerbatim::HtmlOnly, DocVerbatim::isBlock, DocFormula::isInline, DocImage::isInlineImage, DocVerbatim::JavaDocCode, DocVerbatim::JavaDocLiteral, DocStyleChange::Preformatted, DocStyleChange::style, TRUE and DocVerbatim::type.

Referenced by HtmlDocVisitor::forceEndParagraph, HtmlDocVisitor::forceStartParagraph and HtmlDocVisitor::operator().

Variables

g_types

const char g_types[][NUM_HTML_LIST_TYPES] = {"1", "a", "i", "A"}
static

Definition at line 45 of file htmldocvisitor.cpp.

45static const char g_types[][NUM_HTML_LIST_TYPES] = {"1", "a", "i", "A"};

Referenced by HtmlDocVisitor::operator().

hex

const char* hex ="0123456789ABCDEF"
static

Definition at line 77 of file htmldocvisitor.cpp.

77static const char *hex="0123456789ABCDEF";

NUM_HTML_LIST_TYPES

const int NUM_HTML_LIST_TYPES = 4
static

Definition at line 44 of file htmldocvisitor.cpp.

44static const int NUM_HTML_LIST_TYPES = 4;

Referenced by HtmlDocVisitor::operator().


Generated via doxygen2docusaurus by Doxygen 1.14.0.