Re: NVDA addon creation development environment #addon

Andy B.


Right now it is impossible to have add-ons use autocomplete in an editor/IDE. As mentioned, parts of NVDA aren't running or loaded yet. For example, how is a non working copy of NVDA (the source) going to know what add-ons the current running copy (portable/installed) is running at the time? This is the problem we run into with creating development environments. Tests might work, but the unit tests have to be installed in the working copy. An earlier thread proved that NVDA tries to cut down the amount of weight it has to carry around, so this might not work. However, NVDA could make an add-on that contains the tests. It could then be installed in the current working copy without forcing everyone to download a heavy installer. We could then write add-on tests against the tests add-on by importing its namespaces/modules, then disconnect the tests from the production version of the add-on. An easier way for now is to use the nvda python terminal to test your add-on code. In fact, Developer toolkit was written entirely in the nvda python terminal before getting put into files. In other words, Developer toolkit's features are tested one by one in the nvda python terminal before they are put into testing/production. I even went so far as to test color conversion and pairing routines in the nvda python terminal. I know my idea works before my research is complete.

On Mon, Feb 10, 2020 at 6:10 PM James Scholes <james@...> wrote:
I don't think this is going to work the way you want.  When you say:

 > cloned nvda-vscode into the root of that folder under .vscode

... I assume you're referring to this:

But AFAIK, that is only for development of NVDA itself, rather than add-ons.

I've been out of the loop for a while, so someone can correct me if I'm
wrong.  But my understanding is that to date, nobody has created a
method of accessing and testing NVDA-specific Python modules without a
running copy of the screen reader.  Even if they had, several parts of
NVDA depend on others which cannot yet be instantiated outside of the
context of a running copy.  That may change in the future, or someone
may come up with mocked objects for testing purposes.

In terms of your test module not appearing to be present, it's because
code is no longer loaded from %appdata%\roaming\nvda\appModules.  You'll
need to enable the developer scratchpad in Settings -> Advanced, and
then use %appdata%\roaming\nvda\scratchpad\appModules instead.

In many ways, NVDA add-on development is still in its infancy.  Nobody
does TDD, for example, because there isn't yet a way to facilitate it.
The same extends to support within an IDE.  Contributions in this arena
are very much welcome though!


James Scholes

On 10/02/2020 at 3:46 pm, Florian Beijers wrote:
> Hi,
> So first, if this isn't the place to ask this question, please let me
> know. It seemed the most suitable, but I might have missed a resource :)
> I am trying to create a development environment for creating addons
> based on Visual Studio Code. I am running into a bit of a snag though,
> hoping someone here might know what I am missing. My steps:
> - recursively cloned nvaccess/nvda
> - cloned nvda-vscode into the root of that folder under .vscode
> - Opened the folder using file -> open folder... in Visual Studio Code
> Insiders.
> - As a test, I wanted to build the example in the developer
> guide to see if intellisense and such would come up. So I added
> %appdata%\roaming\nvda\appModules to the workspace.
> - Selected my python interpreter as being python 3.8.1 32-bit within the
> global scope for both folders in the workspace, this setting invoked
> through a gesture appears to be folder-specific rather than workspace-wide.
> - Created a new file within appModules called with the
> following content:
> import appModuleHandler
> class AppModule(appModuleHandler.AppModule):
> pass
> After doing all this, these are my observations:
> - The visual studio code problems view reports appModuleHandler could
> not be imported.
> - Similarly, autocomplete does not come up for NVDA-specific options.
> - My appModule is not loaded according to nvda+ctrl+f1. However, that
> could have to do with the pass statement, does that unload the module?
> A few questions:
> - Does anyone see something obvious I might have missed?
> - When I run scons source to prepare the source tree, scons tells me it
> can't find python 3.7-32. This is true, I don't have that specific
> version of Python installed. Is that why this is happening?
> - Am I on completely the wrong track and can I get NVDA's python context
> into VS Code some other way?
> Thanks a bunch for any help :)

Join to automatically receive all group messages.