Skip to main content

A work in progress.

Made to sync RTD project redirects and maintainers from authoritative files kept in version control. May never do anything else!

Synopsis

Provide an RTD API token via the environment:

$ export RTD_TOKEN=…

List projects:

$ rtd projects
nextstrain
├── nextstrain-ncov
├── nextstrain-nextclade
├── nextstrain-augur
├── nextstrain-auspice
├── nextstrain-cli
└── nextstrain-sphinx-theme

Show a project (very sparse currently):

$ rtd projects nextstrain
nextstrain <https://docs.nextstrain.org/en/latest/>

Show a project’s redirects:

$ rtd projects nextstrain redirects
                                                                             Redirects

  Type   From URL                                                     To URL
 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  page   /guides/                                                     /
  page   /guides/index.html                                           /index.html
  page   /guides/install/                                             install-nextstrain.html
  page   /guides/install/augur_install.html                           https://docs.nextstrain.org/projects/augur/en/stable/installation/installation.html
  page   /guides/install/auspice-install                              https://docs.nextstrain.org/projects/auspice/en/stable/introduction/install.html
  page   /guides/install/auspice-install.html                         https://docs.nextstrain.org/projects/auspice/en/stable/introduction/install.html
  page   /guides/install/cli-install.html                             https://docs.nextstrain.org/projects/cli/en/latest/installation/
  page   /guides/install/index.html                                   install-nextstrain.html
  page   /guides/install/local-installation.html                      install-nextstrain.html
  page   /guides/install/windows-help.html                            install-nextstrain.html
  page   /install-nextstrain.html                                     /install.html
  page   /learn/                                                      /
  page   /learn/about-nextstrain.html                                 /learn/about.html
  page   /learn/index.html                                            /index.html
  page   /reference/                                                  /
  page   /reference/formats/                                          /reference/data-formats.html
  page   /reference/formats/data-formats.html                         /reference/data-formats.html
  page   /reference/formats/index.html                                /reference/data-formats.html
  page   /reference/index.html                                        /index.html
  …

Sync a project’s redirects:

$ rtd projects nextstrain redirects sync -f redirects.yml
Creating: page /tutorials/quickstart.html → /tutorials/running-a-workflow.html
Creating: page /tutorials/tb_tutorial.html → /tutorials/creating-a-workflow-vcf.html
Creating: page /tutorials/zika.html → /tutorials/creating-a-workflow.html

          Created

  Type   From URL                      To URL
 ──────────────────────────────────────────────────────────────────────────────
  page   /tutorials/quickstart.html    /tutorials/running-a-workflow.html
  page   /tutorials/tb_tutorial.html   /tutorials/creating-a-workflow-vcf.html
  page   /tutorials/zika.html          /tutorials/creating-a-workflow.html

                                    Deleted

  Type   From URL   To URL
 ──────────────────────────

Created 3, deleted 0, kept 38.

No changes made in --dry-run mode.  Pass --wet-run for realsies.

Show a project’s maintainers:

$ rtd projects nextstrain maintainers
eharkins
huddlej
ivan.aksamentov
jameshadfield
misja
nextstrain
rneher
trs
trvrb
victorlin0

Sync a project’s maintainers:

$ rtd projects nextstrain maintainers sync -f rtd-maintainers.txt
- eharkins
• huddlej
• ivan.aksamentov
• jameshadfield
- misja
• nextstrain
• rneher
• trs
• trvrb
+ victorlin0

Added (+) 1, removed (-) 2, kept 7.

No changes made in --dry-run mode.  Pass --wet-run for realsies.

For automation or just the full details, ask for JSON output instead of human-centered output from any command:

$ rtd --json projects
[
  {
    "id": 607779,
    "name": "nextstrain",
    "created": "2020-05-28T00:25:49.630013Z",
    "modified": "2021-08-18T23:39:10.271300Z",
    "default_branch": "master",
    "default_version": "latest",
    "homepage": "https://nextstrain.org",
    "language": {
      "code": "en",
      "name": "English"
    },
    "programming_language": {
      "code": "words",
      "name": "Only Words"
    },
    "repository": {
      "type": "git",
      "url": "https://github.com/nextstrain/docs.nextstrain.org.git"
    },
    …
  },
  …
]

Install

From PyPI:

python3 -m pip install readthedocs-cli

From source:

python3 -m venv .venv
source .venv/bin/activate

python3 -m pip install --upgrade pip setuptools wheel
python3 -m pip install -e .

rtd --version

Automatic sync using GitHub Actions

We manage the RTD redirects for <https://docs.nextstrain.org> using a file in our Git repository, <https://github.com/nextstrain/docs.nextstrain.org>. The redirects are automatically synced to RTD via a GitHub Actions workflow that uses this CLI tool. It’s a good example of how to set up something similar for your own project. The pieces are:

  1. redirects.yml file — The redirects themselves, defined as YAML.

  2. .github/workflows/sync-redirects.yaml file — GitHub Actions workflow to sync to RTD when redirects.yml changes on the master branch.

  3. An RTD_TOKEN GitHub Actions secret containing an RTD API token.

Releasing

This is still a pretty informal piece of software, but it is released to PyPI so that we can easily install it various places.

The gist of the release process is:

  1. Bump the __version__ variable (just an integer) in src/readthedocs_cli/__init__.py.

  2. Commit, tag, and push.

  3. Build and upload.

    You’ll need build and twine installed.

    # Clear any existing build artifacts for safety
    rm -rf dist/
    
    # Build source tarball and platform-agnostic wheel
    python3 -m build
    
    # Upload both to PyPI
    twine upload dist/*

Metadata

Release files for readthedocs-cli 4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for readthedocs-cli 4
File Size Uploaded
readthedocs-cli-4.tar.gz 10.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for readthedocs-cli 4
File Interpreter ABI Platform
readthedocs_cli-4-py3-none-any.whl Python 3 none any Details

Total release size: 20.1 kB

Release files / readthedocs-cli-4.tar.gz

Download URL readthedocs-cli-4.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
af71a9ca6fe0b50255ce4db2c378190998d39dc25312fe3d254437a31f7988d5
BLAKE2b-256 checksum
How to use checksums
f9cd2578170a3025a4a20c80021d602ae5884fac65356b94fef830f2a72e98c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.5.0 importlib_metadata/4.6.4 pkginfo/1.5.0.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9

Release files / readthedocs_cli-4-py3-none-any.whl

Download URL readthedocs_cli-4-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4eb28b1eb1d058a2eae2c5d783c02f9abb53e4257f1a1a5519cf710f707491bf
BLAKE2b-256 checksum
How to use checksums
a662d793852c736154f7dfc69bf791100553826c2be354c1bfc1d272fb26d166
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.5.0 importlib_metadata/4.6.4 pkginfo/1.5.0.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9

Release history Release notifications | RSS feed

5

2 release files

This release

4 This release

2 release files

3

2 release files

2

2 release files

1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page