10#include <QtCore/qfileinfo.h>
11#include <QtCore/qprocess.h>
16
17
18
19
23 const_cast<QLoggingCategory &>(lcQdoc()).setEnabled(QtDebugMsg, value);
24 const_cast<QLoggingCategory &>(lcQdocClang()).setEnabled(QtDebugMsg, value);
30 qCDebug(lcQdoc,
"START DEBUGGING: %ls", qUtf16Printable(message));
35 qCDebug(lcQdoc,
"STOP DEBUGGING: %ls", qUtf16Printable(message));
41 return lcQdoc().isEnabled(QtDebugMsg);
45
46
47
48
49
50
51
52
55 return reinterpret_cast<
const INode *>(string.toULongLong());
58
59
60
61
62
63
64
65
66
69 return QString::number(
reinterpret_cast<quintptr>(node));
73
74
75
78 Q_ASSERT(!loc.filePath().isEmpty());
79 QFileInfo fi{loc.filePath()};
80 const auto id = QLatin1String(
"%1_%2_%3").arg(prefix, fi.fileName(), QString::number(loc.lineNo()));
81 return TextUtils::asAsciiPrintable(id);
85
86
87static bool runProcess(
const QString &program,
const QStringList &arguments,
88 QByteArray *stdOutIn, QByteArray *stdErrIn)
91 process.start(program, arguments, QProcess::ReadWrite);
92 if (!process.waitForStarted()) {
93 qCDebug(lcQdoc).nospace() <<
"Unable to start " << process.program()
94 <<
": " << process.errorString();
97 process.closeWriteChannel();
98 const bool finished = process.waitForFinished();
99 const QByteArray stdErr = process.readAllStandardError();
103 *stdOutIn = process.readAllStandardOutput();
106 qCDebug(lcQdoc).nospace() << process.program() <<
" timed out: " << stdErr;
111 if (process.exitStatus() != QProcess::NormalExit) {
112 qCDebug(lcQdoc).nospace() << process.program() <<
" crashed: " << stdErr;
116 if (process.exitCode() != 0) {
117 qCDebug(lcQdoc).nospace() << process.program() <<
" exited with "
118 << process.exitCode() <<
": " << stdErr;
126
127
129 return QByteArrayLiteral(
" (framework directory)");
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
152 QStringList arguments;
153 arguments << QStringLiteral(
"-E") << QStringLiteral(
"-x") << QStringLiteral(
"c++")
154 << QStringLiteral(
"-") << QStringLiteral(
"-v");
157 if (!runProcess(compiler, arguments, &stdOut, &stdErr))
159 const QByteArrayList stdErrLines = stdErr.split(
'\n');
160 bool isIncludeDir =
false;
161 for (
const QByteArray &line : stdErrLines) {
163 if (line.startsWith(QByteArrayLiteral(
"End of search list"))) {
164 isIncludeDir =
false;
166 QByteArray prefix(
"-I");
167 QByteArray headerPath{line.trimmed()};
168 if (headerPath.endsWith(frameworkSuffix())) {
169 headerPath.truncate(headerPath.size() - frameworkSuffix().size());
170 prefix = QByteArrayLiteral(
"-F");
172 result.append(QString::fromLocal8Bit(prefix + headerPath));
174 }
else if (line.startsWith(QByteArrayLiteral(
"#include <...> search starts here"))) {
184 QString fileName = QFileInfo(path).fileName();
185 return fileName.startsWith(
"moc_") ||
186 fileName.startsWith(
"qrc_") ||
187 fileName.startsWith(
"ui_");
191
192
193
194
195
196
197
198
199
200
201
202
205 QStringList pieces = linkText.split(
"\\#"_L1);
209 for (
auto &piece : pieces) {
210 QStringList fragmentPieces = piece.split(
'#');
211 next += fragmentPieces.takeFirst();
212 if (!fragmentPieces.isEmpty()) {
214 next = fragmentPieces.first();
216 if (result.count() == 2)
219 if (!next.isEmpty() && result.count() < 2)
226
227
228
229
230
231
234 QString link = project.toLower() + QLatin1Char(
'-') + path;
235 return TextUtils::asAsciiPrintable(link) + QLatin1Char(
'.') + fileExt;
239
240
241
242
243
244
245
246
247
250 const QString suffix = [kind]() {
252 case ExampleFileKind::File:
253 return " Example File"_L1;
254 case ExampleFileKind::Image:
255 return " Image File"_L1;
259 return QFileInfo(fileName).fileName() + suffix;
263
264
265
266
267
268
269
270
271
272
273
274
277 if (files.contains(fileName))
278 return exampleFileTitle(fileName, ExampleFileKind::File);
279 if (images.contains(fileName))
280 return exampleFileTitle(fileName, ExampleFileKind::Image);
The Location class provides a way to mark a location in a file.
Combined button and popup list for selecting options.
This namespace holds QDoc-internal utility methods.
QString uniqueIdentifier(const Location &loc, const QString &prefix)
Returns a unique identifier based on location loc, with a given prefix.
QString exampleFileTitle(const QStringList &files, const QStringList &images, const QString &fileName)
Constructs a title for a file or image page in an example.
static void setDebugEnabled(bool value)
QStringList getInternalIncludePaths(const QString &compiler)
QString exampleFileTitle(const QString &fileName, ExampleFileKind kind)
Constructs a title for a file or image page in an example.
bool isGeneratedFile(const QString &path)
const INode * nodeForString(const QString &string)
Converts a string representation of a pointer address to an INode pointer.
void stopDebugging(const QString &message)
static QByteArray frameworkSuffix()
QStringList pathAndFragment(const QString &linkText)
Returns a string list containing the path and fragment components of the given linkText.
void startDebugging(const QString &message)
static bool runProcess(const QString &program, const QStringList &arguments, QByteArray *stdOutIn, QByteArray *stdErrIn)
QString linkForExampleFile(const QString &path, const QString &project, const QString &fileExt)
Constructs an href link from an example file name.
QString stringForNode(const INode *node)
Converts an INode pointer address to its string representation.