17#include <qcryptographichash.h>
21using namespace Qt::StringLiterals;
26
27
28
29
30
31
32
33
34
35
36
37
40
41
42
43
44
45
46
48 const QSet<QString> &metaCommandSet,
const QSet<QString> &topics)
50 m_priv =
new DocPrivate(start_loc, end_loc, source);
52 parser.parse(source, m_priv, metaCommandSet, topics);
54 if (Config::instance().getAtomsDump()) {
55 start_loc.information(u"==== Atoms Structure for block comment starting at %1 ===="_s.arg(
56 start_loc.toString()));
59 u"==== Ending atoms Structure for block comment ending at %1 ===="_s.arg(
88
89
93 return m_priv ==
nullptr ? dummy : m_priv->m_start_loc;
97
98
107 return m_priv ==
nullptr ? null : m_priv->m_src;
112 return m_priv ==
nullptr || m_priv->m_src.isEmpty();
117 static const Text dummy;
118 return m_priv ==
nullptr ? dummy : m_priv
->m_text;
123 static const Text dummy;
124 return m_priv ==
nullptr ? dummy : m_priv
->m_title;
134 QString classNameOnly = className;
135 if (className.contains(
"::"))
136 classNameOnly = className.split(
"::").last();
145
146
147
150 briefStr += atom->string();
152 briefStr += Generator::plainCode(atom->string());
157 QStringList w = briefStr.split(QLatin1Char(
' '));
158 if (!w.isEmpty() && w.first() ==
"Returns") {
160 if (!w.isEmpty() && w.first() ==
"The")
163 if (!w.isEmpty() && (w.first() == className || w.first() == classNameOnly))
167 && ((w.first() ==
"class") || (w.first() ==
"function") || (w.first() ==
"macro")
168 || (w.first() ==
"widget") || (w.first() ==
"namespace")
169 || (w.first() ==
"header")))
172 if (!w.isEmpty() && (w.first() ==
"is" || w.first() ==
"provides"))
175 if (!w.isEmpty() && (w.first() ==
"a" || w.first() ==
"an"))
181 if (whats.endsWith(QLatin1Char(
'.')))
182 whats.truncate(whats.size() - 1);
184 if (!whats.isEmpty())
185 whats[0] = whats[0].toUpper();
203 return m_priv ==
nullptr ? QSet<QString>() : m_priv->m_params;
208 return m_priv ==
nullptr ? QStringList() : m_priv->m_enumItemList;
213 return m_priv ==
nullptr ? QStringList() : m_priv->m_omitEnumItemList;
218 return m_priv ==
nullptr ? QSet<QString>() : m_priv->m_metacommandsUsed;
222
223
224
227 return metaCommandsUsed().contains(QLatin1String(
"internal"));
231
232
233
236 return metaCommandsUsed().contains(QLatin1String(
"reimp"));
240
241
242
249
250
253 if (m_priv ==
nullptr)
259
260
263 return metaCommandArgs(u"overload"_s);
267
268
269
270
283 return m_priv ==
nullptr ? QList<
Text>() : m_priv->m_alsoList;
288 return m_priv && m_priv
->extra && !m_priv
->extra->m_tableOfContents.isEmpty();
293 return m_priv && m_priv
->extra && !m_priv
->extra->m_keywords.isEmpty();
298 return m_priv && m_priv
->extra && !m_priv
->extra->m_targets.isEmpty();
303 if (m_priv ==
nullptr) {
304 static const QList<Atom *> empty;
308 return m_priv
->extra->m_tableOfContents;
313 if (m_priv ==
nullptr) {
314 static const QList<
int> empty;
318 return m_priv
->extra->m_tableOfContentsLevels;
323 if (m_priv ==
nullptr) {
324 static const QList<Atom *> empty;
328 return m_priv
->extra->m_keywords;
333 if (m_priv ==
nullptr) {
334 static const QList<Atom *> empty;
338 return m_priv
->extra->m_targets;
348 return m_priv && m_priv
->extra ? &m_priv
->extra->m_comparesWithMap :
nullptr;
359 Config &config = Config::instance();
362 const auto &configMacros = config.subVars(
CONFIG_MACRO);
363 for (
const auto ¯oName : configMacros) {
364 QString macroDotName =
CONFIG_MACRO + Config::dot + macroName;
366 macro.numParams = -1;
367 const auto ¯oConfigVar = config.get(macroDotName);
368 macro.m_defaultDef = macroConfigVar.asString();
369 if (!macro.m_defaultDef.isEmpty()) {
370 macro.m_defaultDefLocation = macroConfigVar.location();
371 macro.numParams = Config::numParams(macro.m_defaultDef);
375 const auto ¯oDotNames = config.subVars(macroDotName);
376 for (
const auto &f : macroDotNames) {
377 const auto ¯oSubVar = config.get(macroDotName + Config::dot + f);
378 QString def{macroSubVar.asString()};
379 if (!def.isEmpty()) {
380 macro.m_otherDefs.insert(f, def);
381 int m = Config::numParams(def);
382 if (macro.numParams == -1)
385 else if (macro.numParams != m && f != QLatin1String(
"match")) {
387 QString other = QStringLiteral(
"default");
388 if (macro.m_defaultDef.isEmpty())
389 other = macro.m_otherDefs.constBegin().key();
390 macroSubVar.location().warning(
391 QStringLiteral(
"Macro '\\%1' takes inconsistent number of "
392 "arguments (%2 %3, %4 %5)")
393 .arg(macroName, f, QString::number(m), other,
394 QString::number(macro.numParams)));
397 if (macro.numParams < m)
402 if (macro.numParams != -1)
403 m_utilities.macroHash.insert(macroName, macro);
408
409
417
418
419
420
421
426 bool metMargin =
true;
430 for (i = 0; i < str.size(); ++i) {
438 if (str[i] ==
'\n') {
450 if (cleaned.size() == str.size())
451 str =
std::move(cleaned);
454 for (
int i = 0; i < 3; ++i)
455 location.advance(str[i]);
459 str = str.mid(3, str.size() - 5);
475 QFile input_file{resolved_file.get_path()};
476 if (!input_file.open(QFile::ReadOnly))
478 code = DocParser::untabifyEtc(QTextStream{&input_file}.readAll());
481 CodeMarker *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
static void quoteFromFile(const Location &location, Quoter "er, ResolvedFile resolved_file)
const Text & title() const
bool isInternal() const
Returns true if the set of metacommands used in the doc comment contains {internal}...
bool hasTableOfContents() const
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.