forked from fpoussin/qtcreator-doxygen
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdoxygenplugin.cpp
634 lines (526 loc) · 23.5 KB
/
doxygenplugin.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
/**************************************************************************
**
** This file is part of Doxygen plugin for Qt Creator
**
** Copyright (c) 2009 Kevin Tanguy ([email protected]).
** Copyright (c) 2015 Fabien Poussin ([email protected]).
**
** This plugin is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as
** published by the Free Software Foundation, either version 2.1
** of the License, or (at your option) any later version.
**
** This plugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Lesser General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Doxygen Plugin. If not, see <http://www.gnu.org/licenses/>.
**/
#include "doxygenplugin.h"
#include "doxygen.h"
#include "doxygenconstants.h"
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icontext.h>
#include <coreplugin/icore.h>
#include <coreplugin/messagemanager.h>
#include <cppeditor/cppeditorconstants.h>
#include <cpptools/cpptoolsconstants.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projecttree.h>
#include <projectexplorer/session.h>
#include <projectexplorer/projectnodes.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/parameteraction.h>
#include <utils/qtcassert.h>
#include <utils/synchronousprocess.h>
#include <QAction>
#include <QFileInfo>
#include <QKeySequence>
#include <QMainWindow>
#include <QMenu>
#include <QMessageBox>
#include <QProcess>
#include <QString>
#include <QStringList>
#include <QtPlugin>
using namespace ExtensionSystem;
using namespace DoxyPlugin;
using namespace DoxyPlugin::Internal;
// Timeout for building documentation
enum { doxygenTimeOut = 120 };
//static const char CMD_ID_DOXYGEN_MAINVIEW[] = "Doxygen.MainView";
static const char CMD_ID_DOXYGEN_MENU[] = "Doxygen.Menu";
static const char CMD_ID_CREATEDOCUMENTATION[] = "Doxygen.CreateDocumentation";
static const char CMD_ID_DOCUMENTFILE[] = "Doxygen.DocumentFile";
//static const char CMD_ID_DOCUMENTOPENEDPROJECT[] = "Doxygen.DocumentOpenedProject";
static const char CMD_ID_DOCUMENTACTIVEPROJECT[] = "Doxygen.DocumentActiveProject";
static const char CMD_ID_BUILDDOCUMENTATION[] = "Doxygen.BuildDocumentation";
static const char CMD_ID_BuildCurrentDocAndOpenHtml[] = "Doxygen.BuildCurrentDocAndOpenHtml";
static const char CMD_ID_DOXYFILEWIZARD[] = "Doxygen.RunWizard";
DoxygenPlugin* DoxygenPlugin::m_instance = nullptr;
DoxygenPlugin::DoxygenPlugin()
{
m_instance = this;
}
DoxygenPlugin::~DoxygenPlugin()
{
// Unregister objects from the plugin manager's object pool
// Delete members
m_instance = nullptr;
m_settings->deleteLater();
}
bool DoxygenPlugin::initialize(const QStringList& arguments, QString* errorString)
{
// Register objects in the plugin manager's object pool
// Load settings
// Add actions to menus
// Connect to other plugins' signals
// In the initialize function, a plugin can be sure that the plugins it
// depends on have initialized their members.
using namespace Constants;
using namespace Core::Constants;
using namespace ExtensionSystem;
Q_UNUSED(arguments);
Q_UNUSED(errorString);
// settings dialog :)
m_settings = new DoxygenSettings;
//addAutoReleasedObject(m_settings);
Core::ActionManager* am = Core::ActionManager::instance();
Core::ActionContainer *mfolderContextMenu = Core::ActionManager::createMenu(Constants::M_FOLDERCONTEXT);
Core::ActionContainer *mfileContextMenu = Core::ActionManager::createMenu(Constants::M_FILECONTEXT);
Core::Context globalcontext(C_GLOBAL);
//Core::Context context(CMD_ID_DOXYGEN_MAINVIEW);
Core::ActionContainer* toolsContainer = am->actionContainer(Core::Constants::M_TOOLS);
#if defined (PLUGIN_VER) && PLUGIN_VER<4130 // less than v4.13.x use Core::Id
Core::ActionContainer* doxygenMenu = am->createMenu(Core::Id(CMD_ID_DOXYGEN_MENU));
#else
Core::ActionContainer* doxygenMenu = am->createMenu(Utils::Id(CMD_ID_DOXYGEN_MENU));
#endif
doxygenMenu->menu()->setTitle(tr("&Doxygen"));
toolsContainer->addMenu(doxygenMenu);
// put action in our own menu in "Tools"
// create documentation for symbol under cursor
Core::Command* command;
m_doxygenCreateDocumentationAction = new QAction(tr("Document current entity"), this);
command = am->registerAction(m_doxygenCreateDocumentationAction, CMD_ID_CREATEDOCUMENTATION, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F9")));
connect(m_doxygenCreateDocumentationAction, SIGNAL(triggered(bool)), this, SLOT(documentEntity()));
doxygenMenu->addAction(command);
// Don't forget the contextual menu
Core::ActionContainer* contextMenu = am->createMenu(CppEditor::Constants::M_CONTEXT);
contextMenu->addAction(command);
// create documentation for a whole file
m_doxygenDocumentFileAction = new QAction(tr("Document current file"), this);
command = am->registerAction(m_doxygenDocumentFileAction, CMD_ID_DOCUMENTFILE, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F5")));
connect(m_doxygenDocumentFileAction, SIGNAL(triggered(bool)), this, SLOT(documentFile()));
doxygenMenu->addAction(command);
contextMenu->addAction(command);
/*
// create documentation for a whole project of the currently opened file
m_doxygenDocumentOpenedProjectAction = new QAction(tr("Document whole project of opened file"), this);
command = am->registerAction(m_doxygenDocumentOpenedProjectAction,
CMD_ID_DOCUMENTOPENEDPROJECT, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F7")));
connect(m_doxygenDocumentOpenedProjectAction, SIGNAL(triggered(bool)),
this, SLOT(documentOpenedProject()));
doxygenMenu->addAction(command);
*/
// create documentation for a whole project
m_doxygenDocumentActiveProjectAction = new QAction(tr("Document current project"), this);
command = am->registerAction(m_doxygenDocumentActiveProjectAction,
CMD_ID_DOCUMENTACTIVEPROJECT, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F8")));
connect(m_doxygenDocumentActiveProjectAction, SIGNAL(triggered(bool)),
this, SLOT(documentCurrentProject()));
doxygenMenu->addAction(command);
// "compile" documentation action
m_doxygenBuildDocumentationAction = new QAction(tr("Build Doxygen Documentation"), this);
command = am->registerAction(m_doxygenBuildDocumentationAction, CMD_ID_BUILDDOCUMENTATION, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F4")));
connect(m_doxygenBuildDocumentationAction, SIGNAL(triggered(bool)), this, SLOT(buildDocumentation()));
doxygenMenu->addAction(command);
// compile and open index.html
m_doxygenBuildCurrentDocAndOpenHtml = new QAction(tr("Build Doxygen And Open Html"), this);
command = am->registerAction(m_doxygenBuildCurrentDocAndOpenHtml, CMD_ID_BuildCurrentDocAndOpenHtml, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F10")));
connect(m_doxygenBuildCurrentDocAndOpenHtml, SIGNAL(triggered(bool)), this, SLOT(buildCurrentDocAndOpenHtml()));
doxygenMenu->addAction(command);
contextMenu->addAction(command);
mfileContextMenu->addAction(command, Constants::G_FILE_OPEN);
mfolderContextMenu->addAction(command, Constants::G_FOLDER_FILES);
// edit Doxyfile action
m_doxygenDoxyfileWizardAction = new QAction(tr("Edit Doxyfile"), this);
command = am->registerAction(m_doxygenDoxyfileWizardAction, CMD_ID_DOXYFILEWIZARD, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F6")));
connect(m_doxygenDoxyfileWizardAction, SIGNAL(triggered(bool)), this, SLOT(doxyfileWizard()));
// Internal connections
Doxygen* dox = Doxygen::instance();
connect(dox, SIGNAL(message(QString)), this, SLOT(externalString(QString)));
connect(this, SIGNAL(doxyDocumentEntity(DoxygenSettingsStruct, Core::IEditor*)),
dox, SLOT(documentEntity(DoxygenSettingsStruct, Core::IEditor*)));
connect(this, SIGNAL(doxyDocumentFile(DoxygenSettingsStruct, Core::IEditor*)),
dox, SLOT(documentFile(DoxygenSettingsStruct, Core::IEditor*)));
connect(this, SIGNAL(doxyDocumentCurrentProject(DoxygenSettingsStruct)),
dox, SLOT(documentCurrentProject(DoxygenSettingsStruct)));
// connect(this, SIGNAL(doxyHtmlFile(DoxygenSettingsStruct, Core::IEditor*)),
// dox, SLOT(buildCurrentDocAndOpenHtml(DoxygenSettingsStruct, Core::IEditor*)));
// Process connection for Doxygen
m_process = new QProcess();
connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)),
this, SLOT(processExited(int, QProcess::ExitStatus)));
connect(m_process, SIGNAL(readyRead()),
this, SLOT(readProcessOutput()));
return true;
}
void DoxygenPlugin::extensionsInitialized()
{
// Retrieve objects from the plugin manager's object pool
// In the extensionsInitialized function, a plugin can be sure that all
// plugins that depend on it are completely initialized.
}
ExtensionSystem::IPlugin::ShutdownFlag DoxygenPlugin::aboutToShutdown()
{
// Save settings
// Disconnect from signals that are not needed during shutdown
// Hide UI (if you add UI that is not in the main window directly)
return SynchronousShutdown;
}
void DoxygenPlugin::documentEntity()
{
Core::IEditor* editor = Core::EditorManager::instance()->currentEditor();
emit doxyDocumentEntity(settings(), editor);
}
void DoxygenPlugin::documentFile()
{
if (QMessageBox::question((QWidget*)this->parent(),
"Doxygen", "Document current File?",
QMessageBox::Yes, QMessageBox::No)
== QMessageBox::Yes) {
Core::IEditor* editor = Core::EditorManager::instance()->currentEditor();
emit doxyDocumentFile(settings(), editor);
}
}
void DoxygenPlugin::generatehtml()
{
if (QMessageBox::question((QWidget*)this->parent(),
"Doxygen", "dump doxygen output from on current File?",
QMessageBox::Yes, QMessageBox::No)
== QMessageBox::Yes) {
Core::IEditor* editor = Core::EditorManager::instance()->currentEditor();
emit doxyHtmlFile(settings(),editor);
}
}
void DoxygenPlugin::documentSpecificProject()
{
Doxygen::instance()->documentSpecificProject(settings());
}
void DoxygenPlugin::documentCurrentProject()
{
emit doxyDocumentCurrentProject(settings());
}
bool DoxygenPlugin::buildDocumentation() // TODO: refactor
{
// TODO, allow configuration of the command
// the default here will just run doxygen at the project root
ProjectExplorer::Project* p = ProjectExplorer::ProjectTree::currentProject();
if (!p) {
QMessageBox::warning((QWidget*)parent(),
tr("Doxygen"),
tr("You don't have any current project."),
QMessageBox::Close, QMessageBox::NoButton);
return false;
}
QString projectRoot = Doxygen::getProjectRoot();
if (!projectRoot.size())
return false;
QString doxyFile = projectRoot;
doxyFile += settings().doxyConfigCpp;
QStringList args;
// create default Doxyfile if it doesn't exist
QFileInfo doxyFileInfo(doxyFile);
if (!doxyFileInfo.exists()) {
args << "-g" << doxyFile;
runDoxygen(args, projectRoot);
return true;
}
args << doxyFile;
runDoxygen(args, projectRoot);
return false;
}
bool DoxygenPlugin::buildCurrentDocAndOpenHtml()
{
ProjectExplorer::Project* p = ProjectExplorer::ProjectTree::currentProject();
#if defined (PLUGIN_VER) && PLUGIN_VER<4100 // less than v4.10.x
ProjectExplorer::Node *currentNode = ProjectExplorer::ProjectTree::findCurrentNode();
#else
ProjectExplorer::Node *currentNode = ProjectExplorer::ProjectTree::currentNode();
#endif
if (!p) {
QMessageBox::warning((QWidget*)parent(),
tr("Doxygen"),
tr("You don't have any current project."),
QMessageBox::Close, QMessageBox::NoButton);
return false;
}
QString projectRoot = Doxygen::getProjectRoot();
if (!projectRoot.size())
return false;
#if defined (PLUGIN_VER) && PLUGIN_VER<4130 // less than v4.13.x
QString currentfile = currentNode->filePath().toString();
#else
QString currentfile = currentNode->path();
#endif
QString outputDir = settings().doxygenOutDir;
QString DOXY_CONFIG_FILE;
bool isdoxyConfigdocs = false;
QStringList args1;
if(currentfile.indexOf(".c") > 0 || currentfile.indexOf(".cpp") > 0 ||
currentfile.indexOf(".h") > 0 || currentfile.indexOf(".hpp") > 0){
DOXY_CONFIG_FILE = settings().doxyConfigCpp;
}else if(currentfile.indexOf(".qml") > 0){
DOXY_CONFIG_FILE = settings().doxyConfigQml;
}else if(currentfile.indexOf(".py") > 0){
DOXY_CONFIG_FILE = settings().doxyConfigPython;
}else if(currentfile.indexOf(".md") > 0 || currentfile.indexOf(".markdown") > 0){
DOXY_CONFIG_FILE = settings().doxyConfigMarkdown;
isdoxyConfigdocs = true;
}
if(DOXY_CONFIG_FILE == ""){
switch (QMessageBox::question((QWidget*)this->parent(),
"Doxygen", "Please select doxygen config type...",
"Cpp","Qml","Markdown"
/*QMessageBox::Yes, QMessageBox::No,QMessageBox::Cancel*/)) {
case 0: /*Cpp*/
DOXY_CONFIG_FILE = settings().doxyConfigCpp;
break;
case 1: /*Qml*/
DOXY_CONFIG_FILE = settings().doxyConfigQml;
break;
case 2: /*Markdown*/
DOXY_CONFIG_FILE = settings().doxyConfigMarkdown;
isdoxyConfigdocs = true;
break;
}
}
/*Change directory to DOXY_CONFIG_FILE Path*/
QString DOXY_CONFIG_PATH = QFileInfo(DOXY_CONFIG_FILE).absoluteDir().absolutePath();
externalString("Current directory" + QDir::currentPath());
if (!QDir::setCurrent(DOXY_CONFIG_PATH))
qDebug() << "Could not change the current working directory";
externalString("Change directory to:" + QDir::currentPath());
/*Remove outputDir file*/
QDir qOutdir( outputDir + "/html");
if(qOutdir.isEmpty() == false){
qOutdir.removeRecursively();
externalString("Delete file from " + qOutdir.absolutePath());
}
const QString executable = settings().doxygenCommand;
const QString brwosercmd = settings().browserCommand;
const QString brwosercmd_arg = settings().browserArgCommand;
const bool enableOpenHtml = settings().enableOpenHtml;
QString quote ="\"";
#if defined(Q_OS_WIN32)
QString ampersand =" &";
const QString shellcmd = "cmd /C";
/*Assign EXPAND command */
QString DOXY_EXPAND= ampersand + " echo LAYOUT_FILE="+quote+ QDir::toNativeSeparators(DOXY_CONFIG_PATH + "/theme/doxygen_layout.xml")+ quote + ampersand
+" echo HTML_HEADER="+quote+ QDir::toNativeSeparators(DOXY_CONFIG_PATH + "/theme/doxygen_header.html") + quote + ampersand
+" echo HTML_FOOTER="+quote+ QDir::toNativeSeparators(DOXY_CONFIG_PATH + "/theme/doxygen_footer.html") + quote + ampersand
+" echo HTML_EXTRA_STYLESHEET="+quote+ QDir::toNativeSeparators(DOXY_CONFIG_PATH + "/theme/doxygen_extra.css") + quote ;
#else
QString ampersand =" ;";
const QString shellcmd = "sh -c";
/*Assign EXPAND command */
QString DOXY_EXPAND= ampersand + " echo LAYOUT_FILE="+quote+ DOXY_CONFIG_PATH + "/theme/doxygen_layout.xml"+ quote + ampersand
+" echo HTML_HEADER="+quote+ DOXY_CONFIG_PATH + "/theme/doxygen_header.html" + quote + ampersand
+" echo HTML_FOOTER="+quote+ DOXY_CONFIG_PATH + "/theme/doxygen_footer.html" + quote + ampersand
+" echo HTML_EXTRA_STYLESHEET="+quote+ DOXY_CONFIG_PATH + "/theme/doxygen_extra.css" + quote ;
#endif
if(isdoxyConfigdocs == false)
DOXY_EXPAND = "";
#if defined(Q_OS_WIN32)
QString doxycmd = shellcmd + " (type "+quote+QDir::toNativeSeparators(DOXY_CONFIG_FILE)+quote+" &"
+ " echo OUTPUT_DIRECTORY="+quote+ QDir::toNativeSeparators(outputDir) +quote+" &"
+ " echo INPUT="+quote+ QDir::toNativeSeparators(currentfile) +quote+ DOXY_EXPAND + ")"
+ " | " +quote+ QDir::toNativeSeparators(executable) +quote+ " - \"";
QString openhtmlcmd = quote+ QDir::toNativeSeparators(brwosercmd)+quote + " " + brwosercmd_arg + " ""file:///"+ outputDir + "/html/index.html";
#else
QString doxycmd = shellcmd + " ""\"(cat "+DOXY_CONFIG_FILE+ " ;"
+ " echo "+"OUTPUT_DIRECTORY=" + outputDir+ " ;"
+ " echo "+"INPUT=" + currentfile + DOXY_EXPAND + " ) "
+ " | " + executable+ " - \"";
QString openhtmlcmd = brwosercmd + " " + brwosercmd_arg + " ""file:///"+ outputDir + "/html/index.html";
#endif
/*Run doxygen command with sidin*/
runCommandWithSync(doxycmd,projectRoot);
/*Run open html from brwoser cmd*/
if(enableOpenHtml)
runCommandWithSync(openhtmlcmd,projectRoot);
// QString DOXY_OUTPUT_CFG = "OUTPUT_DIRECTORY=" + outputDir;
// QString DOXY_PARSER_CFG = "INPUT=" + currentfile;
// args1 << DOXY_CONFIG_FILE << DOXY_PARSER_CFG << DOXY_OUTPUT_CFG << outputDir << "\n";
// runCommand(cmd,args1,projectRoot);
return false;
}
void DoxygenPlugin::doxyfileWizard() // TODO: refactor
{
// prevent a crash if user launches this command with no project opened
// You don't need to have an editor open for that.
ProjectExplorer::Project* p = ProjectExplorer::ProjectTree::currentProject();
if (!p) {
QMessageBox::warning((QWidget*)parent(),
tr("Doxygen"),
tr("You don't have any current project."),
QMessageBox::Close, QMessageBox::NoButton);
return;
}
QString projectRoot = p->projectDirectory().toString();
QString executable = settings().doxywizardCommand;
QStringList arglist(settings().doxyConfigCpp);
bool ret = QProcess::startDetached(settings().doxywizardCommand, arglist, projectRoot);
if (!ret) {
const QString outputText = tr("Failed to launch %1\n").arg(executable);
externalString(outputText);
}
}
void DoxygenPlugin::runDoxygen(const QStringList& arguments, QString workingDirectory)
{
const QString executable = settings().doxygenCommand;
if (executable.isEmpty()) {
externalString(tr("No doxygen executable specified"));
return;
}
const QStringList allArgs = settings().addOptions(arguments);
const QString outputText = tr("Executing: %1 %2\n").arg(executable).arg(DoxygenSettingsStruct::formatArguments(allArgs));
externalString(outputText);
m_process->close();
m_process->waitForFinished();
m_process->setWorkingDirectory(workingDirectory);
m_process->start(executable, allArgs);
if (!m_process->waitForStarted(5000))
qDebug("Could not start %s within 5 seconds", executable.toStdString().c_str());
return;
}
void DoxygenPlugin::runSysCommand(QString command, const QStringList& arguments)
{
const QString executable = command;
if (executable.isEmpty()) {
externalString(tr("No doxygen executable specified"));
return;
}
const QStringList allArgs = settings().addOptions(arguments);
const QString outputText = tr("Executing: %1 %2\n").arg(executable).arg(DoxygenSettingsStruct::formatArguments(allArgs));
externalString(outputText);
QByteArray ba = outputText.toLocal8Bit();
const char *c_str = ba.data();
if ( system ( c_str ) < 0 )
{
qDebug() << "run " << c_str << "Fail!";
}
return;
}
void DoxygenPlugin::runSysCommand(QString command)
{
const QString executable = command;
if (executable.isEmpty()) {
externalString(tr("No doxygen executable specified"));
return;
}
const QString outputText = tr("Executing: %1\n").arg(executable);
externalString(outputText);
QByteArray ba = outputText.toLocal8Bit();
const char *c_str = ba.data();
if ( system ( c_str ) < 0 )
{
qDebug() << "run " << c_str << "Fail!";
}
return;
}
void DoxygenPlugin::runCommand(QString command, const QStringList& arguments, QString workingDirectory)
{
const QString executable = command;
if (executable.isEmpty()) {
externalString(tr("No doxygen executable specified"));
return;
}
const QStringList allArgs = settings().addOptions(arguments);
const QString outputText = tr("Executing: %1 %2\n").arg(executable).arg(DoxygenSettingsStruct::formatArguments(allArgs));
externalString(outputText);
m_process->close();
m_process->waitForFinished();
m_process->setWorkingDirectory(workingDirectory);
m_process->start(executable, allArgs);
if (!m_process->waitForStarted(5000))
qDebug("Could not start %s within 5 seconds", executable.toStdString().c_str());
return;
}
void DoxygenPlugin::runCommandWithSync(QString command, QString workingDirectory)
{
const QString executable = command;
if (executable.isEmpty()) {
externalString(tr("No doxygen executable specified"));
return;
}
const QString outputText = tr("Executing: %1\n").arg(executable);
externalString(outputText);
m_process->close();
m_process->waitForFinished();
m_process->setWorkingDirectory(workingDirectory);
m_process->start(executable);
if (!m_process->waitForStarted(5000))
qDebug("Could not start %s within 5 seconds", executable.toStdString().c_str());
m_process->waitForFinished();
return;
}
void DoxygenPlugin::externalString(const QString& text)
{
Core::MessageManager::write(text);
Core::MessageManager::showOutputPane();
}
void DoxygenPlugin::processExited(int returnCode, QProcess::ExitStatus exitStatus)
{
DoxygenResponse response;
response.error = true;
response.stdErr = QLatin1String(m_process->readAllStandardError());
response.stdOut = QLatin1String(m_process->readAllStandardOutput());
switch (exitStatus) {
case QProcess::NormalExit:
response.error = false;
break;
case QProcess::CrashExit:
response.message = tr("The process terminated with exit code %1.").arg(returnCode);
break;
}
if (response.error)
externalString(response.message);
else
externalString(tr("Doxygen run successfully"));
}
void DoxygenPlugin::readProcessOutput()
{
externalString(QLatin1String(m_process->readAll()));
}
DoxygenSettingsStruct DoxygenPlugin::settings() const
{
return m_settings->settings();
}
DoxygenPlugin* DoxygenPlugin::instance()
{
return m_instance;
}