1 new commit in addonTemplate: https://bitbucket.org/nvdaaddonteam/addontemplate/commits/2a20f8b543bc/ Changeset: 2a20f8b543bc Branch: addondocsupport User: norrumar Date: 2013-05-25 01:46:23 Summary: Now docHandler is copied to globalPlugins folder and renamed as yourAddonName_docHandler.py automatically. Affected #: 3 files diff --git a/README.md b/README.md index 1a6d239..a907e1e 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,6 @@ To create a new NVDA add-on, taking advantage of this template: - Put your code in the usual folders for NVDA extension, under the **addon** folder. For instance: globalPlugins, synthDrivers, etc. You can delete folders you don't need for your particular add-on package. - Gettext translations must be placed into addon\locale\<lang>/LC_MESSAGES\nvda.po. - Documentation files must be placed into addon\doc\<lang>/fileName, readme.html by default. -- You can copy docHandler.py to a globalPlugins or appModules folder. Then import it and use docHandler.openDocPath() to open the documentation file corresponding to NVDA's current language, or English by default. - To package the add-on for distribution, open a command line, change to the folder that has the **SCONSTRUCT** file and run the **scons** command. The created add-on, if there were no errors, is placed in the current directory. - You can further customize variables in the **buildVars.py** file. diff --git a/docHandler.py b/docHandler.py index da9c1d5..cafcc5a 100644 --- a/docHandler.py +++ b/docHandler.py @@ -5,9 +5,19 @@ import os import languageHandler +import addonHandler +import globalPluginHandler +import gui +import wx + +addonHandler.initTranslation() _addonDir = os.path.join(os.path.dirname(__file__), "..") # The root of an addon folder _docFileName = "readme.html" # The name of an addon documentation file +_curAddon = addonHandler.Addon(_addonDir) # Addon instance +_addonSummary = _curAddon.manifest['summary'] +_addonVersion = _curAddon.manifest['version'] +_addonName = _curAddon.manifest['name'] def getDocFolder(addonDir=_addonDir): langs = [languageHandler.getLanguage(), "en"] @@ -38,4 +48,23 @@ def openDocPath(): try: os.startfile(getDocPath()) except WindowsError: - pass \ No newline at end of file + pass + +class GlobalPlugin(globalPluginHandler.GlobalPlugin): + + def __init__(self): + super(globalPluginHandler.GlobalPlugin, self).__init__() + self.help = gui.mainFrame.sysTrayIcon.helpMenu + self.helpItem = self.help.Append(wx.ID_ANY, "{summary} {version}".format(summary=_addonSummary, version=_addonVersion), + # Translators: Tooltip for an addon menu item. + _("Open documentation for %s") % _addonName) + gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU, self.onHelp, self.helpItem) + + def onHelp(self, evt): + openDocPath() + + def terminate(self): + try: + self.help.RemoveItem(self.helpItem) + except wx.PyDeadObjectError: + pass diff --git a/sconstruct b/sconstruct index 4366cca..f84cd82 100644 --- a/sconstruct +++ b/sconstruct @@ -5,6 +5,8 @@ import codecs import gettext +import shutil +import os import os.path import zipfile import configobj @@ -57,8 +59,27 @@ env['BUILDERS']['gettextMergePotFile']=env.Builder( suffix=".pot") def createAddonBundleFromPath(path, dest): - """ Creates a bundle from a directory that contains a a addon manifest file.""" + """ Creates a bundle from a directory that contains an addon manifest file.""" basedir = os.path.abspath(path) + plugindir = os.path.join(basedir, "globalPlugins") + docFilename = "{addonName}_docHandler.py".format(addonName=buildVars.addon_info["addon-name"]) + if not os.path.isdir(plugindir): + try: + os.makedirs(plugindir) + except: + pass + try: + shutil.copy("docHandler.py", plugindir) + except: + pass + if not os.path.isfile(docFilename): + curdir = os.getcwd() + os.chdir(plugindir) + try: + os.rename("docHandler.py", docFilename) + except: + pass + os.chdir(curdir) with zipfile.ZipFile(dest, 'w', zipfile.ZIP_DEFLATED) as z: # FIXME: the include/exclude feature may or may not be useful. Also python files can be pre-compiled. for dir, dirnames, filenames in os.walk(basedir): Repository URL: https://bitbucket.org/nvdaaddonteam/addontemplate/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. ---------------------------------------------------------------- NVDA add-ons Central: A list for discussing NVDA add-ons To post a message, send an email to nvda-addons@xxxxxxxxxxxxx. To unsubscribe, send an email with the subject line of "unsubscribe" (without quotes) to nvda-addons-request@xxxxxxxxxxxxx. If you have questions for list moderators, please send a message to nvda-addons-moderators@xxxxxxxxxxxxx. Community addons can be found here: http://addons.nvda-project.org