64 */ |
64 */ |
65 PageGenerator::~PageGenerator() |
65 PageGenerator::~PageGenerator() |
66 { |
66 { |
67 while (!outStreamStack.isEmpty()) |
67 while (!outStreamStack.isEmpty()) |
68 endSubPage(); |
68 endSubPage(); |
|
69 } |
|
70 |
|
71 static QRegExp linkTag("(<@link node=\"([^\"]+)\">).*(</@link>)"); |
|
72 static QRegExp funcTag("(<@func target=\"([^\"]*)\">)(.*)(</@func>)"); |
|
73 static QRegExp typeTag("(<@(type|headerfile|func)(?: +[^>]*)?>)(.*)(</@\\2>)"); |
|
74 static QRegExp spanTag("</@(?:comment|preprocessor|string|char)>"); |
|
75 static QRegExp unknownTag("</?@[^>]*>"); |
|
76 |
|
77 bool PageGenerator::parseArg(const QString& src, |
|
78 const QString& tag, |
|
79 int* pos, |
|
80 int n, |
|
81 QStringRef* contents, |
|
82 QStringRef* par1, |
|
83 bool debug) |
|
84 { |
|
85 #define SKIP_CHAR(c) \ |
|
86 if (debug) \ |
|
87 qDebug() << "looking for " << c << " at " << QString(src.data() + i, n - i); \ |
|
88 if (i >= n || src[i] != c) { \ |
|
89 if (debug) \ |
|
90 qDebug() << " char '" << c << "' not found"; \ |
|
91 return false; \ |
|
92 } \ |
|
93 ++i; |
|
94 |
|
95 |
|
96 #define SKIP_SPACE \ |
|
97 while (i < n && src[i] == ' ') \ |
|
98 ++i; |
|
99 |
|
100 int i = *pos; |
|
101 int j = i; |
|
102 |
|
103 // assume "<@" has been parsed outside |
|
104 //SKIP_CHAR('<'); |
|
105 //SKIP_CHAR('@'); |
|
106 |
|
107 if (tag != QStringRef(&src, i, tag.length())) { |
|
108 if (0 && debug) |
|
109 qDebug() << "tag " << tag << " not found at " << i; |
|
110 return false; |
|
111 } |
|
112 |
|
113 if (debug) |
|
114 qDebug() << "haystack:" << src << "needle:" << tag << "i:" <<i; |
|
115 |
|
116 // skip tag |
|
117 i += tag.length(); |
|
118 |
|
119 // parse stuff like: linkTag("(<@link node=\"([^\"]+)\">).*(</@link>)"); |
|
120 if (par1) { |
|
121 SKIP_SPACE; |
|
122 // read parameter name |
|
123 j = i; |
|
124 while (i < n && src[i].isLetter()) |
|
125 ++i; |
|
126 if (src[i] == '=') { |
|
127 if (debug) |
|
128 qDebug() << "read parameter" << QString(src.data() + j, i - j); |
|
129 SKIP_CHAR('='); |
|
130 SKIP_CHAR('"'); |
|
131 // skip parameter name |
|
132 j = i; |
|
133 while (i < n && src[i] != '"') |
|
134 ++i; |
|
135 *par1 = QStringRef(&src, j, i - j); |
|
136 SKIP_CHAR('"'); |
|
137 SKIP_SPACE; |
|
138 } else { |
|
139 if (debug) |
|
140 qDebug() << "no optional parameter found"; |
|
141 } |
|
142 } |
|
143 SKIP_SPACE; |
|
144 SKIP_CHAR('>'); |
|
145 |
|
146 // find contents up to closing "</@tag> |
|
147 j = i; |
|
148 for (; true; ++i) { |
|
149 if (i + 4 + tag.length() > n) |
|
150 return false; |
|
151 if (src[i] != '<') |
|
152 continue; |
|
153 if (src[i + 1] != '/') |
|
154 continue; |
|
155 if (src[i + 2] != '@') |
|
156 continue; |
|
157 if (tag != QStringRef(&src, i + 3, tag.length())) |
|
158 continue; |
|
159 if (src[i + 3 + tag.length()] != '>') |
|
160 continue; |
|
161 break; |
|
162 } |
|
163 |
|
164 *contents = QStringRef(&src, j, i - j); |
|
165 |
|
166 i += tag.length() + 4; |
|
167 |
|
168 *pos = i; |
|
169 if (debug) |
|
170 qDebug() << " tag " << tag << " found: pos now: " << i; |
|
171 return true; |
|
172 #undef SKIP_CHAR |
69 } |
173 } |
70 |
174 |
71 /*! |
175 /*! |
72 This function is recursive. |
176 This function is recursive. |
73 */ |
177 */ |
103 we prepend "qml-" to the file name of QML element doc |
207 we prepend "qml-" to the file name of QML element doc |
104 files. |
208 files. |
105 */ |
209 */ |
106 if ((p->subType() == Node::QmlClass) || |
210 if ((p->subType() == Node::QmlClass) || |
107 (p->subType() == Node::QmlBasicType)) { |
211 (p->subType() == Node::QmlBasicType)) { |
108 base.prepend("qml-"); |
212 if (!base.startsWith(QLatin1String("QML:"))) |
|
213 base.prepend("qml-"); |
109 } |
214 } |
110 #endif |
215 #endif |
111 if (!pp || pp->name().isEmpty() || pp->type() == Node::Fake) |
216 if (!pp || pp->name().isEmpty() || pp->type() == Node::Fake) |
112 break; |
217 break; |
113 base.prepend(QLatin1Char('-')); |
218 base.prepend(QLatin1Char('-')); |