From 530ab6d6dbdbb438e40d576d0edae473a1236d9c Mon Sep 17 00:00:00 2001 From: David Culley <6276049+davidculley@users.noreply.github.com> Date: Sat, 24 Aug 2024 06:12:38 +0200 Subject: [PATCH 1/5] docs: revise section about library code --- docs/architecture.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index 990137b2b37..52c4210d89e 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -10,18 +10,20 @@ A neat visualization of the file layout is available here: (or go to and enter `ankitects/anki`). -### Library (rslib & pylib) +### Library (`rslib/` and `pylib/`) -The Python library (pylib) exports "backend" methods - opening collections, -fetching and answering cards, and so on. It is used by Anki’s GUI, and can also -be included in command line programs to access Anki decks without the GUI. +The code responsible for the actual logic (opening collections, fetching and answering cards, et cetera) — the "backend" methods — is written parts in Python, parts in Rust. +Most of the logic previously implemented in Python was rewritten in Rust so that the code can be shared between the different Anki apps. -The library is accessible in Python with "import anki". Its code lives in -the `pylib/anki/` folder. +- The parts of the library code written in Python are located in `pylib/` (more specifically, in `pylib/anki/`). +- The parts of the library code written in Rust are located in `rslib/`. -These days, the majority of backend logic lives in a Rust library (rslib, located in `rslib/`). Calls to pylib proxy requests to rslib, and return the results. +The Python code serves as proxy for the Rust library and, when called, forwards the requests to the code in `rslib/` which does the actual computations and then returns the results to the code in `pylib/anki/`. +The way that is implemented is by way of a Python binding named `rsbridge` within `pylib/` (that is, `pylib/rsbridge/`) that wraps around the Rust code and makes the logic implemented in Rust accessible with Python code. -pylib contains a private Python module called rsbridge (`pylib/rsbridge/`) that wraps the Rust code, making it accessible in Python. +The Python library is made available as a Python package named `anki` and is accessible through `import anki` in Python code. + +Anki’s GUI relies on this Python library (located in `pylib/anki/`) and you can use it too (by installing it with `pip install anki`) if you want to develop command line programs to programmatically access your Anki decks without the need of running Anki’s GUI. ### GUI (aqt & ts) From 4fcd01a26fe541a773914cbcdc95f69efd05a2b6 Mon Sep 17 00:00:00 2001 From: David Culley <6276049+davidculley@users.noreply.github.com> Date: Sat, 24 Aug 2024 06:12:59 +0200 Subject: [PATCH 2/5] docs: revise section about GUI code --- docs/architecture.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index 52c4210d89e..b3ef0b4b141 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -25,13 +25,14 @@ The Python library is made available as a Python package named `anki` and is acc Anki’s GUI relies on this Python library (located in `pylib/anki/`) and you can use it too (by installing it with `pip install anki`) if you want to develop command line programs to programmatically access your Anki decks without the need of running Anki’s GUI. -### GUI (aqt & ts) +### GUI (`qt/` and `ts/`) -Anki's _GUI_ is a mix of Qt (via the PyQt Python bindings for Qt), and -TypeScript/HTML/CSS. The Qt code lives in `qt/aqt/`, and is importable in Python -with "import aqt". The web code is split between `qt/aqt/data/web/` and `ts/`, -with the majority of new code being placed in the latter, and copied into the -former at build time. +Anki’s GUI is written parts in Python using the toolkit Qt (via Qt's Python bindings known as PyQt), and parts in a mix of TypeScript, HTML, and CSS. + +The Python code that implements Anki’s GUI (using PyQt) is located in `qt/aqt/`. It’s made available as a Python package named `aqt` (installable with `pip install 'aqt[qt6]'`) and is accessible through `import aqt` in Python code. + +The web code is split between `ts/` and `qt/aqt/data/web/`. +The majority of new code now goes into `ts/` rather than `qt/aqt/data/web/` and, during the build process, gets copied into `qt/aqt/data/web/` instead. ## Protobuf From 07a726961366e09ba285ae41f9d992238480ab0f Mon Sep 17 00:00:00 2001 From: David Culley <6276049+davidculley@users.noreply.github.com> Date: Sat, 24 Aug 2024 06:15:16 +0200 Subject: [PATCH 3/5] docs: revise section about architecture --- docs/architecture.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index b3ef0b4b141..df66e19d044 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -2,13 +2,12 @@ Very brief notes for now. -## Backend/GUI +## Backend and GUI -At the highest level, Anki is logically separated into two parts. +At the highest level, the Anki codebase is logically separated into two parts: -A neat visualization of the file layout is available here: - -(or go to and enter `ankitects/anki`). +- the GUI code +- the backend code ### Library (`rslib/` and `pylib/`) @@ -34,6 +33,10 @@ The Python code that implements Anki’s GUI (using PyQt) is located in `qt/aqt/ The web code is split between `ts/` and `qt/aqt/data/web/`. The majority of new code now goes into `ts/` rather than `qt/aqt/data/web/` and, during the build process, gets copied into `qt/aqt/data/web/` instead. +### Visualization of the code base + +A neat visualization of the file layout is available [here](https://mango-dune-07a8b7110.1.azurestaticapps.net/?repo=ankitects%2Fanki) (or go to [here](https://githubnext.com/projects/repo-visualization#explore-for-yourself) instead and enter `ankitects/anki`). + ## Protobuf Anki uses Protocol Buffers to define backend methods, and the storage format of From 758eec7f043fb9243d4c953a99404ec9761d7d9e Mon Sep 17 00:00:00 2001 From: David Culley <6276049+davidculley@users.noreply.github.com> Date: Sat, 24 Aug 2024 06:17:59 +0200 Subject: [PATCH 4/5] docs: switch sections about GUI and backend --- docs/architecture.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index df66e19d044..4f281051c0b 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -9,6 +9,15 @@ At the highest level, the Anki codebase is logically separated into two parts: - the GUI code - the backend code +### GUI (`qt/` and `ts/`) + +Anki’s GUI is written parts in Python using the toolkit Qt (via Qt's Python bindings known as PyQt), and parts in a mix of TypeScript, HTML, and CSS. + +The Python code that implements Anki’s GUI (using PyQt) is located in `qt/aqt/`. It’s made available as a Python package named `aqt` (installable with `pip install 'aqt[qt6]'`) and is accessible through `import aqt` in Python code. + +The web code is split between `ts/` and `qt/aqt/data/web/`. +The majority of new code now goes into `ts/` rather than `qt/aqt/data/web/` and, during the build process, gets copied into `qt/aqt/data/web/` instead. + ### Library (`rslib/` and `pylib/`) The code responsible for the actual logic (opening collections, fetching and answering cards, et cetera) — the "backend" methods — is written parts in Python, parts in Rust. @@ -24,15 +33,6 @@ The Python library is made available as a Python package named `anki` and is acc Anki’s GUI relies on this Python library (located in `pylib/anki/`) and you can use it too (by installing it with `pip install anki`) if you want to develop command line programs to programmatically access your Anki decks without the need of running Anki’s GUI. -### GUI (`qt/` and `ts/`) - -Anki’s GUI is written parts in Python using the toolkit Qt (via Qt's Python bindings known as PyQt), and parts in a mix of TypeScript, HTML, and CSS. - -The Python code that implements Anki’s GUI (using PyQt) is located in `qt/aqt/`. It’s made available as a Python package named `aqt` (installable with `pip install 'aqt[qt6]'`) and is accessible through `import aqt` in Python code. - -The web code is split between `ts/` and `qt/aqt/data/web/`. -The majority of new code now goes into `ts/` rather than `qt/aqt/data/web/` and, during the build process, gets copied into `qt/aqt/data/web/` instead. - ### Visualization of the code base A neat visualization of the file layout is available [here](https://mango-dune-07a8b7110.1.azurestaticapps.net/?repo=ankitects%2Fanki) (or go to [here](https://githubnext.com/projects/repo-visualization#explore-for-yourself) instead and enter `ankitects/anki`). From e16e8877c75497ffc6f914223370c2140dc20e4b Mon Sep 17 00:00:00 2001 From: David Culley <6276049+davidculley@users.noreply.github.com> Date: Sun, 25 Aug 2024 15:07:38 +0200 Subject: [PATCH 5/5] docs: use 'for example' rather than 'et cetera' --- docs/architecture.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/architecture.md b/docs/architecture.md index 4f281051c0b..744b11c4526 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -20,7 +20,7 @@ The majority of new code now goes into `ts/` rather than `qt/aqt/data/web/` and, ### Library (`rslib/` and `pylib/`) -The code responsible for the actual logic (opening collections, fetching and answering cards, et cetera) — the "backend" methods — is written parts in Python, parts in Rust. +The code responsible for the actual logic (for example, opening collections, or fetching and answering cards) — the "backend" methods — is written parts in Python, parts in Rust. Most of the logic previously implemented in Python was rewritten in Rust so that the code can be shared between the different Anki apps. - The parts of the library code written in Python are located in `pylib/` (more specifically, in `pylib/anki/`).