Skip to content

Add nx routes command - #590

Merged
Espoir-Loem merged 6 commits into
NexyPy:developfrom
WinnrDz:feature/nx-routes
Nov 24, 2026
Merged

Espoir-Loem merged 6 commits into
NexyPy:developfrom
WinnrDz:feature/nx-routes

Conversation

@WinnrDz

@WinnrDz WinnrDz commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #455.

Adds the nx routes CLI command to display application routes, their HTTP methods, paths, and source files.

Additional changes:

  • Sorts routes by path.
  • Excludes the framework's favicon route.
  • Adds translations to all 12 CLI locale catalogs.
  • Adds unit tests for route listing, sorting, and empty results.
  • Updates CLI documentation and changelog.

AI assistance disclosure: To be honest, I wasn't ready for this issue, and it's my first ever issue so i didnt want to leave it incomplete, i tried to learn about cli commands and python, but i couldnt understand how to start, i decided to use Ai and ended up vibe coding the entire solution.

How did you test this change?

Ran:

python -m pytest tests/unit/nexy/cli/test_routes.py tests/unit/nexy/i18n/test_cli_catalogs.py -q

Result:

96 passed in 6.93s

Also ran:

git diff --check

No whitespace errors were reported. Git displayed CRLF-to-LF warnings for the translation files.

The full python scripts/verify.py command has not been run.

Checklist

  • python scripts/verify.py passes (not run yet).
  • Each new behaviour has a test that failed before the change (test-first workflow was not followed).
  • Each commit changes one file written by hand, with its test (not followed).
  • Commit messages follow Conventional Commits.
  • No AI tool appears as author or co-author (verify the commit author and trailers).
  • A new docs page is listed in docs/README.md and llms.txt (not applicable; no new docs page was added).

@WinnrDz
WinnrDz requested a review from Espoir-Loem as a code owner November 21, 2026 09:46
@github-actions github-actions Bot added area:cli The nx command area:docs docs/, the sites, README and llms.txt labels Nov 21, 2026
@Espoir-Loem

Copy link
Copy Markdown
Member

Hi @WinnrDz, thanks for picking up #455 and for being transparent in the PR description. The nx routes command is in the right direction, but there are a few things to fix before it can be reviewed/merged.

1) Base branch

This PR targets main, but Nexy development happens on develop (like #477). Please retarget the PR to develop (GitHub UI: Edit next to the PR title / base branch, or gh pr edit 590 --base develop) and make sure your branch is up to date with develop.

2) CI failures

A. quality (3.12/3.13/3.14/3.15) fail on ruff

All 4 quality jobs fail at ruff check with the same 2 errors:

W292 No newline at end of file
  --> nexy/modules/cli/commands/routes.py:43
W292 No newline at end of file
  --> tests/unit/nexy/cli/test_routes.py:73

Fix: add a trailing newline at the end of both files (or run ruff check --fix nexy/modules/cli/commands/routes.py tests/unit/nexy/cli/test_routes.py).

B. Windows (3.13) fails with 45 tests

There are two causes:

1. tests/unit/nexy/cli/test_routes.py::test_routes_reports_when_no_routes_exist

On Windows, the app exposes framework doc routes, so the test gets a table containing /docs and /openapi.json instead of No routes found.:

AssertionError: assert 'No routes found.' in '... /docs ... /openapi.json ...'

The command currently excludes only /favicon.ico. Since the CLI/docs message says "If no application routes are found, it prints No routes found.", framework routes like FastAPI docs should also be treated as non-application routes. A simple fix is to exclude known framework paths in nexy/modules/cli/commands/routes.py, for example:

_FRAMEWORK_PATHS = {
    "/favicon.ico",
    "/docs",
    "/openapi.json",
    "/redoc",
    "/docs/oauth2-redirect",
}

...
found = sorted(
    (
        route
        for route in routes_of(application.server)
        if route["path"] not in _FRAMEWORK_PATHS
    ),
    key=lambda route: route["path"],
)

(Adjust the set if needed, but keep it explicit and small.) Then make sure the empty-routes test still reflects the intended behavior.

2. 44 translation tests fail for docs/reference/cli.md

You updated docs/reference/cli.md, but the translated pages were not regenerated. tests/unit/sites/test_translations.py fails for 11 locales × 4 tests (ar, de, es, fr, hi, id, ja, ko, pt, ru, zh), e.g.:

FAILED tests/unit/sites/test_translations.py::... [zh/reference/cli.md]
AssertionError: assert 35 == 36  (table row missing)

Per the repo conventions, never edit files under docs/<code>/ by hand. Regenerate them from the English page:

uv run python scripts/translate_docs.py

(or --lang <code> for specific languages; running it without --lang updates changed pages across languages). This should update docs/*/reference/cli.md and the corresponding docs/<code>/TRANSLATIONS.json entries for that page.

3) Before pushing

Please run locally (on the develop-based branch):

python -m pytest tests/unit/nexy/cli/test_routes.py tests/unit/nexy/i18n/test_cli_catalogs.py -q
python -m pytest tests/unit/sites/test_translations.py -q
ruff check nexy/modules/cli/commands/routes.py tests/unit/nexy/cli/test_routes.py
python scripts/verify.py

python scripts/verify.py runs the same gates as CI.

4) Repo conventions to keep in mind

  • Conventional Commits: feat(cli): ..., fix(cli): ..., docs: ..., etc.
  • One file, one commit (with its test, and for a docs page its translations + TRANSLATIONS.json line) as described in AGENTS.md / CONTRIBUTING. The current 2 commits mix several concerns; it may be easier to reorganize before the final review.
  • No AI tool as author/co-author: the attribution check is currently green, so keep commit metadata clean.

If you use an AI coding assistant, you can ask it to inspect and fix this PR with gh, for example: gh pr checks 590, gh run view <run-id> --job <job-id> --log-failed, then apply the fixes above (newlines, framework route filtering, regenerate translations), run python scripts/verify.py, and commit/push the changes. If you prefer to do it manually, the points above should be enough to get the CI green.

@WinnrDz
WinnrDz changed the base branch from main to develop November 23, 2026 08:27
@Espoir-Loem
Espoir-Loem marked this pull request as draft November 24, 2026 12:40
@Espoir-Loem
Espoir-Loem marked this pull request as ready for review November 24, 2026 12:40
# Conflicts:
#	docs/ar/TRANSLATIONS.json
#	docs/ar/reference/cli.md
#	docs/bn/TRANSLATIONS.json
#	docs/bn/reference/cli.md
#	docs/de/TRANSLATIONS.json
#	docs/es/TRANSLATIONS.json
#	docs/fr/TRANSLATIONS.json
#	docs/fr/reference/cli.md
#	docs/hi/TRANSLATIONS.json
#	docs/hi/reference/cli.md
#	docs/id/TRANSLATIONS.json
#	docs/id/reference/cli.md
#	docs/pt/TRANSLATIONS.json
#	docs/pt/reference/cli.md
#	docs/ru/TRANSLATIONS.json
#	docs/ru/reference/cli.md
#	docs/ur/TRANSLATIONS.json
#	docs/ur/reference/cli.md
#	docs/zh/TRANSLATIONS.json
#	docs/zh/reference/cli.md
@Espoir-Loem
Espoir-Loem merged commit 88b2183 into NexyPy:develop Nov 24, 2026
10 checks passed
@Espoir-Loem

Copy link
Copy Markdown
Member

Merged to develop as 88b2183. Thank you @WinnrDz for sticking with this: the command, the tests, the locale catalogs and the regenerated documentation are all in place, and CI is green. The merge also resolves the conflict with the v2.10.0 release branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:cli The nx command area:docs docs/, the sites, README and llms.txt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add nx routes: list every route and the file that answers it

2 participants