Added not yet functional documentation thingy · scummos/kdevelop-python@461f397 · GitHub
Skip to content

Commit 461f397

Browse files
committed
Added not yet functional documentation thingy
1 parent 75d45cc commit 461f397

6 files changed

Lines changed: 50 additions & 6 deletions

File tree

‎duchain/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions

‎duchain/declarations/importedmoduledeclaration.cpp‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ QString importedModuleDeclaration::generateDocumentationForModule()
1919

2020
QString result = parser->readAllStandardOutput();
2121

22-
kDebug() << result;
23-
2422
return result;
2523
}
2624

‎duchain/navigation/declarationnavigationcontext.cpp‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ DeclarationNavigationContext::DeclarationNavigationContext(DeclarationPointer de
4343
kDebug() << " >> Module declaration found! Building documentation";
4444
kDebug() << " >> Identifier: " << import_decl->m_moduleIdentifier;
4545
m_moduleDocumentation = import_decl->generateDocumentationForModule();
46+
kDebug() << " << Done generating documentation";
4647
}
4748
}
4849

@@ -51,7 +52,8 @@ QString DeclarationNavigationContext::html(bool shorten) {
5152
if ( m_moduleDocumentation.length() ) {
5253
normalDoc += "<br><hr><br>" + m_moduleDocumentation;
5354
}
54-
return normalDoc;
55+
// return normalDoc;
56+
return QString();
5557
}
5658

5759
NavigationContextPointer DeclarationNavigationContext::registerChild(DeclarationPointer declaration)
Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#include "navigationwidget.h"
22
#include "declarationnavigationcontext.h"
3+
#include <qlayout.h>
4+
#include <QWebView>
5+
#include <QUrl>
6+
#include <QWebFrame>
7+
#include <QWebElement>
8+
#include <qboxlayout.h>
9+
#include <qpushbutton.h>
10+
#include <QObject>
311

412
namespace Python {
513

@@ -8,15 +16,42 @@ NavigationWidget::NavigationWidget(KDevelop::DeclarationPointer declaration, KDe
816
kDebug() << "Navigation widget for Declaration requested";
917
m_topContext = topContext;
1018

11-
initBrowser(400);
12-
1319
m_startContext = new DeclarationNavigationContext(declaration, m_topContext);
1420
setContext(m_startContext);
21+
22+
m_documentationWebView = new QWebView(this);
23+
m_documentationWebView->load(QUrl("http://localhost:1050/"));
24+
connect( m_documentationWebView, SIGNAL(loadFinished(bool)), SLOT(addDocumentationData(bool)) );
25+
26+
delete layout();
27+
28+
QGridLayout* newLayout = new QGridLayout();
29+
newLayout->setRowMinimumHeight(0, 300);
30+
newLayout->setColumnMinimumWidth(0, 400);
31+
setLayout(newLayout);
32+
layout()->addWidget(m_documentationWebView);
33+
34+
initBrowser(400);
35+
}
36+
37+
void NavigationWidget::addDocumentationData(bool finished)
38+
{
39+
kDebug() << "Done loading!";
40+
QWebElement document = m_documentationWebView->page()->mainFrame()->documentElement();
41+
if ( ! document.isNull() ) {
42+
kDebug() << " >>> Trying to append documentation... ";
43+
document.findFirst("body").appendInside("Hello World");
44+
}
45+
else {
46+
kError() << " !!! Could not append documentation to HTML page received!";
47+
}
1548
}
1649

1750
NavigationWidget::NavigationWidget(const KDevelop::IncludeItem& includeItem, KDevelop::TopDUContextPointer topContext, const QString& htmlPrefix, const QString& htmlSuffix)
1851
{
1952

2053
}
2154

22-
}
55+
}
56+
57+
#include "navigationwidget.moc"

‎duchain/navigation/navigationwidget.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,25 @@
44
#include <language/duchain/navigation/abstractnavigationwidget.h>
55
#include <language/util/includeitem.h>
66
#include "pythonduchainexport.h"
7+
#include <QWebView>
78

89
namespace Python {
910

1011
class KDEVPYTHONDUCHAIN_EXPORT NavigationWidget : public KDevelop::AbstractNavigationWidget
1112
{
13+
Q_OBJECT
14+
15+
public slots:
16+
void addDocumentationData(bool finished);
1217

1318
public:
1419
NavigationWidget(KDevelop::DeclarationPointer declaration, KDevelop::TopDUContextPointer topContext, const QString& htmlPrefix = QString(), const QString& htmlSuffix = QString());
1520
NavigationWidget(const KDevelop::IncludeItem& includeItem, KDevelop::TopDUContextPointer topContext, const QString& htmlPrefix = QString(), const QString& htmlSuffix = QString());
1621

1722
static QString shortDescription(KDevelop::Declaration* declaration) { return "<b>Test</b>"; };
1823
static QString shortDescription(const KDevelop::IncludeItem& includeItem) { return "<b>Test</b>"; };
24+
25+
QWebView* m_documentationWebView;
1926
};
2027

2128
}

‎pythonparsejob.cpp‎

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)