Skip to content

Commit

Permalink
Build vars and SConstruct: incorporate add-on template changes.
Browse files Browse the repository at this point in the history
Changes include Python 3 build requirement, copyright header update, and Markdown extensions support for docs.
  • Loading branch information
josephsl committed Mar 4, 2021
1 parent 1798d08 commit f30d888
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
7 changes: 7 additions & 0 deletions buildVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,10 @@ def _(arg):
# If your add-on is written in a language other than english, modify this variable.
# For example, set baseLanguage to "es" if your add-on is primarily written in spanish.
baseLanguage = "en"

# Markdown extensions for add-on documentation
# Most add-ons do not require additional Markdown extensions.
# If you need to add support for markup such as tables, fill out the below list.
# Extensions string must be of the form "markdown.extensions.extensionName"
# e.g. "markdown.extensions.tables" to add tables.
markdownExtensions = []
22 changes: 13 additions & 9 deletions sconstruct
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# NVDA add-on template SCONSTRUCT file
# Copyright (C) 2012-2020 Rui Batista, Noelia Martinez, Joseph Lee
# Copyright (C) 2012-2021 Rui Batista, Noelia Martinez, Joseph Lee
# This file is covered by the GNU General Public License.
# See the file COPYING.txt for more details.

Expand All @@ -24,9 +24,17 @@ import buildVars # NOQA: E402

def md2html(source, dest):
import markdown
# Use extensions if defined.
mdExtensions = buildVars.markdownExtensions
lang = os.path.basename(os.path.dirname(source)).replace('_', '-')
localeLang = os.path.basename(os.path.dirname(source))
try:
_ = gettext.translation("nvda", localedir=os.path.join("addon", "locale"), languages=[localeLang]).gettext
summary = _(buildVars.addon_info["addon_summary"])
except Exception:
summary = buildVars.addon_info["addon_summary"]
title = "{addonSummary} {addonVersion}".format(
addonSummary=buildVars.addon_info["addon_summary"], addonVersion=buildVars.addon_info["addon_version"]
addonSummary=summary, addonVersion=buildVars.addon_info["addon_version"]
)
headerDic = {
"[[!meta title=\"": "# ",
Expand All @@ -36,7 +44,7 @@ def md2html(source, dest):
mdText = f.read()
for k, v in headerDic.items():
mdText = mdText.replace(k, v, 1)
htmlText = markdown.markdown(mdText)
htmlText = markdown.markdown(mdText, extensions=mdExtensions)
# Optimization: build resulting HTML text in one go instead of writing parts separately.
docText = "\n".join([
"<!DOCTYPE html>",
Expand Down Expand Up @@ -160,11 +168,7 @@ def generateManifest(source, dest):


def generateTranslatedManifest(source, language, out):
# 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
_ = 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 @@ -229,4 +233,4 @@ env.Depends(manifest, "buildVars.py")

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

0 comments on commit f30d888

Please sign in to comment.