16#include <qcryptographichash.h>
20using namespace Qt::StringLiterals;
25
26
27
28
29
30
31
32
33
34
35
36
39
40
41
42
43
44
45
47 const QSet<QString> &metaCommandSet,
const QSet<QString> &topics)
49 m_priv =
new DocPrivate(start_loc, end_loc, source);
51 parser.parse(source, m_priv, metaCommandSet, topics);
53 if (Config::instance().getAtomsDump()) {
54 start_loc.information(u"==== Atoms Structure for block comment starting at %1 ===="_s.arg(
55 start_loc.toString()));
58 u"==== Ending atoms Structure for block comment ending at %1 ===="_s.arg(
87
88
92 return m_priv ==
nullptr ? dummy : m_priv->m_start_loc;
96
97
106 return m_priv ==
nullptr ? null : m_priv->m_src;
111 return m_priv ==
nullptr || m_priv->m_src.isEmpty();
116 static const Text dummy;
117 return m_priv ==
nullptr ? dummy : m_priv
->m_text;
122 static const Text dummy;
123 return m_priv ==
nullptr ? dummy : m_priv
->m_title;
133 QString classNameOnly = className;
134 if (className.contains(
"::"))
135 classNameOnly = className.split(
"::").last();
144
145
146
149 briefStr += atom->string();
151 briefStr += Generator::plainCode(atom->string());
156 QStringList w = briefStr.split(QLatin1Char(
' '));
157 if (!w.isEmpty() && w.first() ==
"Returns") {
159 if (!w.isEmpty() && w.first() ==
"The")
162 if (!w.isEmpty() && (w.first() == className || w.first() == classNameOnly))
166 && ((w.first() ==
"class") || (w.first() ==
"function") || (w.first() ==
"macro")
167 || (w.first() ==
"widget") || (w.first() ==
"namespace")
168 || (w.first() ==
"header")))
171 if (!w.isEmpty() && (w.first() ==
"is" || w.first() ==
"provides"))
174 if (!w.isEmpty() && (w.first() ==
"a" || w.first() ==
"an"))
180 if (whats.endsWith(QLatin1Char(
'.')))
181 whats.truncate(whats.size() - 1);
183 if (!whats.isEmpty())
184 whats[0] = whats[0].toUpper();
202 return m_priv ==
nullptr ? QSet<QString>() : m_priv->m_params;
207 return m_priv ==
nullptr ? QStringList() : m_priv->m_enumItemList;
212 return m_priv ==
nullptr ? QStringList() : m_priv->m_omitEnumItemList;
217 return m_priv ==
nullptr ? QSet<QString>() : m_priv->m_metacommandsUsed;
221
222
223
226 return metaCommandsUsed().contains(QLatin1String(
"internal"));
230
231
232
235 return metaCommandsUsed().contains(QLatin1String(
"reimp"));
239
240
241
248
249
252 if (m_priv ==
nullptr)
258
259
262 return metaCommandArgs(u"overload"_s);
266
267
268
269
282 return m_priv ==
nullptr ? QList<
Text>() : m_priv->m_alsoList;
287 return m_priv && m_priv
->extra && !m_priv
->extra->m_tableOfContents.isEmpty();
292 return m_priv && m_priv
->extra && !m_priv
->extra->m_keywords.isEmpty();
297 return m_priv && m_priv
->extra && !m_priv
->extra->m_targets.isEmpty();
302 if (m_priv ==
nullptr) {
303 static const QList<Atom *> empty;
307 return m_priv
->extra->m_tableOfContents;
312 if (m_priv ==
nullptr) {
313 static const QList<
int> empty;
317 return m_priv
->extra->m_tableOfContentsLevels;
322 if (m_priv ==
nullptr) {
323 static const QList<Atom *> empty;
327 return m_priv
->extra->m_keywords;
332 if (m_priv ==
nullptr) {
333 static const QList<Atom *> empty;
337 return m_priv
->extra->m_targets;
347 return m_priv && m_priv
->extra ? &m_priv
->extra->m_comparesWithMap :
nullptr;
358 Config &config = Config::instance();
361 const auto &configMacros = config.subVars(
CONFIG_MACRO);
362 for (
const auto ¯oName : configMacros) {
363 QString macroDotName =
CONFIG_MACRO + Config::dot + macroName;
365 macro.numParams = -1;
366 const auto ¯oConfigVar = config.get(macroDotName);
367 macro.m_defaultDef = macroConfigVar.asString();
368 if (!macro.m_defaultDef.isEmpty()) {
369 macro.m_defaultDefLocation = macroConfigVar.location();
370 macro.numParams = Config::numParams(macro.m_defaultDef);
374 const auto ¯oDotNames = config.subVars(macroDotName);
375 for (
const auto &f : macroDotNames) {
376 const auto ¯oSubVar = config.get(macroDotName + Config::dot + f);
377 QString def{macroSubVar.asString()};
378 if (!def.isEmpty()) {
379 macro.m_otherDefs.insert(f, def);
380 int m = Config::numParams(def);
381 if (macro.numParams == -1)
384 else if (macro.numParams != m && f != QLatin1String(
"match")) {
386 QString other = QStringLiteral(
"default");
387 if (macro.m_defaultDef.isEmpty())
388 other = macro.m_otherDefs.constBegin().key();
389 macroSubVar.location().warning(
390 QStringLiteral(
"Macro '\\%1' takes inconsistent number of "
391 "arguments (%2 %3, %4 %5)")
392 .arg(macroName, f, QString::number(m), other,
393 QString::number(macro.numParams)));
396 if (macro.numParams < m)
401 if (macro.numParams != -1)
402 m_utilities.macroHash.insert(macroName, macro);
407
408
416
417
418
419
420
425 bool metMargin =
true;
429 for (i = 0; i < str.size(); ++i) {
437 if (str[i] ==
'\n') {
449 if (cleaned.size() == str.size())
450 str =
std::move(cleaned);
453 for (
int i = 0; i < 3; ++i)
454 location.advance(str[i]);
458 str = str.mid(3, str.size() - 5);
474 QFile input_file{resolved_file.get_path()};
475 if (!input_file.open(QFile::ReadOnly))
477 code = DocParser::untabifyEtc(QTextStream{&input_file}.readAll());
481 marker = CodeMarker::markerForFileName(resolved_file.get_path());
482 quoter.quoteFromFile(resolved_file.get_path(), code, marker->markedUpCode(code,
nullptr, location));
The Atom class is the fundamental unit for representing documents internally.
AtomType type() const
Return the type of this atom.
const Atom * next() const
Return the next atom in the atom list.
The Config class contains the configuration variables for controlling how qdoc produces documentation...
static void initialize(const Config &config, FileResolver &file_resolver)
CommandMap m_metaCommandMap
QSet< QString > parameterNames() const
Text legaleseText() const
QList< Text > alsoList() const
const Location & location() const
Returns the starting location of a qdoc comment.
Doc & operator=(const Doc &doc)
Doc(const Location &start_loc, const Location &end_loc, const QString &source, const QSet< QString > &metaCommandSet, const QSet< QString > &topics)
Parse the qdoc comment source.
const QList< Atom * > & tableOfContents() const
const Text & title() const
bool isInternal() const
Returns true if the set of metacommands used in the doc comment contains {internal}...
bool hasTableOfContents() const
static void quoteFromFile(const Location &location, Quoter "er, ResolvedFile resolved_file, CodeMarker *marker=nullptr)
const QList< Atom * > & keywords() const
const Text & body() const
static void initialize(FileResolver &file_resolver)
QStringList omitEnumItemNames() const
const QList< Atom * > & targets() const
QMultiMap< ComparisonCategory, Text > * comparesWithMap() const
const QList< int > & tableOfContentsLevels() const
Text trimmedBriefText(const QString &className) const
ArgList metaCommandArgs(const QString &metaCommand) const
Text briefText(bool inclusive=false) const
const Location & startLocation() const
Returns the starting location of a qdoc comment.
bool isMarkedReimp() const
Returns true if the set of metacommands used in the doc comment contains {reimp}.
void markAutoGenerated()
Marks this documentation as auto-generated by QDoc.
bool isAutoGenerated() const
Returns true if this documentation was auto-generated by QDoc rather than written by an author.
static void terminate()
All the heap allocated variables are deleted.
QList< ArgPair > overloadList() const
Returns the list of arguments passed to the {\overload} command.
TopicList topicsUsed() const
Returns a reference to the list of topic commands used in the current qdoc comment.
QStringMultiMap * metaTagMap() const
QSet< QString > metaCommandsUsed() const
void constructExtra() const
const QString & source() const
QStringList enumItemNames() const
Encapsulate the logic that QDoc uses to find files whose path is provided by the user and that are re...
The Location class provides a way to mark a location in a file.
int columnNo() const
Returns the current column number.
void dump() const
Prints a human-readable version of the contained atoms to stderr.
Text subText(Atom::AtomType left, Atom::AtomType right, const Atom *from=nullptr, bool inclusive=false) const
QMultiMap< QString, QString > QStringMultiMap
Combined button and popup list for selecting options.
QHash_QString_Macro macroHash
QHash_QString_int cmdHash
Represents a file that is reachable by QDoc based on its current configuration.