Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: PR Checks

on:
pull_request:
branches: [main, master]
workflow_dispatch:

permissions:
contents: read
pull-requests: write

jobs:
validate:
uses: ./.github/workflows/validate.yml
with:
upload_artifacts: true

comment_packaged_artifact:
runs-on: ubuntu-latest
needs: [validate]
if: github.event_name == 'pull_request'
steps:
- name: Comment packaged artifact link on PR
uses: actions/github-script@v7
env:
ARTIFACT_URL: ${{ needs.validate.outputs.artifact_url }}
with:
script: |
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
const commitSha = context.payload.pull_request?.head?.sha || context.sha;
const shortSha = commitSha.slice(0, 7);
const artifactLine = process.env.ARTIFACT_URL
? `- Artifact: ${process.env.ARTIFACT_URL}`
: '- Artifact: not available (check the run page below)';

const body = [
'### Packaged add-on artifact',
`- Commit: ${shortSha} (${commitSha})`,
artifactLine,
`- Run: ${runUrl}`,
].join('\n');

const issue_number = context.payload.pull_request.number;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number,
body,
});
29 changes: 0 additions & 29 deletions .github/workflows/pr-validation.yml

This file was deleted.

62 changes: 0 additions & 62 deletions .github/workflows/release-addon.yml

This file was deleted.

75 changes: 75 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Release Add-on

on:
push:
tags:
- "**"
workflow_dispatch:

jobs:
validate:
uses: ./.github/workflows/validate.yml
with:
upload_artifacts: false

release_addon:
if: startsWith(github.ref, 'refs/tags/')
needs: [validate]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses:
actions/checkout@v4

# The next step is used to fix a small issue here to obtain the current tag message,
# which will be used as the release body. For more details:
# https://github.com/actions/checkout/issues/290
- name: Make sure we have the correct tag information
run: git fetch --tags --force

- name: Obtain tag message
uses: ericcornelissen/git-tag-annotation-action@v2
id: tag-data

- name: Check differences to main branch
id: differences-to-main
run: |
git fetch origin main --depth=1
if git diff origin/main --exit-code; then
echo "changes_exist=false" >> "$GITHUB_OUTPUT"
else
echo "changes_exist=true" >> "$GITHUB_OUTPUT"
fi

- name: Abort if tag is not applied on top of main
if: steps.differences-to-main.outputs.changes_exist == 'true'
uses: actions/github-script@v7
with:
script: |
core.setFailed('Releases can be generated only from commit on head of main branch')

- name: Install system dependencies
run: sudo apt install gettext

- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install Python dependencies
run: |
pip install scons
pip install markdown

- name: Generate addon
run: |
rm -f *.nvda-addon || true
scons

- name: Release
uses: softprops/action-gh-release@v1
with:
files: "*.nvda-addon"
body: "${{ steps.tag-data.outputs.git-tag-annotation }}"
fail_on_unmatched_files: true
generate_release_notes: false
60 changes: 60 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Validate Add-on

on:
workflow_call:
inputs:
upload_artifacts:
description: Upload build artifacts for this validation run
required: false
type: boolean
default: false
outputs:
artifact_url:
description: URL for the uploaded artifact (when upload_artifacts is true)
value: ${{ jobs.build_and_check.outputs.artifact_url }}
workflow_dispatch:

jobs:
build_and_check:
runs-on: ubuntu-latest
env:
ARTIFACT_RETENTION_DAYS: 7
outputs:
artifact_url: ${{ steps.upload_build_artifacts.outputs.artifact-url }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install system dependencies
run: sudo apt install gettext

- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install Python dependencies
run: |
pip install pre-commit
pip install scons
pip install markdown

- name: Code checks
run: pre-commit run --all-files

- name: Build addon and pot
run: |
rm -f *.nvda-addon *.pot || true
scons
scons pot

- name: Upload build artifacts
id: upload_build_artifacts
if: ${{ inputs.upload_artifacts }}
uses: actions/upload-artifact@v4
with:
name: packaged_addon
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
path: |
./*.nvda-addon
./*.pot
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ addon/doc/**/*.md
*.py[co]
*.nvda-addon
.sconsign.dblite
.playwright-mcp/
test-results/
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: check-case-conflict
- id: check-yaml
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 7.1.1
hooks:
- id: flake8
args: [--config=flake8.ini]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# CustomAppModulesMapper 0.2.0
# CustomAppModulesMapper 0.3.0

Nvda ADDON for allowing dynamic mapping of existing app modules for other applications.

## download
Download the [CustomAppModulesMapper 0.2.0 addon](https://github.com/marlon-sousa/CustomAppModulesMapper/releases/download/0.2.0/CustomAppModulesMapper-0.2.0.nvda-addon)
Download the [CustomAppModulesMapper 0.3.0 addon](https://github.com/marlon-sousa/CustomAppModulesMapper/releases/download/0.3.0/CustomAppModulesMapper-0.3.0.nvda-addon)

## How it works

Expand Down
14 changes: 14 additions & 0 deletions addon/appModules/notAssociated.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: UTF-8 -*-
# A part of the CustomAppModulesMapper addon for NVDA
# Copyright (C) 2024 Marlon Sousa
# This file is covered by the MIT License.
# See the file COPYING.txt for more details.

import appModuleHandler


# A deliberately empty app module. Mapping an application to "notAssociated" gives it a neutral
# app module that adds no app specific behavior, which effectively detaches the application from
# whatever module NVDA would otherwise load for it.
class AppModule(appModuleHandler.AppModule):
pass
77 changes: 77 additions & 0 deletions addon/doc/en/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# 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\CustomAppModulesMapper, 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-2026.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 CustomAppModulesMapper 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.13.
* pip must be configured
* scons (pip install scons)
* markdown (pip install markdown)
* gettext, which provides the `msgfmt` and `xgettext` utilities. `msgfmt` compiles the translation files on every build, and `xgettext` is used by `scons pot` to generate the translation template. On Windows, install a modern build from [gettext-iconv-windows](https://github.com/mlocati/gettext-iconv-windows/releases) (or use `scoop install gettext` / `choco install gettext`), and make sure its `bin` directory comes before any other gettext on your PATH. Do not use the GnuWin32 gettext package: it is frozen at version 0.14.4 (2005) and is too old for this build (`scons pot` fails on the unsupported `--package-name` option).


#### 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

### translating the addon

Assuming you have everything set up to build the addom (see previous topic) issuing scons pot should generate a pot file at the root project directory. It is them possible to generate and contribute the .po files for your language.
Current languages can be found at /addon/locale directory

### translating documentation

Documentation translations are generated from .tpl.md (not from .md) files. This is why, except from this file (read.md) at the root of the project, you won't find other .md files.

The .tpl.md files are normal markdown files with one addition: if you use ${[var]} within its text, [var] will be replaced by a var with the same name defined in buildvars.py when the corresponding md and.html files are generated.

If no variable with that name exists, the substitution doesn't take place.

This is useful for example to generate links and titles with the addon version included without having to rewrite documentation.

To translate documentation, grab the readme.tpl.md file at the root of the project and translate it. The translated file must be named readme.tpl.md and must be placed inside the addon/doc/[lang] directory.

The ${[xxx]} vars need to stay untouched. To generate the docs, issue scons and the markdown and HTML will be generated.
Loading
Loading