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
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ You can use the `canopy_build` script to download the spec files, generate the C
**Downloading or updating all spec files**

```bash
canopy_build fetch-specs --specs-dir specs/
canopy_build fetch-specs --specs-dir specs/ --base-url https://yourschool.instructure.com
```

**Download or update an individual spec file**

```bash
canopy_build fetch-specs --specs-dir specs/ --spec accounts.json
canopy_build fetch-specs --specs-dir specs/ --base-url https://yourschool.instructure.com --spec accounts.json
```

> **Note:** Instructure has started to timeout the download script after so many downloads, after that you will get 202 errors. It's recommended to either download them individually or use a downloading extension in your browser to download all the spec files.
Expand Down Expand Up @@ -178,6 +178,7 @@ Pass it to any command that processes multiple specs via `--exclude-file`:
```bash
canopy_build fetch-specs \
--specs-dir specs/ \
--base-url https://yourschool.instructure.com \
--exclude-file excluded_specs.toml

canopy_build build-all \
Expand Down Expand Up @@ -238,7 +239,7 @@ canopy_docs generate-all \
```python
from canvas_client import CanvasClient

canvas_url = "https://abc.instructure.com"
canvas_url = "https://yourschool.instructure.com"
token = "your_token_here"

client = CanvasClient(canvas_url, token, max_per_page=100)
Expand Down Expand Up @@ -281,7 +282,7 @@ import asyncio
from canvas_client import CanvasClient
from time import perf_counter

canvas_url = "https://abc.instructure.com"
canvas_url = "https://yourschool.instructure.com"
token = "your_token_here"

client = CanvasClient(canvas_url, token, max_per_page=100)
Expand Down
13 changes: 11 additions & 2 deletions canopy/scripts/canvas_api_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,18 @@ def rebuild(
type=click.Path(exists=True, dir_okay=False, readable=True, path_type=Path),
help="TOML file listing spec filenames to exclude from downloading.",
)
def fetch_specs(specs_dir: Path, spec: str | None, exclude_file: Path | None) -> None:
@click.option(
"-b",
"--base-url",
default="https://canvas.instructure.com",
show_default=True,
help="Your Canvas instance URL (e.g. https://yourschool.instructure.com). The /doc/api/ path is appended automatically.",
)
def fetch_specs(
specs_dir: Path, spec: str | None, exclude_file: Path | None, base_url: str
) -> None:
"""Fetch spec files from the Instructure Canvas API docs."""
base_url = "https://canvas.instructure.com/doc/api/"
base_url = base_url.rstrip("/") + "/doc/api/"
excluded = load_excluded_specs(exclude_file)

if spec:
Expand Down
Loading