1 /**************************************************************************
2 ** This file is part of LiteIDE
3 **
4 ** Copyright (c) 2011-2019 LiteIDE. All rights reserved.
5 **
6 ** This library is free software; you can redistribute it and/or
7 ** modify it under the terms of the GNU Lesser General Public
8 ** License as published by the Free Software Foundation; either
9 ** version 2.1 of the License, or (at your option) any later version.
10 **
11 ** This library is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 ** Lesser General Public License for more details.
15 **
16 ** In addition, as a special exception,  that plugins developed for LiteIDE,
17 ** are allowed to remain closed sourced and can be distributed under any license .
18 ** These rights are included in the file LGPL_EXCEPTION.txt in this package.
19 **
20 **************************************************************************/
21 // Module: golangdocapi.h
22 // Creator: visualfc <visualfc@gmail.com>
23 
24 #ifndef GOLANGDOCAPI_H
25 #define GOLANGDOCAPI_H
26 
27 #include "liteapi/liteapi.h"
28 
29 /*
30 openUrl(const QUrl &url);
31 url scheme
32 file : open html or plain file
33 list : url path only [pkg|cmd]
34 find : find pkg name
35 pdoc : show pkg doc
36 */
37 
38 namespace LiteApi {
39 
40 enum PkgApiEnum {
41     NullApi = 0,
42     PkgApi = 0x0001,
43     ConstApi = 0x0002,
44     VarApi = 0x0004,
45     StructApi = 0x0008,
46     InterfaceApi = 0x0010,
47     TypeApi = 0x0020,
48     FuncApi = 0x0040,
49     TypeMethodApi = 0x0080,
50     TypeVarApi = 0x0100,
51     AllTypeApi = StructApi | InterfaceApi | TypeApi,
52     AllGolangApi = PkgApi | ConstApi | VarApi | StructApi | InterfaceApi | TypeApi | FuncApi | TypeMethodApi | TypeVarApi
53 };
54 
55 class IGolangApi : public QObject
56 {
57     Q_OBJECT
58 public:
IGolangApi(QObject * parent)59     IGolangApi(QObject *parent) : QObject(parent) {}
60 public:
61     virtual QStringList all(int flag = AllGolangApi) const = 0;
62     virtual PkgApiEnum findExp(const QString &tag, QString &exp) const = 0;
63     virtual QStringList findDocUrl(const QString &tag) const = 0;
64     virtual QString findDocInfo(const QString &tag) const = 0;
65 };
66 
67 class IGolangDoc : public IObject
68 {
69     Q_OBJECT
70 public:
IGolangDoc(QObject * parent)71     IGolangDoc(QObject *parent) : IObject(parent) {}
72 public slots:
73     virtual void openUrl(const QUrl &url, const QVariant &addin = QVariant()) = 0;
74     virtual void activeBrowser() = 0;
75 };
76 
getGolangDoc(LiteApi::IApplication * app)77 inline IGolangDoc *getGolangDoc(LiteApi::IApplication *app)
78 {
79     return LiteApi::findExtensionObject<IGolangDoc*>(app,"LiteApi.IGolangDoc");
80 }
81 
82 }
83 
84 #endif //GOLANGDOCAPI_H
85 
86