Skip to content

Commit

Permalink
Merge pull request #15 from marlon-sousa/feat/nvda-2024.1-compatibility
Browse files Browse the repository at this point in the history
feat/nvda 2024.1 compatibility
  • Loading branch information
marlon-sousa authored Apr 12, 2024
2 parents 1fd5998 + 03e2ecc commit fd2cb36
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 27 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# EnhancedDictionaries 1.4.1
# EnhancedDictionaries 1.5.0
Nvda ADDON for handling more advanced dictionaries processing

## download
Download the [Enhanced Dictionaries 1.4.1 addon](https://github.com/marlon-sousa/EnhancedDictionaries/releases/download/1.4.1/EnhancedDictionaries-1.4.1.nvda-addon)
Download the [Enhanced Dictionaries 1.5.0 addon](https://github.com/marlon-sousa/EnhancedDictionaries/releases/download/1.5.0/EnhancedDictionaries-1.5.0.nvda-addon)

## Features

Expand Down
52 changes: 38 additions & 14 deletions addon/doc/en/contributing.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,57 @@
# Contributing


## building the addon


### Local environment

Although not mandatory, we suggest you perform the following:

1. Clone NVDA in a folder at the same level as this project.
For example, if this project is cloned at c:\projects\EnhancedDictionaries, NVDA should be cloned at c:\projects\nvda.
Perform a clone with the --recursive flag. If NVDA is already cloned, make sure it is up to date, fetching and then synchronizing the master branch with the NVDA upstream master branch.
Perform a git submodule update --init command to make sure git submodules are correctly synchronized.
2. Perform a git checkout in the release-2024.1 tag in the NVDA project. You don't need to build NVDA, just having the source code at the release branch is enough.
3. Install visual studio code, if it is not installed. Although you can use other environments, the optimal setup requires visual studio code.
4. Open the EnhancedDictionaries folder in VS Code. From command line, perform the "code ." command, or use the file / open folder menus on visual studio code itself and select the folder where this project is cloned.
5. Use ctrl + shift + x to access the extensions widget in Visual studio code. Tab umtil the recomended section and install the recomended extensions.
6. Restart visual studio code.
7. Now, whenever you are navigating through code, pressing f12 in a NVDA object should take you to its source in NVDA project.

### Dependencies

You will need:

* python 3.11 or above.
* python 3.11.
* pip must be configured
* scons (pip install scons)
* markdown (pip install markdown)
* pre-commit (pip install pre-commit)
* msgfmt utility. The easiest way of getting it is by installing git bash and choosing to include bash tools at command prompt

At the very first time you clone the repository, perform a
```
pre-commit install
```

to make sure pre-commit hooks are installed.
#### Pre-commit

It is strongly recomended that you install pre-commit.

* pip imstall pre-commit
* pre-commit install

This will imstall pre-commit and configure its hooks, so that whenever you perform a commit several checks will apply.
Should any of them fail, the commit will not be allowed.
This helps to ensure your commits have quality. You can bypass the check, however be aware that a pull request check will also apply these same checks and merge will be disabled should any of them fail, even if someone approves the pull request.

You can trigger the pre-commit checks at any time without performing a commit by issuing "pre-commit run --all-files".

#### Flake8

If there are quality failures, commits won't be allowed.
One of the pre-commit hooks is flake8, a python linter which, ammong other things, help to make sure the project has a consistent formating and that good practices are in place.

You can perform a pre test before commiting at any time by issuing
Visual Studio code recomended extensions include flake8, so that you can be warned while editing code when something needs to be fixed.

```
pre-commit run --all-files
```
The visual studio code extension and the pre-commit flake8 hooks use the same configuration.

Warning: if you do not install githooks (e.e issuing pre-commit install), your commits won't be cjhecked.
However, when submiting a pull request, there are checks that will block your commits if they fail passing pre-commit hooks. It is always best to fix quality issues before commiting.
### building

Once you have everything installed, issuing scons at the root of the project should build the addon and generate docs.

Expand Down
13 changes: 7 additions & 6 deletions addon/globalPlugins/EnhancedDictionaries/dictHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# See the file COPYING.txt for more details.

import config
from NVDAState import WritePaths
from logHandler import log
import speechDictHandler
from speechDictHandler import dictFormatUpgrade, dictionaries
Expand Down Expand Up @@ -81,7 +82,7 @@ def getDictionary(type):
# We will create it now and pass the new, empty dictionary to the caller, but won't save it.
# This is a task the caller should do when and if they wish
dic = speechDictHandler.SpeechDict()
dic.create(os.path.join(dictFormatUpgrade.speechDictsPath, profile.name, f"{type}.dic"))
dic.create(os.path.join(WritePaths.speechDictsDir, profile.name, f"{type}.dic"))
log.debug(
f"{type} dictionary was requested for profile {profile.name}, but the backing file does not exist."
f" A New dictionary was created, set to be backed by {dic.fileName} if it is ever saved."
Expand All @@ -94,7 +95,7 @@ def loadProfileDict():
if _hasDictionaryProfile(profile.name, "default.dic"):
_loadProfileDictionary(dictionaries["default"], profile.name, "default.dic")
else:
dictionaries["default"].load(os.path.join(dictFormatUpgrade.speechDictsPath, "default.dic"))
dictionaries["default"].load(os.path.join(WritePaths.speechDictsDir, "default.dic"))
dictionaries["builtin"].load("builtin.dic")


Expand All @@ -107,7 +108,7 @@ def loadVoiceDict(synth):
if(_hasVoiceDictionaryProfile(profile.name, synth.name, dictionaryFileName)):
_loadProfileVoiceDictionary(dictionaries["voice"], synth.name, dictionaryFileName)
else:
fileName = os.path.join(dictFormatUpgrade.voiceDictsPath, synth.name, dictionaryFileName)
fileName = os.path.join(WritePaths.voiceDictsDir, synth.name, dictionaryFileName)
dictionaries["voice"].load(fileName)


Expand All @@ -126,20 +127,20 @@ def _getVoiceDictionaryFileName(synth):


def _hasDictionaryProfile(profileName, dictionaryName):
return os.path.exists(os.path.join(dictFormatUpgrade.speechDictsPath, profileName or "", dictionaryName))
return os.path.exists(os.path.join(WritePaths.speechDictsDir, profileName or "", dictionaryName))


def getProfileVoiceDictsPath():
profile = config.conf.getActiveProfile()
return os.path.join(dictFormatUpgrade.speechDictsPath, profile.name or "", r"voiceDicts.v1")
return os.path.join(WritePaths.speechDictsDir, profile.name or "", r"voiceDicts.v1")


def _hasVoiceDictionaryProfile(profileName, synthName, voiceName):
return os.path.exists(os.path.join(getProfileVoiceDictsPath(), synthName, voiceName))


def _loadProfileDictionary(target, profileName, dictionaryName):
target.load(os.path.join(dictFormatUpgrade.speechDictsPath, profileName or "", dictionaryName))
target.load(os.path.join(WritePaths.speechDictsDir, profileName or "", dictionaryName))


def _loadProfileVoiceDictionary(target, synthName, voiceName):
Expand Down
2 changes: 1 addition & 1 deletion addon/globalPlugins/EnhancedDictionaries/guiHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def rebindMenu(menu, handler):


def showEnhancedDictionaryDialog(dic, title=None):
gui.mainFrame._popupSettingsDialog(EnhancedDictionaryDialog, title or __("Default dictionary"), dic)
gui.mainFrame.popupSettingsDialog(EnhancedDictionaryDialog, title or __("Default dictionary"), dic)


# This is our new dictionary dialog.
Expand Down
6 changes: 3 additions & 3 deletions buildVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ def _(x): return x
"addon_description": _("""This addon introduces better dictionaries handling for NVDA.
It is now possible to use profile specific dictionaries, which eenables better productivity by allowing you to use different dictionaries for different applications and scenarius."""),
# version
"addon_version": "1.4.1",
"addon_version": "1.5.0",
# Author(s)
"addon_author": u"Marlon Brandão de Sousa <[email protected]>",
# URL for the add-on documentation support
"addon_url": "https://github.com/marlon-sousa/EnhancedDictionaries",
# Documentation file name
"addon_docFileName": "readme.html",
# Minimum NVDA version supported (e.g. "2018.3.0", minor version is optional)
"addon_minimumNVDAVersion": "2022.1",
"addon_minimumNVDAVersion": "2024.1",
# Last NVDA version supported/tested (e.g. "2018.4.0", ideally more recent than minimum version)
"addon_lastTestedNVDAVersion": "2023.1",
"addon_lastTestedNVDAVersion": "2024.1",
# 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,
}
Expand Down
45 changes: 44 additions & 1 deletion contributing.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,58 @@
# Contributing


## building the addon


### Local environment

Although not mandatory, we suggest you perform the following:

1. Clone NVDA in a folder at the same level as this project.
For example, if this project is cloned at c:\projects\EnhancedDictionaries, NVDA should be cloned at c:\projects\nvda.
Perform a clone with the --recursive flag. If NVDA is already cloned, make sure it is up to date, fetching and then synchronizing the master branch with the NVDA upstream master branch.
Perform a git submodule update --init command to make sure git submodules are correctly synchronized.
2. Perform a git checkout in the release-2024.1 tag in the NVDA project. You don't need to build NVDA, just having the source code at the release branch is enough.
3. Install visual studio code, if it is not installed. Although you can use other environments, the optimal setup requires visual studio code.
4. Open the EnhancedDictionaries folder in VS Code. From command line, perform the "code ." command, or use the file / open folder menus on visual studio code itself and select the folder where this project is cloned.
5. Use ctrl + shift + x to access the extensions widget in Visual studio code. Tab umtil the recomended section and install the recomended extensions.
6. Restart visual studio code.
7. Now, whenever you are navigating through code, pressing f12 in a NVDA object should take you to its source in NVDA project.

### Dependencies

You will need:

* python 3.6 or above.
* python 3.11.
* pip must be configured
* scons (pip install scons)
* markdown (pip install markdown)
* msgfmt utility. The easiest way of getting it is by installing git bash and choosing to include bash tools at command prompt


#### Pre-commit

It is strongly recomended that you install pre-commit.

* pip imstall pre-commit
* pre-commit install

This will imstall pre-commit and configure its hooks, so that whenever you perform a commit several checks will apply.
Should any of them fail, the commit will not be allowed.
This helps to ensure your commits have quality. You can bypass the check, however be aware that a pull request check will also apply these same checks and merge will be disabled should any of them fail, even if someone approves the pull request.

You can trigger the pre-commit checks at any time without performing a commit by issuing "pre-commit run --all-files".

#### Flake8

One of the pre-commit hooks is flake8, a python linter which, ammong other things, help to make sure the project has a consistent formating and that good practices are in place.

Visual Studio code recomended extensions include flake8, so that you can be warned while editing code when something needs to be fixed.

The visual studio code extension and the pre-commit flake8 hooks use the same configuration.

### building

Once you have everything installed, issuing scons at the root of the project should build the addon and generate docs.

## translations
Expand Down

0 comments on commit fd2cb36

Please sign in to comment.