Skip to content

Commit

Permalink
Remove preceding $ in documentation code blocks, use bash for code …
Browse files Browse the repository at this point in the history
…blocks, add pre-commit check for console usage (#3730)

* Remove preceding `$` in documentation code blocks, always use bash

* Add a pre-commit check for console code blocks in the documentation dir

* Auto-fix console code block to bash
  • Loading branch information
AetherUnbound authored Jan 31, 2024
1 parent 326d297 commit 4e964f1
Show file tree
Hide file tree
Showing 17 changed files with 147 additions and 138 deletions.
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions documentation/api/guides/https.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`,
Expand All @@ -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}]%
Expand Down
36 changes: 18 additions & 18 deletions documentation/api/guides/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand All @@ -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}]%
Expand All @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions documentation/api/guides/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
8 changes: 4 additions & 4 deletions documentation/automations/guides/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions documentation/catalog/guides/adding_a_new_provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions documentation/frontend/guides/analytics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
24 changes: 12 additions & 12 deletions documentation/frontend/guides/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,41 @@ 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
`API_URL` environment variable to point to that instance. If you had the
[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:
Expand Down
4 changes: 2 additions & 2 deletions documentation/general/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
32 changes: 16 additions & 16 deletions documentation/general/general_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
```
````

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
Loading

0 comments on commit 4e964f1

Please sign in to comment.