[nvda-addons] commit/addonTemplate: mhameed: Merged in addonDocSupport (pull request #1)

  • From: commits-noreply@xxxxxxxxxxxxx
  • To: nvda-addons@xxxxxxxxxxxxx
  • Date: Thu, 23 May 2013 04:39:21 -0000

1 new commit in addonTemplate:

https://bitbucket.org/nvdaaddonteam/addontemplate/commits/dce4b964973e/
Changeset:   dce4b964973e
Branch:      master
User:        mhameed
Date:        2013-05-23 06:39:19
Summary:     Merged in addonDocSupport (pull request #1)

Initial support for addon documentation.
Affected #:  2 files

diff --git a/README.md b/README.md
index c173c24..1a6d239 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,8 @@ To create a new NVDA add-on, taking advantage of this 
template:
 - In the **buildVars.py** file, change variable **addon_info** with your 
add-on's information (name, summary, description, version, author and url).
 - 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
new file mode 100644
index 0000000..da9c1d5
--- /dev/null
+++ b/docHandler.py
@@ -0,0 +1,41 @@
+# -*- coding: UTF-8 -*-
+
+# docHandler: module for managing addons documentation
+# See: http://community.nvda-project.org/ticket/2694
+
+import os
+import languageHandler
+
+_addonDir = os.path.join(os.path.dirname(__file__), "..") # The root of an 
addon folder
+_docFileName = "readme.html" # The name of an addon documentation file
+
+def getDocFolder(addonDir=_addonDir):
+       langs = [languageHandler.getLanguage(), "en"]
+       for lang in langs:
+               docFolder = os.path.join(addonDir, "doc", lang)
+               if os.path.isdir(docFolder):
+                       return docFolder
+               if "_" in lang:
+                       tryLang = lang.split("_")[0]
+                       docFolder = os.path.join(addonDir, "doc", tryLang)
+                       if os.path.isdir(docFolder):
+                               return docFolder
+                       if tryLang == "en":
+                               break
+               if lang == "en":
+                       break
+       return None
+
+def getDocPath(docFileName=_docFileName):
+       docPath = getDocFolder()
+       if docPath is not None:
+               docFile = os.path.join(docPath, docFileName)
+               if os.path.isfile(docFile):
+                       docPath = docFile
+       return docPath
+
+def openDocPath():
+       try:
+               os.startfile(getDocPath())
+       except WindowsError:
+               pass
\ No newline at end of file

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.

Other related posts:

  • » [nvda-addons] commit/addonTemplate: mhameed: Merged in addonDocSupport (pull request #1) - commits-noreply