|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2016 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the QtHelp documentation provider plug-in. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 import os |
|
13 import glob |
|
14 |
|
15 from PyQt5.QtCore import QObject |
|
16 |
|
17 # Start-Of-Header |
|
18 name = "Documentation Sets" |
|
19 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
|
20 autoactivate = True |
|
21 deactivateable = True |
|
22 version = "1.0.0" |
|
23 className = "PluginDocumentationSets" |
|
24 packageName = "DocumentationSets" |
|
25 shortDescription = "Documentation sets in QtHelp format (*.qch)" |
|
26 longDescription = ( |
|
27 """This plug-in provides an interface to additional documentation sets""" |
|
28 """ in QtHelp format (*.qch) for registration with the eric help/web""" |
|
29 """ browser or Qt Assistant.""" |
|
30 ) |
|
31 needsRestart = False |
|
32 pyqtApi = 2 |
|
33 python2Compatible = True |
|
34 # End-Of-Header |
|
35 |
|
36 error = "" |
|
37 |
|
38 |
|
39 def helpFiles(): |
|
40 """ |
|
41 Module function to return the documentation sets provided by this plug-in. |
|
42 |
|
43 @return dictionary with documentation set type as key and list of |
|
44 documentation files as values |
|
45 @rtype dict (key: str, value: list of str) |
|
46 """ |
|
47 documentationSets = {} |
|
48 documentationSetsDir = os.path.join(os.path.dirname(__file__), |
|
49 "DocumentationSets") |
|
50 if os.path.isdir(documentationSetsDir): |
|
51 documentationTypes = [ |
|
52 d for d in os.listdir(documentationSetsDir) |
|
53 if os.path.isdir(os.path.join(documentationSetsDir, d)) |
|
54 ] |
|
55 for documentationType in documentationTypes: |
|
56 documentationSets[documentationType] = glob.glob( |
|
57 os.path.join(documentationSetsDir, documentationType, "*.qch")) |
|
58 |
|
59 return documentationSets |
|
60 |
|
61 |
|
62 class PluginDocumentationSets(QObject): |
|
63 """ |
|
64 Class implementing the QtHelp documentation provider plug-in. |
|
65 """ |
|
66 def __init__(self, ui): |
|
67 """ |
|
68 Constructor |
|
69 |
|
70 @param ui reference to the user interface object (UI.UserInterface) |
|
71 """ |
|
72 super(PluginDocumentationSets, self).__init__(ui) |
|
73 self.__ui = ui |
|
74 |
|
75 def activate(self): |
|
76 """ |
|
77 Public method to activate this plugin. |
|
78 |
|
79 @return tuple of None and activation status (boolean) |
|
80 """ |
|
81 global error |
|
82 error = "" # clear previous error |
|
83 |
|
84 return None, True |
|
85 |
|
86 def deactivate(self): |
|
87 """ |
|
88 Public method to deactivate this plugin. |
|
89 """ |
|
90 pass |