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;
128 QString classNameOnly = className;
129 if (className.contains(
"::"))
130 classNameOnly = className.split(
"::").last();
139
140
141
144 briefStr += atom->string();
146 briefStr += Generator::plainCode(atom->string());
151 QStringList w = briefStr.split(QLatin1Char(
' '));
152 if (!w.isEmpty() && w.first() ==
"Returns") {
154 if (!w.isEmpty() && w.first() ==
"The")
157 if (!w.isEmpty() && (w.first() == className || w.first() == classNameOnly))
161 && ((w.first() ==
"class") || (w.first() ==
"function") || (w.first() ==
"macro")
162 || (w.first() ==
"widget") || (w.first() ==
"namespace")
163 || (w.first() ==
"header")))
166 if (!w.isEmpty() && (w.first() ==
"is" || w.first() ==
"provides"))
169 if (!w.isEmpty() && (w.first() ==
"a" || w.first() ==
"an"))
175 if (whats.endsWith(QLatin1Char(
'.')))
176 whats.truncate(whats.size() - 1);
178 if (!whats.isEmpty())
179 whats[0] = whats[0].toUpper();
197 return m_priv ==
nullptr ? QSet<QString>() : m_priv->m_params;
202 return m_priv ==
nullptr ? QStringList() : m_priv->m_enumItemList;
207 return m_priv ==
nullptr ? QStringList() : m_priv->m_omitEnumItemList;
212 return m_priv ==
nullptr ? QSet<QString>() : m_priv->m_metacommandsUsed;
216
217
218
221 return metaCommandsUsed().contains(QLatin1String(
"internal"));
225
226
227
230 return metaCommandsUsed().contains(QLatin1String(
"reimp"));
234
235
236
237
245 return m_priv ==
nullptr ?
ArgList() : m_priv->m_metaCommandMap.value(metacommand);
250 return m_priv ==
nullptr ? QList<
Text>() : m_priv->m_alsoList;
255 return m_priv && m_priv
->extra && !m_priv
->extra->m_tableOfContents.isEmpty();
260 return m_priv && m_priv
->extra && !m_priv
->extra->m_keywords.isEmpty();
265 return m_priv && m_priv
->extra && !m_priv
->extra->m_targets.isEmpty();
271 return m_priv
->extra->m_tableOfContents;
277 return m_priv
->extra->m_tableOfContentsLevels;
283 return m_priv
->extra->m_keywords;
289 return m_priv
->extra->m_targets;
299 return m_priv && m_priv
->extra ? &m_priv
->extra->m_comparesWithMap :
nullptr;
310 Config &config = Config::instance();
313 const auto &configMacros = config.subVars(
CONFIG_MACRO);
314 for (
const auto ¯oName : configMacros) {
315 QString macroDotName =
CONFIG_MACRO + Config::dot + macroName;
317 macro.numParams = -1;
318 const auto ¯oConfigVar = config.get(macroDotName);
319 macro.m_defaultDef = macroConfigVar.asString();
320 if (!macro.m_defaultDef.isEmpty()) {
321 macro.m_defaultDefLocation = macroConfigVar.location();
322 macro.numParams = Config::numParams(macro.m_defaultDef);
326 const auto ¯oDotNames = config.subVars(macroDotName);
327 for (
const auto &f : macroDotNames) {
328 const auto ¯oSubVar = config.get(macroDotName + Config::dot + f);
329 QString def{macroSubVar.asString()};
330 if (!def.isEmpty()) {
331 macro.m_otherDefs.insert(f, def);
332 int m = Config::numParams(def);
333 if (macro.numParams == -1)
336 else if (macro.numParams != m && f != QLatin1String(
"match")) {
338 QString other = QStringLiteral(
"default");
339 if (macro.m_defaultDef.isEmpty())
340 other = macro.m_otherDefs.constBegin().key();
341 macroSubVar.location().warning(
342 QStringLiteral(
"Macro '\\%1' takes inconsistent number of "
343 "arguments (%2 %3, %4 %5)")
344 .arg(macroName, f, QString::number(m), other,
345 QString::number(macro.numParams)));
348 if (macro.numParams < m)
353 if (macro.numParams != -1)
354 m_utilities.macroHash.insert(macroName, macro);
359
360
368
369
370
375 bool metAsterColumn =
true;
379 for (i = 0; i < str.size(); ++i) {
384 metAsterColumn =
true;
386 if (str[i] ==
'\n') {
389 metAsterColumn =
false;
395 if (cleaned.size() == str.size())
398 for (
int i = 0; i < 3; ++i)
399 location.advance(str[i]);
400 str = str.mid(3, str.size() - 5);
416 QFile input_file{resolved_file.get_path()};
417 if (!input_file.open(QFile::ReadOnly))
419 code = DocParser::untabifyEtc(QTextStream{&input_file}.readAll());
422 CodeMarker *marker = CodeMarker::markerForFileName(resolved_file.get_path());
423 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)
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)
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}.
static void terminate()
All the heap allocated variables are deleted.
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.