Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Remove preceding `$` in documentation code blocks, use bash for code blocks, add pre-commit check for console usage (#3730)

Madison Swain-Bowden4e964f188e0e
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index cc81ea04b..cfdf24a4b 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -11,6 +11,15 @@ repos:
entry: bash -c 'if [ ! -f "$(dirname "$dir")"/frontend/src/locales/ar.json ]; then just frontend/run i18n; fi'
language: system
pass_filenames: false
+ - id: fix-console-code-block
+ name: Ensure "bash" code block is used over "console"
+ files: ^documentation/.*\.md$
+ # Check that we are not using the ```console block in our documentation
+ # -R recursively checks files
+ # -l suppresses normal input and only lists files with errors
+ # Print an error message if any files are found
+ entry: sed -i -e 's/```console/```bash/g'
+ language: system
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
diff --git a/documentation/api/guides/https.md b/documentation/api/guides/https.md
index 13d4d3cd0..e23949fe3 100644
--- a/documentation/api/guides/https.md
+++ b/documentation/api/guides/https.md
@@ -18,8 +18,8 @@ Additionally, you will need to install
1. Create certificates for NGINX to use.
- ```console
- $ just docker/nginx/cert
+ ```bash
+ just docker/nginx/cert
```
This will create a certificate file `openversse.crt` and a key file
@@ -28,8 +28,8 @@ Additionally, you will need to install
2. Bring the ingestion server and API up, along with all their dependent
services.
- ```console
- $ just api/up
+ ```bash
+ just api/up
```
The `api/up` recipe orchestrates the following services: `cache`, `db`,
@@ -40,8 +40,8 @@ Additionally, you will need to install
3. Make an API call over HTTPS.
- ```console
- $ just api/stats images https://localhost:50243
+ ```bash
+ just api/stats images https://localhost:50243
just _curl-get "images/stats/" https://localhost:50243
curl "https://localhost:50243/v1/images/stats/"
[{"source_name":"flickr","display_name":"Flickr","source_url":"https://www.flickr.com","logo_url":null,"media_count":2500},{"source_name":"stocksnap","display_name":"StockSnap","source_url":"https://stocksnap.io","logo_url":null,"media_count":2500}]%
diff --git a/documentation/api/guides/quickstart.md b/documentation/api/guides/quickstart.md
index 1efaf7de1..dbab0768e 100644
--- a/documentation/api/guides/quickstart.md
+++ b/documentation/api/guides/quickstart.md
@@ -17,25 +17,25 @@ you need to run this.
2. Clone the repository to your computer. Then switch to the cloned directory.
If you're planning to contribute, fork the repo and clone your fork instead.
- ```console
- $ git clone https://github.com/WordPress/openverse.git # or your fork
- $ cd openverse/
+ ```bash
+ git clone https://github.com/WordPress/openverse.git # or your fork
+ cd openverse/
```
If you followed the general setup guide and installed
[GitHub CLI](/general/general_setup.md#github-cli), you can clone more simply
using the `gh` command.
- ```console
- $ gh repo clone WordPress/openverse # or your fork
- $ cd openverse/
+ ```bash
+ gh repo clone WordPress/openverse # or your fork
+ cd openverse/
```
3. Bring the ingestion server and API up, along with all their dependent
services.
- ```console
- $ just api/up
+ ```bash
+ just api/up
```
The `api/up` recipe orchestrates the following services: `cache`, `db`,
@@ -49,24 +49,24 @@ you need to run this.
4. Load the sample data. This step can take a few minutes to complete.
- ```console
- $ just api/init
+ ```bash
+ just api/init
```
````{admonition} Troubleshooting
If this step fails, cleaning up and restarting usually fixes it.
- ```console
- $ just down -v
- $ just api/init
+ ```bash
+ just down -v
+ just api/init
```
````
5. With the data loaded, the API can now return JSON responses to your HTTP
requests.
- ```console
- $ just api/stats
+ ```bash
+ just api/stats
just _curl-get "images/stats/" http://localhost:50280
curl "http://localhost:50280/v1/images/stats/"
[{"source_name":"flickr","display_name":"Flickr","source_url":"https://www.flickr.com","logo_url":null,"media_count":2500},{"source_name":"stocksnap","display_name":"StockSnap","source_url":"https://stocksnap.io","logo_url":null,"media_count":2500}]%
@@ -77,8 +77,8 @@ you need to run this.
JSON data. If you have `jq` installed, you can pipe the response to it and
transform it.
- ```console
- $ just api/stats | jq '.[0]'
+ ```bash
+ just api/stats | jq '.[0]'
{
"source_name": "flickr",
"display_name": "Flickr",
@@ -87,7 +87,7 @@ you need to run this.
"media_count": 2500
}
- $ just api/stats 'audio' | jq '[.[] | .source_name]'
+ just api/stats 'audio' | jq '[.[] | .source_name]'
[
"freesound",
"jamendo",
diff --git a/documentation/api/guides/test.md b/documentation/api/guides/test.md
index 1de1e4683..b91480f7c 100644
--- a/documentation/api/guides/test.md
+++ b/documentation/api/guides/test.md
@@ -9,8 +9,8 @@ Once you've made some changes to the codebase, it is important to run tests.
2. Run the tests.
- ```console
- $ just api/test
+ ```bash
+ just api/test
```
```{note}
diff --git a/documentation/automations/guides/quickstart.md b/documentation/automations/guides/quickstart.md
index 59d287910..22a456ea6 100644
--- a/documentation/automations/guides/quickstart.md
+++ b/documentation/automations/guides/quickstart.md
@@ -26,8 +26,8 @@ If you wish to install only dependencies for automations, run the following:
Run Python automation scripts using the `automations/python/run` just recipe.
Ex.:
-```
-$ just automations/python/run print_labels.py
+```bash
+just automations/python/run print_labels.py
```
The recipe is an alias for running `pipenv run <script>` inside the
@@ -38,8 +38,8 @@ configuration as expected by many scripts.
Run Node.js automation scripts using the `automations/js/run` just recipe. Ex.:
-```
-$ just automations/js/run render-jinja.js
+```bash
+just automations/js/run render-jinja.js
```
The recipe is an alias for running `pnpm exec <script>` inside the
diff --git a/documentation/catalog/guides/adding_a_new_provider.md b/documentation/catalog/guides/adding_a_new_provider.md
index ef6f8e9a8..3dc22390a 100644
--- a/documentation/catalog/guides/adding_a_new_provider.md
+++ b/documentation/catalog/guides/adding_a_new_provider.md
@@ -159,15 +159,15 @@ manually turn the DAG on in production.
2. Run individual test by creating a testing session within Docker, then
selecting only the tests associated with the provider.
- ```console
- $ just catalog/test-session
- $ pytest -k <provider_name>
+ ```bash
+ just catalog/test-session
+ pytest -k <provider_name>
```
Alternatively, the test selection can be run in Docker directly with:
- ```console
- $ just catalog/test -k <provider_name>
+ ```bash
+ just catalog/test -k <provider_name>
```
```{note}
diff --git a/documentation/frontend/guides/analytics.md b/documentation/frontend/guides/analytics.md
index 7973469d8..902833dfc 100644
--- a/documentation/frontend/guides/analytics.md
+++ b/documentation/frontend/guides/analytics.md
@@ -13,12 +13,12 @@ Use the following `just` recipes to set Plausible up locally:
```sh
# Runs the portion of the docker-compose stack that includes Plausible
-$ just frontend/up
+just frontend/up
# Sets up Plausible with a default user and the localhost testing site
# Only necessary the first time you run Plausible locally, when adding
# new custom events, or any time after you run `just down -v`
-$ just frontend/init
+just frontend/init
```
If you have already run `just up` and `just init` at the root of the repository,
diff --git a/documentation/frontend/guides/quickstart.md b/documentation/frontend/guides/quickstart.md
index 8e3ee0edf..d4a259bd5 100644
--- a/documentation/frontend/guides/quickstart.md
+++ b/documentation/frontend/guides/quickstart.md
@@ -17,32 +17,32 @@ you need to run this.
2. Clone the repository to your computer. Then switch to the cloned directory.
If you're planning to contribute, fork the repo and clone your fork instead.
- ```console
- $ git clone https://github.com/WordPress/openverse.git # or your fork
- $ cd openverse/
+ ```bash
+ git clone https://github.com/WordPress/openverse.git # or your fork
+ cd openverse/
```
If you followed the general setup guide and installed
[GitHub CLI](/general/general_setup.md#github-cli), you can clone more simply
using the `gh` command.
- ```console
- $ gh repo clone WordPress/openverse # or your fork
- $ cd openverse/
+ ```bash
+ gh repo clone WordPress/openverse # or your fork
+ cd openverse/
```
3. Install only the Node.js dependencies. You do not need to install any Python
dependencies to run the frontend.
- ```console
- $ just node-install
+ ```bash
+ just node-install
```
4. To bring up the frontend, we have another `just` recipe. We have `just`
recipes for almost everything.
- ```console
- $ just frontend/run dev
+ ```bash
+ just frontend/run dev
```
If you want your frontend to use a different API instance, you can set the
@@ -50,8 +50,8 @@ you need to run this.
[API running locally](/api/guides/quickstart.md), you can do the following to
use the local API with the frontend.
- ```console
- $ env API_URL="http://localhost:50280" just frontend/run dev
+ ```bash
+ env API_URL="http://localhost:50280" just frontend/run dev
```
Now you should be able to access the following endpoints:
diff --git a/documentation/general/deployment.md b/documentation/general/deployment.md
index 6c5310810..f92c7b413 100644
--- a/documentation/general/deployment.md
+++ b/documentation/general/deployment.md
@@ -178,8 +178,8 @@ the available list of tags and the workflow will fail if the tag is determined
not to exist in the image repository. You can find a list of release tags for
specific apps by filtering git tags based on the tag prefix for the app:
-```
-$ git tag -l '<app slug>-*'
+```bash
+git tag -l '<app slug>-*'
```
Replace `<app slug>` with `api`, `frontend`, or `ingestion_server` as needed.
diff --git a/documentation/general/general_setup.md b/documentation/general/general_setup.md
index 8155a7a7a..48848819f 100644
--- a/documentation/general/general_setup.md
+++ b/documentation/general/general_setup.md
@@ -62,8 +62,8 @@ Openverse is Git-tracked. To clone Openverse locally, you will need to install
if it's not always the latest version. To know if you have Git installed, run
the following command.
-```console
-$ git --version
+```bash
+git --version
```
If you see `git version x.y.z`, you have Git installed. If you see an error, you
@@ -86,9 +86,9 @@ for some operating systems.
If you run `just` inside the Openverse root repo without a recipe name, you can
see a huge list of all the different recipes present in the project.
-```console
-$ cd openverse/
-$ just
+```bash
+cd openverse/
+just
```
````
@@ -125,8 +125,8 @@ will already have this installed, even if it's not always the latest version. To
know if you have Python (specifically version 3) installed, run the following
command.
-```console
-$ python3 --version
+```bash
+python3 --version
```
If you see `Python x.y.z`, you have Python installed. If you see an error, you
@@ -155,8 +155,8 @@ We use Node.js in the frontend of our stack. So to work with that part of the
codebase, you will need Node.js installed. To know if you have Node.js
installed, run the following command.
-```console
-$ node --version
+```bash
+node --version
```
If you see `vx.y.z`, you have Node.js installed. If you see an error, you need
@@ -176,9 +176,9 @@ onwards. So no installation is needed.
Enable Corepack in the monorepo root. Then, check if Corepack can discover the
right package manager, pnpm, by running the following commands.
-```console
-$ corepack enable
-$ pnpm --version
+```bash
+corepack enable
+pnpm --version
```
You should see a version number and no error message.
@@ -212,8 +212,8 @@ Engine include steps to also install the Buildx plugin.
To know if your Docker setup is using Buildx, run the following command.
-```console
-$ docker build --help
+```bash
+docker build --help
```
If you see `docker buildx build` under 'Aliases', you have Buildx set up as the
@@ -228,8 +228,8 @@ and indexer workers locally during development.
Docker Compose is a part of the Docker Desktop installation. To know if you have
Docker Compose installed, run the following command.
-```console
-$ docker compose version
+```bash
+docker compose version
```
If you see `Docker Compose version vx.y.z`, you have Docker Compose installed.
diff --git a/documentation/general/quickstart.md b/documentation/general/quickstart.md
index 09c77e938..6f2e1e7ab 100644
--- a/documentation/general/quickstart.md
+++ b/documentation/general/quickstart.md
@@ -34,18 +34,18 @@ prerequisites.
2. Clone the repository to your computer. Then switch to the cloned directory.
If you're planning to contribute, fork the repo and clone your fork instead.
- ```console
- $ git clone https://github.com/WordPress/openverse.git # or your fork
- $ cd openverse/
+ ```bash
+ git clone https://github.com/WordPress/openverse.git # or your fork
+ cd openverse/
```
If you followed the setup guide and installed
[GitHub CLI](/general/general_setup.md#github-cli), you can clone more simply
using the `gh` command.
- ```console
- $ gh repo clone WordPress/openverse # or your fork
- $ cd openverse/
+ ```bash
+ gh repo clone WordPress/openverse # or your fork
+ cd openverse/
```
3. Install all dependencies. This step installs dependencies for the frontend,
@@ -53,21 +53,21 @@ prerequisites.
install API or ingestion server dependencies because they are meant to run
using Docker containers.
- ```console
- $ just install
+ ```bash
+ just install
```
To be more specific with your install, you can run either of the following.
- ```console
- $ just node-install # only frontend and Node.js automations
- $ just py-install # only documentation and Python automations
+ ```bash
+ just node-install # only frontend and Node.js automations
+ just py-install # only documentation and Python automations
```
4. Spin up and orchestrate all Docker services.
- ```console
- $ just up
+ ```bash
+ just up
```
The `up` recipe orchestrates the following services: `cache`, `db`,
@@ -112,24 +112,24 @@ prerequisites.
5. Load the sample data. This step can take a few minutes to complete.
- ```console
- $ just init
+ ```bash
+ just init
```
````{admonition} Troubleshooting
If this step fails, cleaning up and restarting usually fixes it.
- ```console
- $ just down -v
- $ just api/init
+ ```bash
+ just down -v
+ just api/init
```
````
6. With the data loaded, the API can now return JSON responses to your HTTP
requests.
- ```console
- $ just api/stats
+ ```bash
+ just api/stats
just _curl-get "images/stats/" http://localhost:50280
curl "http://localhost:50280/v1/images/stats/"
[{"source_name":"flickr","display_name":"Flickr","source_url":"https://www.flickr.com","logo_url":null,"media_count":2500},{"source_name":"stocksnap","display_name":"StockSnap","source_url":"https://stocksnap.io","logo_url":null,"media_count":2500}]%
@@ -140,8 +140,8 @@ prerequisites.
JSON data. If you have `jq` installed, you can pipe the response to it and
transform it.
- ```console
- $ just api/stats | jq '.[0]'
+ ```bash
+ just api/stats | jq '.[0]'
{
"source_name": "flickr",
"display_name": "Flickr",
@@ -150,7 +150,7 @@ prerequisites.
"media_count": 2500
}
- $ just api/stats 'audio' | jq '[.[] | .source_name]'
+ just api/stats 'audio' | jq '[.[] | .source_name]'
[
"freesound",
"jamendo",
@@ -165,8 +165,8 @@ prerequisites.
7. To bring up the frontend, we have another `just` recipe. We have `just`
recipes for almost everything.
- ```console
- $ env API_URL="http://localhost:50280" just frontend/run dev
+ ```bash
+ env API_URL="http://localhost:50280" just frontend/run dev
```
Now you should be able to access the following endpoints:
@@ -181,15 +181,15 @@ prerequisites.
2. For services running inside Docker, like the API, ingestion server and
Plausible, use another `just` recipe to bring them down.
- ```console
- $ just down
+ ```bash
+ just down
```
````{tip}
If you include the `-v` flag, all Docker volumes (including their data) will
be deleted too, which is useful in case you want a fresh start.
- ```console
- $ just down -v
+ ```bash
+ just down -v
```
````
diff --git a/documentation/ingestion_server/guides/quickstart.md b/documentation/ingestion_server/guides/quickstart.md
index bcd16d75f..f3900a91d 100644
--- a/documentation/ingestion_server/guides/quickstart.md
+++ b/documentation/ingestion_server/guides/quickstart.md
@@ -18,24 +18,24 @@ you need to run this.
2. Clone the repository to your computer. Then switch to the cloned directory.
If you're planning to contribute, fork the repo and clone your fork instead.
- ```console
- $ git clone https://github.com/WordPress/openverse.git # or your fork
- $ cd openverse/
+ ```bash
+ git clone https://github.com/WordPress/openverse.git # or your fork
+ cd openverse/
```
If you followed the general setup guide and installed
[GitHub CLI](/general/general_setup.md#github-cli), you can clone more simply
using the `gh` command.
- ```console
- $ gh repo clone WordPress/openverse # or your fork
- $ cd openverse/
+ ```bash
+ gh repo clone WordPress/openverse # or your fork
+ cd openverse/
```
3. Bring the ingestion server up, along with all their dependent services.
- ```console
- $ just ingestion_server/up
+ ```bash
+ just ingestion_server/up
```
The `ingestion_server/up` recipe orchestrates the following services: `db`,
diff --git a/documentation/ingestion_server/guides/test.md b/documentation/ingestion_server/guides/test.md
index 6be29b6c5..e541b11ea 100644
--- a/documentation/ingestion_server/guides/test.md
+++ b/documentation/ingestion_server/guides/test.md
@@ -10,8 +10,8 @@ Once you've made some changes to the codebase, it is important to run tests.
2. Install the Python dependencies, including dev-dependencies.
- ```console
- $ just ingestion_server/install
+ ```bash
+ just ingestion_server/install
```
```{caution}
@@ -21,8 +21,8 @@ Once you've made some changes to the codebase, it is important to run tests.
3. Run the integration tests.
- ```console
- $ just ingestion_server/test-local
+ ```bash
+ just ingestion_server/test-local
```
Note that if an `.env` file exists in the folder you're running `just` from,
diff --git a/documentation/ingestion_server/guides/troubleshoot.md b/documentation/ingestion_server/guides/troubleshoot.md
index 0ff814930..a3001b7d6 100644
--- a/documentation/ingestion_server/guides/troubleshoot.md
+++ b/documentation/ingestion_server/guides/troubleshoot.md
@@ -23,15 +23,15 @@ the size of a test/staging index. To do so, follow these steps.
2. SSH into the machine using it's public IP.
- ```console
- $ ssh ec2-user@<public-ip>
+ ```bash
+ ssh ec2-user@<public-ip>
```
3. Determine the name of the active `indexer_worker` container and pause it.
- ```console
- $ docker ps
- $ docker pause <container_id>
+ ```bash
+ docker ps
+ docker pause <container_id>
```
4. Repeat steps 2 and 3 for each active ingestion worker machine. Leave the SSH
@@ -44,8 +44,8 @@ the size of a test/staging index. To do so, follow these steps.
6. From each of the open SSH sessions, send a completion notification to the
ingestion server's internal IP address.
- ```console
- $ curl \
+ ```bash
+ curl \
-X POST \
-H "Content-Type: application/json" \
-d '{"error":false}' \
diff --git a/documentation/ingestion_server/reference/task_api.md b/documentation/ingestion_server/reference/task_api.md
index b2e23b352..da70d1032 100644
--- a/documentation/ingestion_server/reference/task_api.md
+++ b/documentation/ingestion_server/reference/task_api.md
@@ -27,8 +27,8 @@ otherwise a random UUID will be used.
### Example
-```console
-$ curl \
+```bash
+curl \
-X POST \
-H 'Content-Type: application/json' \
-d '{"model": "image", "action": "REINDEX", "index_suffix": "20231106"}' \
@@ -59,8 +59,8 @@ suffix.
### Example
-```console
-$ curl \
+```bash
+curl \
-X POST \
-H 'Content-Type: application/json' \
-d '{"model": "image", "action": "CREATE_AND_POPULATE_FILTERED_INDEX", "destination_index_suffix": "20231106"}' \
@@ -86,8 +86,8 @@ the default or filtered index for that media type respectively.
### Example
-```console
-$ curl \
+```bash
+curl \
-X POST \
-H 'Content-Type: application/json' \
-d '{"model": "image", "action": "POINT_ALIAS", "index_suffix": "20231106", "alias": "image-filtered"}' \
@@ -116,8 +116,8 @@ for a media type.
### Example
-```console
-$ curl \
+```bash
+curl \
-X POST \
-H 'Content-Type: application/json' \
-d '{"model": "image", "action": "DELETE_INDEX", "index_suffix": "20231106"}' \
diff --git a/documentation/meta/documentation/quickstart.md b/documentation/meta/documentation/quickstart.md
index f6efcea3f..d0cdacd51 100644
--- a/documentation/meta/documentation/quickstart.md
+++ b/documentation/meta/documentation/quickstart.md
@@ -17,32 +17,32 @@ you need to run this.
2. Clone the repository to your computer. Then switch to the cloned directory.
If you're planning to contribute, fork the repo and clone your fork instead.
- ```console
- $ git clone https://github.com/WordPress/openverse.git # or your fork
- $ cd openverse/
+ ```bash
+ git clone https://github.com/WordPress/openverse.git # or your fork
+ cd openverse/
```
If you followed the general setup guide and installed
[GitHub CLI](/general/general_setup.md#github-cli), you can clone more simply
using the `gh` command.
- ```console
- $ gh repo clone WordPress/openverse # or your fork
- $ cd openverse/
+ ```bash
+ gh repo clone WordPress/openverse # or your fork
+ cd openverse/
```
3. Install only the Python dependencies. You do not need to install any Node.js
dependencies to run the documentation.
- ```console
- $ just documentation/install
+ ```bash
+ just documentation/install
```
4. Run the documentation live server. Once this is done, you should be able to
see the documentation on [http://127.0.0.1:50230](http://127.0.0.1:50230).
- ```console
- $ just documentation/live
+ ```bash
+ just documentation/live
```
````{admonition} Troubleshooting
@@ -50,9 +50,9 @@ you need to run this.
of contents or changes to the file system. In those cases, you can clean the
caches and restart the live server.
- ```console
- $ just documentation/clean
- $ just documentation/live
+ ```bash
+ just documentation/clean
+ just documentation/live
```
````
diff --git a/documentation/projects/planning.md b/documentation/projects/planning.md
index d8a4038ee..f89cb64ce 100644
--- a/documentation/projects/planning.md
+++ b/documentation/projects/planning.md
@@ -47,7 +47,7 @@ accepts one argument as the project name, followed optionally by any number of
implementation plans.
```bash
-$ just documentation/create-project 'Project name' 'First IP' 'Second IP'
+just documentation/create-project 'Project name' 'First IP' 'Second IP'
```
This will create the directory structure for your project with the specified
@@ -67,7 +67,7 @@ plan, you can use the `just` recipe `create-ip`. It accepts the directory name
(not full path) of the project and the plan name as arguments.
```bash
-$ just documentation/create-ip project_name 'New IP'
+just documentation/create-ip project_name 'New IP'
```
````