Skip to content
Draft
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ ts/.svelte-kit
.yarn
.claude/settings.local.json
.claude/user.md
docs/_build/
docs/autoapi/
/docs/_static/
18 changes: 18 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2

sphinx:
configuration: docs/conf.py

build:
os: ubuntu-24.04
tools:
python: "3.13"
jobs:
pre_create_environment:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
create_environment:
- uv venv "$READTHEDOCS_VIRTUALENV_PATH"
install:
- UV_PROJECT_ENVIRONMENT="$READTHEDOCS_VIRTUALENV_PATH" uv sync --frozen --group docs
9 changes: 9 additions & 0 deletions docs/api-python-modules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# API Modules

```{toctree}
:maxdepth: 2
:glob:

autoapi/anki/*/index
autoapi/anki/*/*/index
```
9 changes: 9 additions & 0 deletions docs/api-python.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Python API

The pages below are generated from Python docstrings in `pylib/anki`.

```{toctree}
:maxdepth: 2

api-python-modules
```
15 changes: 15 additions & 0 deletions docs/api-rust.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Rust API

Anki's Rust API documentation is generated from doc comments in the `rslib/`
crates using `cargo doc`.

To browse the docs locally:

```
cargo doc --open
```

The main crates are:

- **anki** (`rslib/`) - Core library
- **anki_io** (`rslib/io/`) - I/O utilities
44 changes: 44 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from pathlib import Path

project = "Anki"
copyright = "Ankitects Pty Ltd and contributors"
author = "Ankitects Pty Ltd and contributors"

ROOT = Path(__file__).resolve().parents[1]

extensions = [
"myst_parser",
"sphinx.ext.intersphinx",
"autoapi.extension",
]

source_suffix = {
".rst": "restructuredtext",
".md": "markdown",
}

myst_enable_extensions = ["colon_fence", "deflist"]
html_theme = "sphinx_book_theme"
html_theme_options = {
"repository_url": "https://github.com/ankitects/anki",
"use_repository_button": True,
"use_issues_button": True,
"use_edit_page_button": True,
"path_to_docs": "docs",
"repository_branch": "main",
}

autoapi_type = "python"
autoapi_dirs = [str(ROOT / "pylib" / "anki")]
autoapi_root = "autoapi"
autoapi_keep_files = True
autoapi_add_toctree_entry = False
autoapi_python_use_implicit_namespaces = True
autoapi_options = [
"members",
"undoc-members",
"show-inheritance",
"show-module-summary",
]

exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
16 changes: 12 additions & 4 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,24 @@ See [this page](./build.md)

## Generating documentation

For Rust:
To build the documentation site from `docs/`:

```
cargo doc --open
uv run --group docs sphinx-build -b html docs out/docs/html
open out/docs/html/index.html
```

To build the API docs used by Anki's existing Python Sphinx pipeline:

```
./ninja python:sphinx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @abdnh and @andrewsanchez
When you run this command, does this work for you?
Because, on my side, when I try to run, I get an error.

In this line: https://github.com/ankitects/anki/blob/main/build/configure/src/python.rs#L233 I must change it to:

      "$uv sync --group sphinx && $python python/sphinx/build.py" // remove this line
      "$uv sync --group docs && $python python/sphinx/build.py" // add this line

Does it make sense?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't work, because the sphinx group was removed as you noted.

open out/python/sphinx/html/py-modindex.html
```

For Python:
For Rust API docs:

```
./ninja python:sphinx && open out/python/sphinx/html/py-modindex.html
cargo doc --open
```

## Environmental Variables
Expand Down
23 changes: 23 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Anki Documentation

## Prose

```{toctree}
:maxdepth: 2

readme
development
build
contributing
architecture
protobuf
```

## API

```{toctree}
:maxdepth: 2

api-python
api-rust
```
4 changes: 4 additions & 0 deletions docs/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Project README

```{include} ../README.md
```
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ dev = [
"types-waitress",
"types-pywin32",
]

[project.optional-dependencies]
sphinx = [
docs = [
"sphinx",
"sphinx_rtd_theme",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrewsanchez is there a reason to remove it?

I'm asking because when I try to run it, I get a build error, and I have to add it back to work welll

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I specified the html theme in conf.py so not sure why you're getting that error but I'll check!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, because I can't get it to run successfully locally.

"myst-parser",
"sphinx-book-theme",
"sphinx-autoapi",
]

Expand Down
2 changes: 1 addition & 1 deletion rslib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ sha1.workspace = true
snafu.workspace = true
strum.workspace = true
tempfile.workspace = true
tokio.workspace = true
tokio = { workspace = true, features = ["io-util"] }
tokio-util.workspace = true
tower-http.workspace = true
tracing.workspace = true
Expand Down
186 changes: 151 additions & 35 deletions uv.lock

Large diffs are not rendered by default.