Skip to content

Commit c6c2e23

Browse files
committed
Reformulate conditional inclusions in configuration file
Reformulate conditional inclusions in configuration file from a "don't include" to an "do include" version
1 parent 6bf61ad commit c6c2e23

3 files changed

Lines changed: 50 additions & 34 deletions

File tree

addon/doxywizard/expert.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ static void translateEnumDescription(QDomElement &valueElem,const QDomElement &t
107107
}
108108
}
109109

110+
static bool getFilter(QDomElement docsVal)
111+
{
112+
QString attr = docsVal.attribute(SA("filter"));
113+
if (attr.isEmpty()) return true;
114+
if (attr.contains(SA("doxywizard"))) return true;
115+
return false;
116+
}
117+
110118
static void translateOption(QDomElement &configRoot,const QDomElement &translationRoot)
111119
{
112120
QDomElement docsVal = configRoot.firstChildElement();
@@ -123,9 +131,11 @@ static void translateOption(QDomElement &configRoot,const QDomElement &translati
123131
while (!docsVal.isNull())
124132
{
125133
//qDebug() << "tagName" << docsVal.tagName();
126-
if (docsVal.tagName()==SA("docs") && docsVal.attribute(SA("doxywizard"))!=SA("0"))
134+
if (docsVal.tagName()==SA("docs") && getFilter(docsVal))
127135
{
128-
docsVal.setAttribute(SA("doxywizard"),SA("0"));
136+
docsVal.removeAttribute(SA("filter"));
137+
// we just need a value so we don't have an empty filter (and thus potential a match on doxywizard later on).
138+
docsVal.setAttribute(SA("filter"),SA("dummy"));
129139
}
130140
else if (docsVal.tagName()==SA("value") && docsVal.hasAttribute(SA("desc")))
131141
{
@@ -782,8 +792,7 @@ QString Expert::getDocsForNode(const QDomElement &child) const
782792
bool first = true;
783793
while (!docsVal.isNull())
784794
{
785-
if (docsVal.tagName()==SA("docs") &&
786-
docsVal.attribute(SA("doxywizard")) != SA("0"))
795+
if (docsVal.tagName()==SA("docs") && getFilter(docsVal))
787796
{
788797
if (!first) docs += SA("<br/>");
789798
first = false;

src/config.xml

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<doxygenconfig>
22
<header>
3-
<docs doxywizard='0' doxyfile='0'>
3+
<docs filter="documentation">
44
<![CDATA[
55
/*
66
*
@@ -69,7 +69,7 @@ Below is an alphabetical index of the tags that are recognized
6969
followed by the descriptions of the tags grouped by category.
7070
]]>
7171
</docs>
72-
<docs doxywizard='0' documentation='0'>
72+
<docs filter="doxywizard,doxyfile">
7373
<![CDATA[
7474
This file describes the settings to be used by the documentation system
7575
Doxygen (www.doxygen.org) for a project.
@@ -101,7 +101,7 @@ without replacing the environment variables or CMake type replacement variables:
101101
</docs>
102102
</header>
103103
<footer>
104-
<docs doxywizard='0' doxyfile='0'>
104+
<docs filter="documentation">
105105
<![CDATA[
106106
\section config_examples Examples
107107
@@ -593,23 +593,15 @@ Go to the <a href="commands.html">next</a> section or return to the
593593
a physical newline was in the original file.
594594
]]>
595595
</docs>
596-
<docs doxyfile='0' documentation='0'>
596+
<docs filter="doxywizard,doxyfile">
597597
<![CDATA[
598598
When you need a literal `{` or `}` or `,` in the value part of an alias you have to
599599
escape them by means of a backslash (\c \\), this can lead to conflicts with the
600600
commands \c \\{ and \c \\} for these it is advised to use the version \c @{ and \c @} or
601601
use a double escape (\c \\\\{ and \c \\\\})
602602
]]>
603603
</docs>
604-
<docs doxywizard='0' documentation='0'>
605-
<![CDATA[
606-
When you need a literal `{` or `}` or `,` in the value part of an alias you have to
607-
escape them by means of a backslash (\c \\), this can lead to conflicts with the
608-
commands \c \\{ and \c \\} for these it is advised to use the version \c @{ and \c @} or
609-
use a double escape (\c \\\\{ and \c \\\\})
610-
]]>
611-
</docs>
612-
<docs doxyfile='0' doxywizard='0'>
604+
<docs filter="documentation">
613605
<![CDATA[
614606
When you need a literal `{` or `}` or `,` in the value part of an alias you have to
615607
escape them by means of a backslash (\c \\), this can lead to conflicts with the
@@ -1344,7 +1336,7 @@ Go to the <a href="commands.html">next</a> section or return to the
13441336
Whatever the program writes to standard output is used as the file version.
13451337
]]>
13461338
</docs>
1347-
<docs doxywizard='0' doxyfile='0'>
1339+
<docs filter="documentation">
13481340
<![CDATA[
13491341
<br>
13501342
<br>
@@ -1371,7 +1363,7 @@ FILE_VERSION_FILTER = "cleartool desc -fmt \%Vn"
13711363
\endverbatim
13721364
]]>
13731365
</docs>
1374-
<docs documentation='0'>
1366+
<docs filter="doxyfile,doxywizard">
13751367
<![CDATA[
13761368
For an example see the documentation.
13771369
]]>
@@ -2102,7 +2094,7 @@ doxygen -w html new_header.html new_footer.html new_stylesheet.css YourConfigFil
21022094
Doxygen.
21032095
]]>
21042096
</docs>
2105-
<docs doxywizard='0' doxyfile='0'>
2097+
<docs filter="documentation">
21062098
<![CDATA[
21072099
The following markers have a special meaning inside the header and footer:
21082100
<dl>
@@ -2202,7 +2194,7 @@ doxygen -w html new_header.html new_footer.html new_stylesheet.css YourConfigFil
22022194
</dl>
22032195
]]>
22042196
</docs>
2205-
<docs documentation='0'>
2197+
<docs filter="doxyfile,doxywizard">
22062198
<![CDATA[
22072199
For a description of the possible markers and block names see the documentation.
22082200
]]>
@@ -2261,7 +2253,7 @@ doxygen -w html new_header.html new_footer.html new_stylesheet.css YourConfigFil
22612253
So if scrollbar customization is desired it has to be added explicitly.
22622254
]]>
22632255
</docs>
2264-
<docs doxywizard='0' doxyfile='0'>
2256+
<docs filter="documentation">
22652257
<![CDATA[
22662258
Here is an example style sheet that gives the contents area a fixed width:
22672259
\verbatim
@@ -2295,7 +2287,7 @@ hr.footer {
22952287
\endverbatim
22962288
]]>
22972289
</docs>
2298-
<docs documentation='0'>
2290+
<docs filter="doxyfile,doxywizard">
22992291
<![CDATA[
23002292
For an example see the documentation.
23012293
]]>
@@ -2918,7 +2910,7 @@ a package in Mathjax version 4 one can use the package name prepended with a min
29182910
- <a href="https://docs.mathjax.org/en/v4.0/">MathJax version 4</a>
29192911
]]>
29202912
</docs>
2921-
<docs doxywizard='0' doxyfile='0'>
2913+
<docs filter="documentation">
29222914
<![CDATA[
29232915
As an example to disable the "Math Renderer" menu item in the "Math
29242916
Settings" menu of MathJax:
@@ -2935,7 +2927,7 @@ MATHJAX_CODEFILE = disableRenderer.js
29352927
\endverbatim
29362928
]]>
29372929
</docs>
2938-
<docs documentation='0'>
2930+
<docs filter="doxyfile,doxywizard">
29392931
<![CDATA[
29402932
For an example see the documentation.
29412933
]]>
@@ -3172,7 +3164,7 @@ doxygen -w latex new_header.tex new_footer.tex new_stylesheet.sty
31723164
The following commands have a special meaning inside the header (and footer):
31733165
]]>
31743166
</docs>
3175-
<docs doxywizard='0' doxyfile='0'>
3167+
<docs filter="documentation">
31763168
<![CDATA[
31773169
<dl>
31783170
<dt><code>$title</code><dd>will be replaced with the project name.
@@ -3293,7 +3285,7 @@ The following block name is set based on whether or not a feature is used in the
32933285
</dl>
32943286
]]>
32953287
</docs>
3296-
<docs documentation='0'>
3288+
<docs filter="doxyfile,doxywizard">
32973289
<![CDATA[
32983290
For a description of the possible markers and block names see the documentation.
32993291
]]>

src/configgen.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import glob
2222

2323
messages = {}
24+
mode = ""
2425

2526
# wrapper class to write to file/output in UTF-8 format
2627
class OutputWriter:
@@ -144,12 +145,22 @@ def addValues(var, node):
144145
print(" %s->addValue(\"%s\");" % (var, name))
145146

146147

148+
def getFilter(node):
149+
global mode
150+
attr = node.getAttribute('filter')
151+
if not attr:
152+
return True
153+
if mode in attr:
154+
return True
155+
return False
156+
157+
147158
def parseHeader(node,objName):
148159
doc = ""
149160
for n in node.childNodes:
150161
if n.nodeType == Node.ELEMENT_NODE:
151162
if (n.nodeName == "docs"):
152-
if (n.getAttribute('doxyfile') != "0"):
163+
if getFilter(n):
153164
doc += parseDocs(n)
154165
docC = transformDocs(doc)
155166
print(" %s->setHeader(" % (objName))
@@ -171,7 +182,7 @@ def prepCDocs(node):
171182
if (type != 'obsolete'):
172183
for n in node.childNodes:
173184
if (n.nodeName == "docs"):
174-
if (n.getAttribute('doxyfile') != "0"):
185+
if getFilter(n):
175186
if n.nodeType == Node.ELEMENT_NODE:
176187
doc += parseDocs(n)
177188
if (type == 'enum'):
@@ -560,7 +571,7 @@ def parseOptionDoc(node, first):
560571
if (type != 'obsolete'):
561572
for n in node.childNodes:
562573
if (n.nodeName == "docs"):
563-
if (n.getAttribute('documentation') != "0"):
574+
if getFilter(n):
564575
if n.nodeType == Node.ELEMENT_NODE:
565576
doc += parseDocs(n)
566577
if (first):
@@ -693,13 +704,12 @@ def parseDocs(node):
693704
#doc += "<br>"
694705
return doc
695706

696-
697707
def parseHeaderDoc(node):
698708
doc = ""
699709
for n in node.childNodes:
700710
if n.nodeType == Node.ELEMENT_NODE:
701711
if (n.nodeName == "docs"):
702-
if (n.getAttribute('documentation') != "0"):
712+
if getFilter(n):
703713
doc += parseDocs(n)
704714
print(doc)
705715

@@ -709,7 +719,7 @@ def parseFooterDoc(node):
709719
for n in node.childNodes:
710720
if n.nodeType == Node.ELEMENT_NODE:
711721
if (n.nodeName == "docs"):
712-
if (n.getAttribute('documentation') != "0"):
722+
if getFilter(n):
713723
doc += parseDocs(n)
714724
print(doc)
715725

@@ -1113,7 +1123,9 @@ def main():
11131123
if len(messages)==0:
11141124
sys.exit('<generator> section missing in %s' % configFile)
11151125

1126+
global mode
11161127
if (sys.argv[1] == "-doc"):
1128+
mode = "documentation"
11171129
print("/* WARNING: This file is generated!")
11181130
print(" * Do not edit this file, but edit %s instead and run" % configFile)
11191131
print(" * python configgen.py -doc %s to regenerate this file!" % configFile)
@@ -1144,6 +1156,7 @@ def main():
11441156
if (n.nodeName == "footer"):
11451157
parseFooterDoc(n)
11461158
elif (sys.argv[1] == "-maph"):
1159+
mode = "doxyfile"
11471160
print("/* WARNING: This file is generated!")
11481161
print(" * Do not edit this file, but edit %s instead and run" % configFile)
11491162
print(" * python configgen.py -maph %s to regenerate this file!" % configFile)
@@ -1214,6 +1227,7 @@ def main():
12141227
print("")
12151228
print("#endif")
12161229
elif (sys.argv[1] == "-maps"):
1230+
mode = "doxyfile"
12171231
print("/* WARNING: This file is generated!")
12181232
print(" * Do not edit this file, but edit %s instead and run" % configFile)
12191233
print(" * python configgen.py -maps %s to regenerate this file!" % configFile)
@@ -1281,6 +1295,7 @@ def main():
12811295
print("}")
12821296
print("")
12831297
elif (sys.argv[1] == "-cpp"):
1298+
mode = "doxyfile"
12841299
print("/* WARNING: This file is generated!")
12851300
print(" * Do not edit this file, but edit %s instead and run" % configFile)
12861301
print(" * python configgen.py -cpp %s to regenerate this file!" % configFile)
@@ -1310,6 +1325,7 @@ def main():
13101325
parseGroups(n)
13111326
print("}")
13121327
elif (sys.argv[1] == "-wiz"):
1328+
mode = "doxywizard"
13131329
configFile = sys.argv[2]
13141330
locale = re.sub('.*config', '', configFile)
13151331
locale = re.sub('.xml', '', locale)
@@ -1333,7 +1349,6 @@ def main():
13331349
parseGroupCDocs(n)
13341350
print("}")
13351351
elif (sys.argv[1] == "-wizswitch"):
1336-
#// SWITCHER
13371352
print("#ifndef CONFIGSWITCHER_H")
13381353
print("#define CONFIGSWITCHER_H")
13391354
print("")

0 commit comments

Comments
 (0)