Skip to content

Commit f5364c3

Browse files
Add auto-generated documentation
- Update some outdated documentation - Add README to sphinx documentation - Update readthedocs config to generate documentation from README in pre_build
1 parent c6da43d commit f5364c3

12 files changed

+192
-78
lines changed

.pre-commit-config.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ repos:
55
rev: 23.7.0
66
hooks:
77
- id: black
8-
language_version: python3.9.13
98
- repo: https://github.com/pre-commit/pre-commit-hooks
109
rev: v2.3.0
1110
hooks:

.readthedocs.yaml

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ build:
1010
os: ubuntu-22.04
1111
tools:
1212
python: "3.11"
13-
# You can also specify other tool versions:
14-
# nodejs: "16"
15-
# rust: "1.55"
16-
# golang: "1.17"
13+
jobs:
14+
pre_build:
15+
- python ./scripts/generate-docs.py ./ ./README.md ./docs/auto/readme
1716

1817
# Build documentation in the docs/ directory with Sphinx
1918
sphinx:

.vscode/launch.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Debug Jest Tests",
6+
"type": "node",
7+
"request": "launch",
8+
"runtimeArgs": [
9+
"--inspect-brk",
10+
"node_modules/.bin/jest",
11+
"--runInBand"
12+
],
13+
"localRoot": "${workspaceRoot}/frontend",
14+
"console": "integratedTerminal",
15+
"internalConsoleOptions": "neverOpen"
16+
}
17+
]
18+
}

README.md

+70-53
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ _FKA: "CORGI", Content Output Review and Generation Interface_
1818

1919
The CORGI system consists of 2 parts:
2020

21-
1. CORGI Job Dashboard
21+
1. CORGI Job Dashboard
2222
2. [Enki](https://github.com/openstax/enki) Pipeline
2323

2424
### CORGI Job Dashboard
2525

2626
The CORGI Job Dashboard or "CORGI dashboard" consists of a front-end microservice and a backend microservice. The CORGI Dashboard acts mainly as a "queue" of jobs to be processed by the Enki Concourse pipeline.
2727

28-
1. Backend - written using Python and the [FastAPI ASGI Framework](https://fastapi.tiangolo.com/). The backend API is used by the front-end and Enki pipelines to create, retrieve, or update job information.
28+
1. Backend - written using Python and the [FastAPI ASGI Framework](https://fastapi.tiangolo.com/). The backend API is used by the front-end and Enki pipelines to create, retrieve, or update job information.
2929

30-
2. Frontend - written using [nuxt.js](https://nuxtjs.org/) and acts as the main dashboard interface of the CORGI system. You can see the list of jobs, create jobs, or abort a job that's in progress. Shows information pertaining to errors and status.
30+
2. Frontend - written using [svelte](https://svelte.dev/) and acts as the main dashboard interface of the CORGI system. You can see the list of jobs, create jobs, or abort a job that's in progress. Shows information pertaining to errors and status.
3131

3232
### [Enki](https://github.com/openstax/enki)
3333

@@ -38,7 +38,7 @@ The full explanation of Enki it is out of scope for this documentation. To learn
3838
---
3939
## Development Internals
4040

41-
### Installing Docker
41+
### Installing Docker
4242

4343
* Install [Docker](https://docs.docker.com/install/).
4444

@@ -50,7 +50,7 @@ The full explanation of Enki it is out of scope for this documentation. To learn
5050
5151

5252

53-
## Local development
53+
## Local development
5454

5555
**General Workflow**
5656
1. Start stack with or without GitHub OAuth (see below)
@@ -108,52 +108,15 @@ To check the logs run:
108108

109109
### Functions Patched in Leashed Mode
110110

111-
Leashed mode attempts to patch any `app.github.api` function functions starting with "get_". It looks for the associated mock functions in `backend/app/tests/unit/init_test_data.py`.
111+
Leashed mode attempts to patch any `app.github.api` function functions starting with `get_`. It looks for the associated mock functions in `backend/app/tests/unit/init_test_data.py`.
112112

113113
### Hot Reloading
114114

115-
Using the development stack, the Svelte frontend is rebuilt inside the container
115+
Using the development stack, the Svelte frontend is rebuilt inside the container
116116
as you make changes: no restarts required. The page should reload automatically
117117
as well. The same is true for the backend: as you make modifications, the
118118
backend server should reload with your latest changes.
119119

120-
121-
### View the Docs
122-
123-
For our documentation we use [Sphinx-docs](https://www.sphinx-doc.org/en/master/)
124-
and lives in the [./docs](./docs) directory.
125-
126-
If you are currently running the entire stack you should be able to see the
127-
documentation by visiting [http://localhost:8000](http://localhost:8000).
128-
129-
The documentation is configured to watch for changes and re-build the documentation.
130-
This allows developers the ability to preview their documentation changes as they
131-
make them.
132-
133-
If you would like to run the documentation without the entire stack running you
134-
can do so by running:
135-
136-
docker-compose up docs
137-
138-
### Editing The Docs
139-
140-
Edits are done in restructured text (rst).
141-
142-
While editing, you can check the logs by running
143-
```
144-
$ ./corgi docs logs
145-
```
146-
or
147-
```
148-
$ ./corgi docs logs -f
149-
```
150-
151-
If edits have been made to the Navigation and are not reflected, re-build the docker image:
152-
```
153-
$ ./corgi build <stack-name>
154-
$ ./corgi start [stack-name]
155-
```
156-
157120
### Run backend unit tests
158121

159122
To run unit tests:
@@ -170,7 +133,7 @@ cd backend/app
170133
poetry run pytest tests/unit --init-test-data --github-token "<token>"
171134
```
172135

173-
### Run integration and UI tests
136+
### Run integration and UI tests
174137

175138
To run the tests execute:
176139

@@ -185,11 +148,12 @@ To run the tests execute:
185148
./corgi ui-tests http://host.docker.internal fake-token
186149
```
187150

188-
**NOTE**: `host.docker.internal` refers to the host machine's `localhost` instead of the container's (see [documentation](https://docs.docker.com/desktop/networking/#use-cases-and-workarounds-for-all-platforms) for more info). The ui tests will still fail if CORGI is running in leashed mode because of how the the github api calls are patched.
151+
**NOTE**: `host.docker.internal` refers to the host machine's `localhost` instead of the container's (see [documentation](https://docs.docker.com/desktop/networking/#use-cases-and-workarounds-for-all-platforms) for more info). The ui tests will still fail if CORGI is running in leashed mode because of how the the github api calls are patched. If you want the ui tests to work locally, you will need to configure the
152+
OAuth credentials accordingly and run CORGI in dev mode.
189153

190154
### How to develop UI tests
191155

192-
Playwright UI tests are stored in `backend/app/tests/ui`.
156+
Playwright UI tests are stored in `backend/app/tests/ui`.
193157

194158
### Clear the database
195159

@@ -221,14 +185,68 @@ Do the migration:
221185

222186
docker-compose exec alembic upgrade head
223187

224-
### Load testing for the backend
188+
### Load testing for the backend (Under Construction)
189+
190+
*UNDER CONSTRUCTION*
225191

226192
Load testing with Locust.io is in the directory `./backend/app/tests/performance/`
227193

228194
Please look at the [README](./backend/app/tests/performance/README.md) in this directory on how to run load tests locally and for production systems.
195+
196+
## Sphinx Documentation
197+
198+
### View the Docs
199+
200+
For our documentation we use [Sphinx-docs](https://www.sphinx-doc.org/en/master/)
201+
and lives in the [./docs](./docs) directory.
202+
203+
If you are currently running the entire stack you should be able to see the
204+
documentation by visiting [http://localhost:8000](http://localhost:8000).
205+
206+
The documentation is configured to watch for changes and re-build the documentation.
207+
This allows developers the ability to preview their documentation changes as they
208+
make them.
209+
210+
If you would like to run the documentation without the entire stack running you
211+
can do so by running:
212+
213+
docker-compose up docs
214+
215+
### Editing The Docs
216+
217+
Edits are done in restructured text (rst).
218+
219+
While editing, you can check the logs by running
220+
```
221+
$ ./corgi docs logs
222+
```
223+
or
224+
```
225+
$ ./corgi docs logs -f
226+
```
227+
228+
If edits have been made to the Navigation and are not reflected, re-build the docker image:
229+
```
230+
$ ./corgi build <stack-name>
231+
$ ./corgi start [stack-name]
232+
```
233+
234+
### Auto-generated docs
235+
236+
Additional documentation is automatically pulled from this README and added to the sphinx docs when the docs service is running and when corgi.readthedocs.io is deployed. Each level 2 header (##) becomes a separate page in the sphinx docs. Links, like [README.md](./README.md), are resolved to github links relative to the markdown file's parent directory.
237+
238+
This documentation is stored in [docs/auto](./docs/auto) and this directory should not be modified directly. It is saved as markdown and converted with the m2r2 sphinx extension (see [conf.py](./docs/conf.py) for more information).
239+
240+
When the files are generated, they are numbered so that the glob result will match the order the headers occurred in within the README.
241+
242+
The `docs` docker image uses [watchdog](https://pypi.org/project/watchdog/) to automatically update the auto-generated documentation as you update [README.md](./README.md).
243+
244+
There is a pre_build step in [.readthedocs.yaml](./.readthedocs.yaml) that generates the documentation during deployment.
245+
246+
229247
## Releasing
230248

231-
The documentation is located in the [Releasing CORGI article]((https://openstax.atlassian.net/wiki/spaces/CE/pages/1256521739/Releasing+CORGI)) in our Confluence documentation.
249+
The documentation is located in the [Releasing CORGI article](https://openstax.atlassian.net/wiki/spaces/CE/pages/1256521739/Releasing+CORGI) in our Confluence documentation.
232250

233251
## Deploying Web Hosting Pipeline
234252

@@ -272,7 +290,7 @@ with requests.session() as session:
272290

273291
## Testing Unmerged CORGI & Enki Changes in Concourse
274292

275-
[CORGI Hotdog](https://corgi-hotdog.ce.openstax.org/) is a testing environment for experimenting with changes before they go to staging.
293+
[CORGI Hotdog](https://corgi-hotdog.ce.openstax.org/) is a testing environment for experimenting with changes before they go to staging.
276294

277295
URL: https://corgi-hotdog.ce.openstax.org/
278296

@@ -293,17 +311,16 @@ URL: https://corgi-hotdog.ce.openstax.org/
293311
- On concourse, corgi-hotdog, wait for hotdog-head to get new checked out version, this triggers a concourse build pipeline is set in build-deploy-Enki
294312
- See api call: `corgi-hotdog.openstax.org/hotdog/head` if you would like more details
295313
- Since concourse depends on production Enki tags on dockerhub, there isn’t a way to do concourse + dev Enki tag — except thru hotdog
296-
- Hotdog tag on dockerhub: corgi-hotdog rebuild as whatever dev ref you give it, then rebuilds the docker image for Enki.
314+
- Hotdog tag on dockerhub: corgi-hotdog rebuild as whatever dev ref you give it, then rebuilds the docker image for Enki.
297315
- Rebuild triggered by submitting a new ref.
298316
- Wait to build hotdog tag and push to dockerhub. At this point, you can create a job. still have to wait for concourse (steps: corgi-git-pdf & corgi-resource) to fetch the tag. then eventually the job will run.
299317
- Some additional details are
300318
- If you checkout a branch, you will need to checkout the branch again if you want to pull the latest changes from the branch
301319
- Jobs run on concourse. See logging & progress details on concourse/CORGI.
302320
- In hotdog corgi ui: worker-version tells you what Enki ref it is & a timestamp
303321
- Only one corgi-hotdog tag at a time
304-
322+
305323
### Hotdog TODO
306324
1. Automatically pull changes from branches
307325
1. Automatically redeploy the stack if python dependencies change (maybe add a field to corgi refs that, when set, will trigger deploy on checkout?)
308326
1. Consider creating a hybrid of PR pipeline so each PR can have a hotdog stack
309-

backend/app/tests/performance/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Load testing of COPS
1+
Load testing of CORGI
22
====================
33

4-
Load tests for COPS.
4+
Load tests for CORGI.
55

66
**Warning:** Be very careful before testing any production URLs! Speak with your team before doing so.
77

docker-compose.stack.dev.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
image: traefik:v2.10
55
volumes:
66
- /var/run/docker.sock:/var/run/docker.sock
7-
command:
7+
command:
88
- "--providers.docker"
99
- "--providers.docker.watch"
1010
- "--providers.docker.exposedByDefault=false"
@@ -82,3 +82,4 @@ services:
8282
- '8000:8000'
8383
volumes:
8484
- ./docs:/docs
85+
- .:/corgi

docs/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
_build/
2+
auto/

docs/Dockerfile

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
FROM sphinxdoc/sphinx:7.1.2 as base
22

33
COPY requirements.txt /docs/requirements.txt
4-
RUN pip install -r /docs/requirements.txt
4+
RUN pip install watchdog && pip install -r /docs/requirements.txt
55

66

77
FROM base as runner
88

99
COPY . /docs
1010
EXPOSE 8000
11-
CMD sphinx-autobuild --host 0.0.0.0 --port 8000 /docs /build/html
11+
12+
COPY <<EOT /entrypoint.bash
13+
repo_root=/corgi
14+
script="\$repo_root/scripts/generate-docs.py"
15+
readme_file="\$repo_root/README.md"
16+
output_dir="/docs/auto/readme"
17+
build_command="python \$script \$repo_root \$readme_file \$output_dir"
18+
\$build_command
19+
watchmedo shell-command --pattern=README.md --command="\$build_command" --drop "\$repo_root" &
20+
sphinx-autobuild --host 0.0.0.0 --port 8000 /docs /build/html
21+
EOT
22+
23+
CMD bash -ex /entrypoint.bash

docs/conf.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,40 @@
1717

1818
# -- Project information -----------------------------------------------------
1919

20-
project = 'Content Output Review and Generation Interface'
21-
copyright = '2019, OpenStax Content Engineering'
22-
author = 'OpenStax Content Engineering'
20+
project = "Content Output Review and Generation Interface"
21+
copyright = "2019, OpenStax Content Engineering"
22+
author = "OpenStax Content Engineering"
2323

2424
# -- General configuration ---------------------------------------------------
2525

2626
# Add any Sphinx extension module names here, as strings. They can be
2727
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
2828
# ones.
2929
extensions = [
30-
'sphinxcontrib.blockdiag',
31-
'sphinxcontrib.seqdiag',
32-
'sphinx.ext.autosectionlabel'
30+
"sphinxcontrib.blockdiag",
31+
"sphinxcontrib.seqdiag",
32+
"sphinx.ext.autosectionlabel",
33+
"m2r2",
3334
]
3435

3536
# Add any paths that contain templates here, relative to this directory.
36-
templates_path = ['_templates']
37+
templates_path = ["_templates"]
3738

3839
# List of patterns, relative to source directory, that match files and
3940
# directories to ignore when looking for source files.
4041
# This pattern also affects html_static_path and html_extra_path.
41-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
42+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
43+
source_suffix = [".rst", ".md"]
4244

4345

4446
# -- Options for HTML output -------------------------------------------------
4547

4648
# The theme to use for HTML and HTML Help pages. See the documentation for
4749
# a list of builtin themes.
4850
#
49-
html_theme = 'sphinx_rtd_theme'
51+
html_theme = "sphinx_rtd_theme"
5052

5153
# Add any paths that contain custom static files (such as style sheets) here,
5254
# relative to this directory. They are copied after the builtin static files,
5355
# so a file named "default.css" will overwrite the builtin "default.css".
54-
html_static_path = ['_static']
56+
html_static_path = ["_static"]

docs/index.rst

+6-4
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,23 @@
99
Content Output Review and Generation Interface (CORGI)
1010
######################################################
1111

12-
CORGI is a multi-part system that provides different ways to
13-
produce OpenStax book artifacts for Content Managers (CMs),
14-
QA, and developers. CORGI is used to create, monitor, and
15-
display the status of content production tasks.
12+
CORGI is a multi-part system that provides different ways to
13+
produce OpenStax book artifacts for Content Managers (CMs),
14+
QA, and developers. CORGI is used to create, monitor, and
15+
display the status of content production tasks.
1616

1717
*****************
1818
Table of Contents
1919
*****************
2020

2121
.. toctree::
22+
:glob:
2223
:maxdepth: 3
2324

2425
operations/setting_up_the_swarm
2526
operations/generate_pipeline_config
2627
operations/backup_and_restore_db
28+
auto/**/*
2729

2830
.. toctree::
2931
:maxdepth: 2

0 commit comments

Comments
 (0)