OSDN Git Service

developer guide: add sections about how to create addons by hand.
authorMichael Curran <mick@kulgan.net>
Mon, 7 May 2012 07:16:00 +0000 (17:16 +1000)
committerMichael Curran <mick@kulgan.net>
Mon, 7 May 2012 07:16:00 +0000 (17:16 +1000)
developerGuide.t2t

index 6a1dfc3..4efcde9 100644 (file)
@@ -529,6 +529,69 @@ class LabelledEditField(Window):
 --- end ---\r
 ```\r
 \r
++ Packaging  code as  NVDA Addons +\r
+To make it easy for users to share and install plugins, they can be packaged in to a single NVDA addon archive, which the user can then install into a copy of NVDA, via its Addons manager found under Tools in the NVDA menu.\r
+An addon is simply a standard zip file with the file extension of nvda-addon which contains a manifest file,  optional  install/uninstall code, and  one or more  directories containing plugins and or drivers.\r
+++ Manifest files ++\r
+Each addon archive must contain a manifest file named manifest.ini.\r
+This manifest file contains key = value pares declaring such info as the addon's name, version and description.\r
++++ Available Fields +++\r
+Although it is highly suggested that manifests contain all fields, the fields marked as manditory must be included otherwize the addon will not install.  \r
+- name: a short unique name for the addon. Used to differentiate addons internally. (Manditory)\r
+- summary: a few words describing the addon. This is shown to the user as its display name. (Manditory)\r
+- version: The version of this addon e.g. 2.0. (Manditory)\r
+- author: The author of this addon, preferably taking the form of  Full Name <email address> e.g. Michael Curran <mick@kulgan.net>. (Manditory)\r
+- description: A sentence or two describing what the addon does in more  detail.\r
+- url: a url where this addon, further info and upgrades can be found.\r
+-\r
+\r
++++ An Example Manifest File +++\r
+```\r
+--- start ---\r
+name = MyTestAddon\r
+summary = Cool Test Addon\r
+version = 1.0\r
+description = An example addon showing how to create addons!\r
+author = Michael Curran <mick@kulgan.net>\r
+url = http://www.nvda-project.org/wiki/Development\r
+--- end ---\r
+``` \r
+\r
+++ Plugins and Drivers ++\r
+The following plugins and drivers can be included in an addon:\r
+- App modules: place them in an appModules directory in the archive.\r
+- Braille display drivers: place them in a brailleDisplayDrivers directory in the archive.\r
+- Global plugins: place them in a globalPlugins directory in the archive.\r
+- Synthesizer drivers: place them in a synthDrivers directory in the archive.\r
+-\r
+\r
+++ Optional install / Uninstall code ++\r
+If you need to execute code as your addon is being installed or uninstalled from NVDA (for example to validate license info or to copy files to a custom location), you can provide a Python   file called installTasks.py in the archive which contains special functions that NVDA will call while installing or uninstalling your addon.\r
+This file should try to not load any modules it does not need to,  especially   Python c extensions or dlls from your own addon, as this could cause later removal of the addon to fail.\r
+However if this does happen, the addon directory will be renamed and then   deleted after the next restart of NVDA. \r
+Finally, it should also  not depend on the existance or state of other addons, as they may not be installed, or have already been removed, or are not yet initialized.\r
++++ the onInstall function +++\r
+NVDA will look for and execute an onInstall function in installTasks.py after it has finished extracting the addon in to NVDA. \r
+Note that although the addon is extracted at this time, its directory has a .pendingInstall suffix until NVDA is restarted and the directory is renamed and the addon is really loaded for the first time.\r
+If this function raises an exception, the installation will fail and its directory will be cleaned up.\r
++++ The onUninstall Function +++\r
+NVDA will look for and execute an onUninstall function in installTasks.py when NVDA is restarted after the user has chosen to remove the addon.\r
+After this function completes, the addon's directory will automatically be removed.\r
+As this happens on NVDA startup before other components are initialized, this function cannot request input from the user.\r
+++ Localizing Addons ++\r
+It is possible to provide locale-specific info and messages for your addon.\r
+Locale information can be stored in a locale directory in the archive.\r
+This directory should contain directories for each language it supports, using the same language name format as the rest of NVDA (e.g. en for English, fr_CA for French Canadian).\r
++++ Locale-specific Manifest Files +++\r
+Each of these directories can contain a locale-specific manifest file called manifest.ini, which can contain a small subset of the fields for translation.\r
+These fields are summary, and description.\r
+All other fields will be ignored.\r
++++ Locale-specific Messages +++\r
+Each language directory can also contain gettext information, which is the system used to translate the rest of NVDA's user interface and reported messages. As like the rest of NVDA, an nvda.mo compiled gettext database file should be placed in the LC_MESSAGES directory within this directory.\r
+to allow plugins in your addon to access gettext message information via calls to _(), at the top of each file its necessary to initialize  translations by calling addonHandler.initTranslations() \r
+For more information about gettext and NVDA translation in general, please read\r
+http://www.nvda-project.org/wiki/TranslatingNVDA\r
\r
 + NVDA Python Console +[PythonConsole]\r
 The NVDA Python console emulates the interactive Python interpreter from within NVDA.\r
 It is a development tool which is useful for debugging, general inspection of NVDA internals or inspection of the accessibility hierarchy of an application.\r