Skip to main content

Simple CLI wrapper for the Readthedocs REST API

Project description

rtd: simple Readthedocs CLI

Install

pip install rtd-cli
# Set this env var, or write the token to ~/.config/rtd-cli/token
 RTD_TOKEN=your_token

Usage

rtd --help
# Usage: rtd [OPTIONS] COMMAND [ARGS]...
#
#   Simple CLI wrapper for the Readthedocs REST API.
#
# Options:
#   --help  Show this message and exit.
#
# Commands:
#   api         Make a request to the Readthedocs REST API.
#   build       Trigger a build for a project version.
#   deactivate  Deactivate one or more versions
#   hide        Hide one or more versions
#   logs        Get build logs for a specific build ID.
#   open        Open project page in browser.

rtd api --help
# Usage: rtd api [OPTIONS] ENDPOINT
#
#   Make a request to the Readthedocs REST API.
#
#   RTD API docs: https://docs.readthedocs.io/en/stable/api/v3.html
#
# Options:
#   -b, --body TEXT                 JSON string to send in the body of a PATCH/POST request;
#                                   if absent, a GET request is sent
#   -m, --method [GET|POST|PATCH]   HTTP method to use; defaults to GET if no body,
#                                   PATCH if body provided
#   -u, --show-updated              After a PATCH/POST request (with -b/--body), send a GET
#                                   to the same endpoint, to verify the updated state of the
#                                   resource
#   --help                          Show this message and exit.

rtd build --help
# Usage: rtd build [OPTIONS] PROJECT
#
#   Trigger a build for a project version.
#
# Options:
#   -v, --version TEXT  Version slug (default: latest)
#   --help              Show this message and exit.

rtd logs --help
# Usage: rtd logs BUILD_ID
#
#   Get build logs for a specific build ID.

rtd open --help
# Usage: rtd open [OPTIONS] PROJECT
#
#   Open project page in browser.
#
# Options:
#   -b, --build TEXT  Open specific build page
#   -d, --docs        Open docs site (not dashboard)
#   --help            Show this message and exit.

Examples

List projects:

rtd api projects
# {
#   "count": …,
#   "next": null,
#   "previous": null,
#   "results": [
#     …
#   ]
# }

Trigger a build:

rtd build your_project
# or specify a version
rtd build your_project -v stable

View build logs:

rtd logs 30253885

Open project pages in browser:

rtd open levanter                    # Opens builds page
rtd open levanter -b 30253885        # Opens specific build
rtd open levanter -d                 # Opens docs site

Update project default branch:

rtd api projects/your_project/ -b '{"default_branch": "main"}' -u

Sync versions from repository:

rtd api projects/your_project/sync-versions/ -m POST

Hide all versions except for a specific list:

project=your_project
keep=(latest 1.11.)  # grep patterns to keep
limit=100

# Exclude `keep` patterns above, when calling `rtd hide` below
grep_args=(-v)
for v in "${keep[@]}"; do
  grep_args+=(-e "$v")
done

rtd api "projects/$project/versions?limit=$limit&active=true&built=true" \
| jq -r '.results[] | select(.hidden | not) | .slug' \
| grep "${grep_args[@]}" \
| xargs rtd hide -p $p

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rtd_cli-0.1.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rtd_cli-0.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file rtd_cli-0.1.0.tar.gz.

File metadata

  • Download URL: rtd_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rtd_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bcf56661278f1dbef01062bb4891e4f4ba6ebad669985b338a161984d108aef4
MD5 4e92fb1e00865e07c8ea355c1a524af6
BLAKE2b-256 2061f4ff21cf941647e88290fc02a2a0966e3c158b5d922800bc1e5a6ccfa2b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for rtd_cli-0.1.0.tar.gz:

Publisher: release.yml on runsascoded/rtd-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rtd_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rtd_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rtd_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8b2b409ef6519ee7598e132f87a2fa16e79b28d78461b5d3233cbc1bcb7f4bc
MD5 8a26567e22de58dd18c49ce5709c2f26
BLAKE2b-256 c3f840c092c1f01d1bf2f39c6683ff24d0443699e6038b85026fc07b38a763e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for rtd_cli-0.1.0-py3-none-any.whl:

Publisher: release.yml on runsascoded/rtd-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page