Skip to content

Commit

Permalink
Update template
Browse files Browse the repository at this point in the history
  • Loading branch information
cartertemm committed Mar 1, 2020
1 parent 5db80a9 commit 7aec437
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 13 deletions.
4 changes: 3 additions & 1 deletion addon/manifest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ summary = "text information"
description = """Provides information about selected text. Press NVDA+; (semicolon) to activate, NVDA + shift + ; to get information from the clipboard, and NVDA + control + ; to speak the last retrieved information. You can press this twice to have it displayed in a browseable dialog. Note: for non-english keyboard layouts these gestures might need to be redefined in the input gestures dialog."""
author = "Carter Temm <[email protected]>"
url = http://github.com/cartertemm/text_information
version = 1.0
version = 1.1
docFileName = readme.html
minimumNVDAVersion = 2019.3
lastTestedNVDAVersion = 2019.3
updateChannel = None
12 changes: 9 additions & 3 deletions buildVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Add-on information variables
addon_info = {
# for previously unpublished addons, please follow the community guidelines at:
# https://bitbucket.org/nvdaaddonteam/todo/raw/master/guideLines.txt
# https://bitbucket.org/nvdaaddonteam/todo/raw/master/guidelines.txt
# add-on Name, internal for nvda
"addon_name" : "textInformation",
# Add-on summary, usually the user visible name of the addon.
Expand All @@ -19,21 +19,27 @@
# Translators: Long description to be shown for this add-on on add-on information from add-ons manager
"addon_description" : _("""Provides information about selected text. Press NVDA+; (semicolon) to activate, NVDA + shift + ; to get information from the clipboard, and NVDA + control + ; to speak the last retrieved information. You can press this twice to have it displayed in a browseable dialog. Note: for non-english keyboard layouts these gestures might need to be redefined in the input gestures dialog."""),
# version
"addon_version" : "1.0",
"addon_version" : "1.1",
# Author(s)
"addon_author" : u"Carter Temm <[email protected]>",
# URL for the add-on documentation support
"addon_url" : "http://github.com/cartertemm/text_information",
# Documentation file name
"addon_docFileName" : "readme.html",
# Minimum NVDA version supported (e.g. "2018.3.0", minor version is optional)
"addon_minimumNVDAVersion" : "2019.3",
# Last NVDA version supported/tested (e.g. "2018.4.0", ideally more recent than minimum version)
"addon_lastTestedNVDAVersion" : "2019.3",
# Add-on update channel (default is None, denoting stable releases, and for development releases, use "dev"; do not change unless you know what you are doing)
"addon_updateChannel" : None,
}


import os.path

# Define the python files that are the sources of your add-on.
# You can use glob expressions here, they will be expanded.
pythonSources = ["addon/globalPlugins/text_information/__init__.py"]
pythonSources = []

# Files that contain strings for translation. Usually your python sources
i18nSources = pythonSources + ["buildVars.py"]
Expand Down
3 changes: 3 additions & 0 deletions manifest.ini.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ author = "{addon_author}"
url = {addon_url}
version = {addon_version}
docFileName = {addon_docFileName}
minimumNVDAVersion = {addon_minimumNVDAVersion}
lastTestedNVDAVersion = {addon_lastTestedNVDAVersion}
updateChannel = {addon_updateChannel}
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Currently, the following features are supported:

Note: Regular expressions are used to verify data. There are currently some that aren't used, phone numbers and emails. This might be changed in the future.

## a note regarding python 3

As of 2019.3, all NVDA add-ons must be python 3 compatible. If you are for some reason running an older version, [1.0](https://github.com/cartertemm/text_information/releases/download/1.0/textInformation-1.0.nvda-addon) is the last version usable by python 2.

## contributing

Contributions are appreciated. You can either submit a PR, or get in contact with the following info:
Expand Down
39 changes: 30 additions & 9 deletions sconstruct
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import gettext
import os
import os.path
import zipfile
import sys
sys.dont_write_bytecode = True

import buildVars


def md2html(source, dest):
import markdown
lang = os.path.basename(os.path.dirname(source)).replace('_', '-')
Expand All @@ -22,7 +23,7 @@ def md2html(source, dest):
}
with codecs.open(source, "r", "utf-8") as f:
mdText = f.read()
for k, v in headerDic.iteritems():
for k, v in headerDic.items():
mdText = mdText.replace(k, v, 1)
htmlText = markdown.markdown(mdText)
with codecs.open(dest, "w", "utf-8") as f:
Expand Down Expand Up @@ -51,10 +52,25 @@ def mdTool(env):
)
env['BUILDERS']['markdown']=mdBuilder

vars = Variables()
vars.Add("version", "The version of this build", buildVars.addon_info["addon_version"])
vars.Add(BoolVariable("dev", "Whether this is a daily development version", False))
vars.Add("channel", "Update channel for this build", buildVars.addon_info["addon_updateChannel"])

env = Environment(ENV=os.environ, tools=['gettexttool', mdTool])
env = Environment(variables=vars, ENV=os.environ, tools=['gettexttool', mdTool])
env.Append(**buildVars.addon_info)

if env["dev"]:
import datetime
buildDate = datetime.datetime.now()
year, month, day = str(buildDate.year), str(buildDate.month), str(buildDate.day)
env["addon_version"] = "".join([year, month.zfill(2), day.zfill(2), "-dev"])
env["channel"] = "dev"
elif env["version"] is not None:
env["addon_version"] = env["version"]
if "channel" in env and env["channel"] is not None:
env["addon_updateChannel"] = env["channel"]

addonFile = env.File("${addon_name}-${addon_version}.nvda-addon")

def addonGenerator(target, source, env, for_signature):
Expand All @@ -67,7 +83,6 @@ def manifestGenerator(target, source, env, for_signature):
lambda target, source, env : "Generating manifest %s" % target[0])
return action


def translatedManifestGenerator(target, source, env, for_signature):
dir = os.path.abspath(os.path.join(os.path.dirname(str(source[0])), ".."))
lang = os.path.basename(dir)
Expand All @@ -90,8 +105,6 @@ def createAddonHelp(dir):
readmeTarget = env.Command(readmePath, "readme.md", Copy("$TARGET", "$SOURCE"))
env.Depends(addon, readmeTarget)



def createAddonBundleFromPath(path, dest):
""" Creates a bundle from a directory that contains an addon manifest file."""
basedir = os.path.abspath(path)
Expand All @@ -106,14 +119,21 @@ def createAddonBundleFromPath(path, dest):
return dest

def generateManifest(source, dest):
addon_info = buildVars.addon_info
addon_info["addon_version"] = env["addon_version"]
addon_info["addon_updateChannel"] = env["addon_updateChannel"]
with codecs.open(source, "r", "utf-8") as f:
manifest_template = f.read()
manifest = manifest_template.format(**buildVars.addon_info)
manifest = manifest_template.format(**addon_info)
with codecs.open(dest, "w", "utf-8") as f:
f.write(manifest)

def generateTranslatedManifest(source, language, out):
_ = gettext.translation("nvda", localedir=os.path.join("addon", "locale"), languages=[language]).ugettext
# No ugettext in Python 3.
if sys.version_info.major == 2:
_ = gettext.translation("nvda", localedir=os.path.join("addon", "locale"), languages=[language]).ugettext
else:
_ = gettext.translation("nvda", localedir=os.path.join("addon", "locale"), languages=[language]).gettext
vars = {}
for var in ("addon_summary", "addon_description"):
vars[var] = _(buildVars.addon_info[var])
Expand Down Expand Up @@ -153,7 +173,7 @@ for mdFile in env.Glob(os.path.join('addon', 'doc', '*', '*.md')):
# Pot target
i18nFiles = expandGlobs(buildVars.i18nSources)
gettextvars={
'gettext_package_bugs_address' : 'nvda-translations@freelists.org',
'gettext_package_bugs_address' : 'nvda-translations@groups.io',
'gettext_package_name' : buildVars.addon_info['addon_name'],
'gettext_package_version' : buildVars.addon_info['addon_version']
}
Expand All @@ -172,3 +192,4 @@ env.Depends(manifest, "buildVars.py")

env.Depends(addon, manifest)
env.Default(addon)
env.Clean (addon, ['.sconsign.dblite', 'addon/doc/en/'])

0 comments on commit 7aec437

Please sign in to comment.