51bool XmlGenerator::isOneColumnValueTable(
const Atom *atom)
53 if (atom->type() != Atom::ListLeft || atom->string() !=
ATOM_LIST_VALUE)
56 while (atom && atom->type() != Atom::ListTagRight)
60 if (!matchAhead(atom, Atom::ListItemLeft))
64 return matchAhead(atom->next(), Atom::ListItemRight);
101void XmlGenerator::rewritePropertyBrief(
const Atom *atom,
const Node *relative)
103 if (relative->nodeType() != NodeType::Property && relative->nodeType() != NodeType::Variable)
106 if (!atom || atom->type() != Atom::String)
109 const QString firstWord =
110 atom->string().toLower().section(
' ', 0, 0, QString::SectionSkipEmpty);
111 const QStringList words{
"the",
"a",
"an",
"whether",
"which" };
112 if (words.contains(firstWord)) {
113 QString str = QLatin1String(
"This ")
114 + QLatin1String(relative->nodeType() == NodeType::Property ?
"property" :
"variable")
115 + QLatin1String(
" holds ") + atom->string().left(1).toLower()
116 + atom->string().mid(1);
117 const_cast<Atom *>(atom)->setString(str);
139void XmlGenerator::setImageFileName(
const Node *relative,
const QString &fileName)
141 if (relative->isExample()) {
142 const auto cen =
static_cast<
const ExampleNode *>(relative);
143 if (cen->imageFileName().isEmpty()) {
144 auto *en =
const_cast<ExampleNode *>(cen);
145 en->setImageFileName(fileName);
155std::pair<QString,
int> XmlGenerator::getAtomListValue(
const Atom *atom)
157 const Atom *lookAhead = atom->next();
159 return std::pair<QString,
int>(QString(), 1);
161 QString t = lookAhead->string();
162 lookAhead = lookAhead->next();
163 if (!lookAhead || lookAhead->type() != Atom::ListTagRight)
164 return std::pair<QString,
int>(QString(), 1);
166 lookAhead = lookAhead->next();
168 if (lookAhead && lookAhead->type() == Atom::SinceTagLeft) {
169 lookAhead = lookAhead->next();
170 Q_ASSERT(lookAhead && lookAhead->type() == Atom::String);
171 t += QLatin1String(
" (since ");
172 const QString sinceString = lookAhead->string();
173 if (sinceString.at(0).isDigit()) {
175 t += productName.isEmpty() ? sinceString : productName +
" " + sinceString;
179 t += QLatin1String(
")");
184 return std::pair<QString,
int>(t, skipAhead);
193std::pair<QString, QString> XmlGenerator::getTableWidthAttr(
const Atom *atom)
196 QString attr =
"generic";
198 if (atom->count() > 0) {
199 p0 = atom->string(0);
200 if (atom->count() > 1)
201 p1 = atom->string(1);
204 if (p0 == QLatin1String(
"borderless"))
206 else if (p0.contains(QLatin1Char(
'%')))
210 if (p1 == QLatin1String(
"borderless"))
211 attr = std::move(p1);
212 else if (p1.contains(QLatin1Char(
'%')))
213 width = std::move(p1);
218 if (width == QLatin1String(
"%")) {
221 int widthPercentage = p0.toInt(&ok);
223 width = QString::number(widthPercentage) +
"%";
229 return {width, attr};
282QString XmlGenerator::linkForNode(
const Node *node,
const Node *relative)
286 if (!node->url().isNull())
288 if (fileBase(node).isEmpty())
290 const InclusionPolicy policy = Config::instance().createInclusionPolicy();
291 const NodeContext context = node->createContext();
292 if (!InclusionFilter::isIncluded(policy, context))
295 QString fn = fileName(node);
296 if (node->parent() && node->parent()->isQmlType() && node->parent()->isAbstract()) {
297 if (Generator::qmlTypeContext()) {
298 if (Generator::qmlTypeContext()->inherits(node->parent())) {
299 fn = fileName(Generator::qmlTypeContext());
300 }
else if (node->parent()->isInternal() && !noLinkErrors()) {
301 node->doc().location().warning(
302 QStringLiteral(
"Cannot link to property in internal type '%1'")
303 .arg(node->parent()->name()));
311 if (!node->isPageNode() || node->isPropertyGroup()) {
312 QString ref = refForNode(node);
313 if (relative && fn == fileName(relative) && ref == refForNode(relative))
316 link += QLatin1Char(
'#');
321
322
323
324
325
326
327
328 if (relative && (node != relative)) {
329 if (useOutputSubdirs() && !node->isExternalPage() &&
330 (node->isIndexNode() || node->tree() != relative->tree()))
331 link.prepend(
"../%1/"_L1.arg(node->tree()->physicalModuleName()));
381QString XmlGenerator::getAutoLink(
const Atom *atom,
const Node *relative,
const Node **node,
386 *node = m_qdb->findNodeForAtom(atom, relative, ref, genus);
390 QString link = (*node)->url();
392 link = linkForNode(*node, relative);
393 }
else if (link.isEmpty()) {
396 if (!ref.isEmpty()) {
397 qsizetype hashtag = link.lastIndexOf(QChar(
'#'));
399 link.truncate(hashtag);
400 link += QLatin1Char(
'#') + ref;
405std::pair<QString, QString> XmlGenerator::anchorForNode(
const Node *node)
407 std::pair<QString, QString> anchorPair;
409 anchorPair.first = Generator::fileName(node);
410 if (node->isTextPageNode())
411 anchorPair.second = node->title();