2 new commits in focusHighlight: https://bitbucket.org/nvdaaddonteam/focushighlight/commits/78740fcef85a/ Changeset: 78740fcef85a Branch: None User: mhameed Date: 2013-08-04 08:45:08 Summary: Small language improvements. Affected #: 1 file diff --git a/readme.md b/readme.md index a902dc8..879fc1b 100644 --- a/readme.md +++ b/readme.md @@ -3,15 +3,13 @@ * Authors: Takuya Nishimoto * download [version 0.0.5][1] - -This addon enables partially sighted users, sighted educators, or developers to track the location of the NVDA -navigator object and the focused object, by drawing a rectangle around the -specific object. +By drawing a colored rectangle, this addon enables partially sighted users, sighted educators, or developers to track the location of the nvda navigator object and the focused object/control. The following 3 colors are used by this addon: -* Green, to identify the navigator object. -* Red, to identify the focused object. -* Yellow, when navigator object and focused object are overlapping. + +* Green, to indicate the navigator object. +* Red, to indicate the focused object/control. +* Yellow, to indicate when navigator object and focused object are overlapping. To disable object tracking, uninstall the addon. https://bitbucket.org/nvdaaddonteam/focushighlight/commits/88bfe5d4bf22/ Changeset: 88bfe5d4bf22 Branch: master User: mhameed Date: 2013-08-04 08:51:39 Summary: Updated to latest addon template. Affected #: 4 files diff --git a/.gitignore b/.gitignore index 3a59e11..6d124be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +addon/doc/*.css +addon/doc/en/ +*_docHandler.py +*.html *.ini *.mo *.pot diff --git a/docHandler.py b/docHandler.py index da9c1d5..8dde60e 100644 --- a/docHandler.py +++ b/docHandler.py @@ -1,13 +1,23 @@ -# -*- coding: UTF-8 -*- +# -*- coding: UTF-8 -*- # docHandler: module for managing addons documentation # See: http://community.nvda-project.org/ticket/2694 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,21 @@ 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), _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..aa65448 100644 --- a/sconstruct +++ b/sconstruct @@ -5,14 +5,55 @@ import codecs import gettext +import shutil +import os import os.path import zipfile +import markdown import configobj import buildVars -env = Environment(ENV=os.environ) +def md2html(source, dest): + lang = os.path.basename(os.path.dirname(source)).replace('_', '-') + title="{addonSummary} {addonVersion}".format(addonSummary=buildVars.addon_info["addon-summary"], addonVersion=buildVars.addon_info["addon-version"]) + headerDic = { + "[[!meta title=\"": "# ", + "\"]]": " #", + } + with codecs.open(source, "r", "utf-8") as f: + mdText = f.read() + for k, v in headerDic.iteritems(): + mdText = mdText.replace(k, v, 1) + htmlText = markdown.markdown(mdText) + with codecs.open(dest, "w", "utf-8") as f: + f.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + + "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n" + + " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\";>\n" + + "<html xmlns=\"http://www.w3.org/1999/xhtml\"; xml:lang=\"%s\" lang=\"%s\">\n" % (lang, lang) + + "<head>\n" + + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n" + + "<link rel=\"stylesheet\" type=\"text/css\" href=\"../style.css\" media=\"screen\"/>\n" + + "<title>%s</title>\n" % title + + "</head>\n<body>\n" + ) + f.write(htmlText) + f.write("\n</body>\n</html>") + +def mdTool(env): + mdAction=env.Action( + lambda target,source,env: md2html(source[0].path, target[0].path), + lambda target,source,env: 'Generating %s'%target[0], + ) + mdBuilder=env.Builder( + action=mdAction, + suffix='.html', + src_suffix='.md', + ) + env['BUILDERS']['markdown']=mdBuilder + +env = Environment(ENV=os.environ, tools=[mdTool]) addonFile = env.File("{addon-name}-{addon-version}.nvda-addon".format(**buildVars.addon_info)) @@ -56,8 +97,25 @@ env['BUILDERS']['gettextMergePotFile']=env.Builder( ], lambda t, s, e : "Generating pot file %s" % t[0]), suffix=".pot") +def createAddonHelp(dir): + if not os.path.isfile("readme.md") or not os.path.isfile("docHandler.py"): + return + docdirs = [os.path.join(dir, "doc"), os.path.join(dir, "doc", "en")] + for docdir in docdirs: + if not os.path.isdir(docdir): + os.makedirs(docdir) + if os.path.isfile("style.css"): + shutil.copy("style.css", docdirs[0]) + shutil.copyfile("readme.md", os.path.join(docdir, "readme.md")) + plugindir = os.path.join(dir, "globalPlugins") + docFilename = "{addonName}_docHandler.py".format(addonName=buildVars.addon_info["addon-name"]) + docPath = os.path.join(plugindir, docFilename) + if not os.path.isdir(plugindir): + os.makedirs(plugindir) + shutil.copyfile("docHandler.py", docPath) + 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) 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. @@ -100,12 +158,20 @@ for dir in langDirs: moFile=env.gettextMoFile(poFile) env.Depends(moFile, poFile) translatedManifest = env.NVDATranslatedManifest(dir.File("manifest.ini"), [moFile, os.path.join("manifest-translated.ini.tpl")]) + env.Depends(translatedManifest, ["buildVars.py"]) env.Depends(addon, [translatedManifest, moFile]) pythonFiles = expandGlobs(buildVars.pythonSources) for file in pythonFiles: env.Depends(addon, file) +#Convert markdown files to html +createAddonHelp("addon") # We need at least doc in English and should append an item to Help menu +for mdFile in env.Glob(os.path.join('addon', 'doc', '*', '*.md')): + htmlFile = env.markdown(mdFile) + env.Depends(htmlFile, mdFile) + env.Depends(addon, htmlFile) + # Pot target i18nFiles = expandGlobs(buildVars.i18nSources) pot = env.gettextPotFile("%s.pot" % "{addon-name}".format(**buildVars.addon_info), i18nFiles) diff --git a/style.css b/style.css new file mode 100644 index 0000000..373283f --- /dev/null +++ b/style.css @@ -0,0 +1,30 @@ +@charset "utf-8"; +body { +font-family : Verdana, Arial, Helvetica, Sans-serif; +color : #FFFFFF; +background-color : #000000; +line-height: 1.2em; +} +h1, h2 {text-align: center} +dt { +font-weight : bold; +float : left; +width: 10%; +clear: left +} +dd { +margin : 0 0 0.4em 0; +float : left; +width: 90%; +display: block; +} +p { clear : both; +} +a { text-decoration : underline; +} +:active { +text-decoration : none; +} +a:focus, a:hover {outline: solid} +:link {color: #0000FF; +background-color: #FFFFFF} Repository URL: https://bitbucket.org/nvdaaddonteam/focushighlight/ -- 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