MCPcopy Create free account
hub / github.com/KDE/kdevelop / descriptionFromNewHtmlData

Function descriptionFromNewHtmlData

plugins/qthelp/qthelpdocumentation.cpp:195–217  ·  view source on GitHub ↗

try to extract description via HTML parsing using new Qt6 documentation format

Source from the content-addressed store, hash-verified

193
194/// try to extract description via HTML parsing using new Qt6 documentation format
195QString descriptionFromNewHtmlData(const QString& fragment, const QString& data)
196{
197 if (fragment.isEmpty()) {
198 return {};
199 }
200
201 // find the header that references the fragment
202 const auto sectionStartPattern = QRegularExpression(QLatin1String("<h(\\d)[^>]+id=\"%1\"").arg(fragment));
203 const auto matchStart = sectionStartPattern.match(data);
204 if (!matchStart.hasMatch()) {
205 return {};
206 }
207
208 // find the start of the next section by the header
209 const auto headerType = matchStart.capturedView(1);
210 const auto sectionStart = matchStart.capturedStart(0);
211 const auto sectionEndPattern = QRegularExpression(QLatin1String("<h%1[^>]+id=\"").arg(headerType));
212 const auto matchEnd = sectionEndPattern.match(data, matchStart.capturedEnd(0));
213 const auto sectionEnd = matchEnd.hasMatch() ? matchEnd.capturedStart(0) : data.size();
214
215 // then cleanup the data inbetween these two places
216 return cleanupDescription(data.sliced(sectionStart, sectionEnd - sectionStart));
217}
218
219/// extract description via HTML parsing using the old Qt5-like documentation format
220QString descriptionFromOldHtmlData(const QString& fragment, const QString& dataString)

Callers 1

descriptionMethod · 0.85

Calls 5

cleanupDescriptionFunction · 0.85
hasMatchMethod · 0.80
isEmptyMethod · 0.45
matchMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected