Skip to content

Commit 873a048

Browse files
authored
Doc Update (#322)
* Improve docs index * Docs update * Regenerate repository map * update ai docs
1 parent 4e5f26f commit 873a048

8 files changed

Lines changed: 98 additions & 29 deletions

File tree

.claude/skills/docs/SKILL.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@ All run from the `docs/` directory (or with `make -C docs <target>`):
4141
| Command | What it does |
4242
|---|---|
4343
| `make apidocs` | Regenerate all `docs/api/*.rst` from source using sphinx-apidoc. Run this whenever Python modules are added or removed. |
44-
| `make livehtml` | Build docs and serve with live reload at http://localhost:9000. Requires the docs Docker container (`docker compose -f docker-compose.docs.yml up`). |
44+
| `make livehtml` | Build docs and serve with live reload at http://localhost:9000. Run inside the `docs` service (started with `just up`; see `docker-compose.local.yml`). |
4545
| `make clean` | Remove `_build/` and `api/` directories for a fresh build. |
4646
| `make html` | One-off HTML build into `_build/html/`. |
4747

48-
To serve with live reload locally (in Docker):
48+
To serve with live reload locally (in Docker), start the stack so the `docs` service runs (from repo root):
4949
```
50-
docker compose -f docker-compose.docs.yml up
50+
just up
5151
```
52+
The `docs` container runs `make livehtml` via `compose/local/django/start-docs`.
5253

5354
To regenerate API docs locally (sphinx-apidoc must be installed):
5455
```
@@ -98,7 +99,7 @@ Line length: 88 characters (enforced by ruff). Wrap long docstring lines to stay
9899
- `:class:\`~democrasite.webiscite.models.Bill\`` — class link
99100
- `:func:\`~democrasite.webiscite.tasks.submit_bill\`` — function link
100101
- `:meth:\`~democrasite.webiscite.webhooks.PullRequestHandler.opened\`` — method link
101-
3. Verify the build: `docker compose -f docker-compose.docs.yml up`
102+
3. Verify the build: `just up` and open http://localhost:9000/
102103

103104
### Adding a new Python module
104105
1. Write a module-level docstring at the top of the file

CLAUDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ Pytest is configured with `--ds=config.settings.test --reuse-db` in `pyproject.t
6262

6363
### Key Patterns
6464

65-
- **Constitution system** (`webiscite/constitution.py`, `constitution.json`): Maps files to protected line ranges. PRs touching protected code become "constitutional" bills requiring supermajority. Line numbers auto-update after merges.
66-
- **Bill lifecycle**: OPEN → APPROVED/REJECTED/FAILED/CLOSED. Each Bill has a OneToOne to a Celery `PeriodicTask` that runs `submit_bill()` at voting period end.
67-
- **Webhook flow** (`webiscite/webhooks.py`): GitHub push events → HMAC validation → create/update `PullRequest` → create `Bill`.
65+
- **Constitution system** (`democrasite/webiscite/constitution.py`, repo-root `constitution.json`): Maps files to protected line ranges. PRs touching protected code become "constitutional" bills requiring supermajority. Line numbers auto-update after merges.
66+
- **Bill lifecycle**: Draft PRs yield `DRAFT` bills until `ready_for_review`; then `OPEN` → APPROVED/REJECTED/FAILED/CLOSED (or `AMENDED` if the PR branch changes during voting). Each Bill has a OneToOne to a Celery Beat `PeriodicTask` that runs `submit_bill()` at voting period end.
67+
- **Webhook flow** (`democrasite/webiscite/webhooks.py`): GitHub `pull_request` webhooks (open, reopen, close, synchronize, ready_for_review, etc.) → HMAC validation → create/update `PullRequest` and `Bill` as appropriate. `push` and `ping` are accepted with minimal handling.
6868
- **Vote constraints**: One vote per user per bill (DB unique constraint). Votes can be changed.
6969
- **Audit trail**: `django-simple-history` tracks changes on key models.
7070

CONTRIBUTING.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ Creating a Webhook
120120

121121
:obj:`democrasite.webiscite` needs `webhooks`_ to find out about events on
122122
Github. `Create a webhook`_ in your fork of the repository, then generate a
123-
secret key for your hook and store it in your environment (either through your
124-
terminal or ``.env`` file) as ``GITHUB_SECRET_KEY``.
123+
secret key for your hook and store it in ``.envs/.local/.django`` (or your shell) as
124+
``GITHUB_WEBHOOK_SECRET`` so it matches the secret configured on GitHub.
125125

126126
To test your webhook, follow these `instructions`_. (If you have a preferred
127127
tool for exposing your local server, feel free to replace smee with it.) If you

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ following the instructions in the guide.
7474
Understanding the repository
7575
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7676

77-
Check out ``repo_map.txt`` in the root of the repository for a display of the
77+
Check out ``repository_map.txt`` in the root of the repository for a display of the
7878
repository layout and brief explanations for the purpose of each non-obvious file and
7979
directory.
8080

@@ -114,8 +114,8 @@ Setting up your users
114114
how the site behaves for both kinds of users.
115115

116116
.. _`django-allauth`: https://docs.allauth.org/en/latest/introduction/index.html
117-
.. _`GitHub`: https://django-allauth.readthedocs.io/en/latest/providers.html#github
118-
.. _`Google`: https://docs.allauth.org/en/latest/socialaccount/providers/github.html
117+
.. _`GitHub`: https://docs.allauth.org/en/latest/socialaccount/providers/github.html
118+
.. _`Google`: https://docs.allauth.org/en/latest/socialaccount/providers/google.html
119119

120120
Linting
121121
^^^^^^^

docs/howto.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ How To - Project Documentation
44
Get Started
55
----------------------------------------------------------------------
66

7-
Documentation can be written as rst files in `democrasite/docs`.
7+
Documentation source files live in the ``docs/`` directory at the repository root.
88

99

10-
To build and serve docs, use the commands::
10+
To build and serve docs with live reload, start the local stack (including the ``docs``
11+
service) from the project root::
1112

12-
docker compose -f docker-compose.docs.yml up
13+
just up
1314

15+
The docs container serves Sphinx at http://localhost:9000/ (see ``docker-compose.local.yml``).
1416

15-
Changes to files in `docs` will be picked up and reloaded automatically.
17+
Changes to files under ``docs/`` and under ``democrasite/`` (watched by sphinx-autobuild)
18+
will be picked up and reloaded automatically.
1619

1720
`Sphinx <https://www.sphinx-doc.org/>`_ is the tool used to build documentation.
1821

docs/index.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,50 @@
66
Democrasite Documentation
77
======================================================================
88

9+
10+
|Built with Cookiecutter Django| |Ruff| |Continuous integration| |Coverage report| |Documentation status|
11+
12+
.. |Built with Cookiecutter Django| image:: https://img.shields.io/badge/built%20with-Cookiecutter%20Django-ff69b4.svg?logo=cookiecutter
13+
:target: https://github.com/pydanny/cookiecutter-django/
14+
15+
.. |Ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
16+
:target: //github.com/astral-sh/ruff
17+
18+
.. |Continuous integration| image:: https://github.com/mfosterw/cookiestocracy/actions/workflows/ci.yml/badge.svg
19+
:target: https://github.com/mfosterw/cookiestocracy/actions/workflows/ci.yml
20+
21+
.. |Coverage report| image:: https://codecov.io/gh/mfosterw/cookiestocracy/graph/badge.svg?token=NPV1TLXZIW
22+
:target: https://codecov.io/gh/mfosterw/cookiestocracy
23+
24+
.. |Documentation status| image:: https://readthedocs.org/projects/cookiestocracy/badge/?version=latest
25+
:target: https://cookiestocracy.readthedocs.io/en/latest/?badge=latest
26+
27+
28+
:License: MIT
29+
30+
Democrasite is a website which automatically merges changes based on popular
31+
approval. For more information on the nature and purpose of the project, visit
32+
our `about page`_. This page is meant for people who want to fork the
33+
repository and/or contribute to the project. This project is approximately in beta
34+
development (hence the repository being named "cookiestocracy" - a reference
35+
to cookiecutter and `kakistocracy`_). The alpha version is `here`_ and the
36+
full version doesn't exist yet.
37+
38+
* Homepage:
39+
https://democrasite.dev
40+
* Source code:
41+
https://github.com/mfosterw/cookiestocracy
42+
* Documentation:
43+
https://cookiestocracy.readthedocs.io/en/latest/
44+
45+
.. _`about page`: https://democrasite.dev/about/
46+
.. _`kakistocracy`: https://en.wikipedia.org/wiki/Kakistocracy
47+
.. _`here`: https://github.com/mfosterw/democrasite-testing
48+
49+
950
.. toctree::
1051
:maxdepth: 2
52+
:titlesonly:
1153
:caption: Contents:
1254

1355
README

docs/webiscite.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ creates a :class:`~democrasite.webiscite.models.PullRequest` instance.
2727

2828
If the user who created the pull request has a democrasite account, a new
2929
:class:`~democrasite.webiscite.models.Bill`
30-
is created with the information from the pull request and made visible on the
31-
homepage immediately. A :class:`~django_celery_beat.models.PeriodicTask` is
32-
also scheduled to execute :func:`~democrasite.webiscite.tasks.submit_bill`
33-
once the voting period ends.
30+
is created with the information from the pull request. If the pull request is
31+
still a GitHub draft, the bill stays in ``DRAFT`` status (no voting) until the
32+
PR is marked ready for review, which publishes it via
33+
:meth:`~democrasite.webiscite.webhooks.PullRequestHandler.ready_for_review`.
34+
Otherwise the bill is ``OPEN`` on the homepage. A
35+
:class:`~django_celery_beat.models.PeriodicTask` is scheduled to execute
36+
:func:`~democrasite.webiscite.tasks.submit_bill` once the voting period ends
37+
(enabled when the bill leaves ``DRAFT``).
3438

3539
:func:`~democrasite.webiscite.tasks.submit_bill` verifies that the pull
3640
request is still open and that its SHA has not changed since the bill was

repository_map.txt

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ The documentation in this file is meant to be very brief. If you don't understan
22
word or are not familiar with a tool, google it!
33

44
.
5+
├── .claude // Claude Code agent skills (optional local tooling)
6+
│   └── skills
7+
│   ├── docs
8+
│   │   └── SKILL.md
9+
│   ├── new-bill-feature
10+
│   │   └── SKILL.md
11+
│   └── test-webhook
12+
│   └── SKILL.md
513
├── .devcontainer // devcontainer files
614
│   ├── bashrc.override.sh // bash initialization
715
│   └── devcontainer.json // devcontainer config
@@ -60,7 +68,7 @@ word or are not familiar with a tool, google it!
6068
│   └── traefik // reverse proxy and load balancer
6169
│   ├── Dockerfile
6270
│   └── traefik.yml
63-
├── config // django configuration and app defintion
71+
├── config // django configuration and app definition
6472
│   ├── settings // django settings files. See https://docs.djangoproject.com/en/dev/ref/settings/
6573
│   │   ├── __init__.py
6674
│   │   ├── base.py // common settings shared between environments
@@ -78,7 +86,9 @@ word or are not familiar with a tool, google it!
7886
│   │   │   └── social.json
7987
│   │   ├── migrations // database definitions and changes, created by django migration commands
8088
│   │   │   ├── __init__.py
81-
│   │   │   └── 0001_initial.py
89+
│   │   │   ├── 0001_initial.py
90+
│   │   │   ├── 0002_historicalnote_historicallike_historicalperson_and_more.py
91+
│   │   │   └── 0003_alter_person_following.py
8292
│   │   ├── tests
8393
│   │   │   ├── __init__.py
8494
│   │   │   ├── conftest.py // test configuration and fixtures definitions
@@ -211,7 +221,12 @@ word or are not familiar with a tool, google it!
211221
│   │   │   ├── __init__.py
212222
│   │   │   ├── 0001_initial.py
213223
│   │   │   ├── 0002_remove_bill_submit_task_bill__submit_task.py
214-
│   │   │   └── 0003_vote_unique_user_bill_vote.py
224+
│   │   │   ├── 0003_vote_unique_user_bill_vote.py
225+
│   │   │   ├── 0004_remove_bill_status_changed_and_more.py
226+
│   │   │   ├── 0005_alter_bill_name_alter_historicalbill_name_and_more.py
227+
│   │   │   ├── 0006_remove_bill_unique_open_pull_request_and_more.py
228+
│   │   │   ├── 0007_alter_bill__submit_task.py
229+
│   │   │   └── 0008_alter_bill_status_alter_historicalbill_status.py
215230
│   │   ├── tests
216231
│   │   │   ├── api
217232
│   │   │   │   ├── __init__.py
@@ -232,29 +247,31 @@ word or are not familiar with a tool, google it!
232247
│   │   ├── apps.py // app definition
233248
│   │   ├── constitution.py // constitution parsing and processing
234249
│   │   ├── context_processors.py // template context processors
250+
│   │   ├── managers.py // custom managers/querysets (e.g. bill annotations)
235251
│   │   ├── models.py // database and ORM object definitions
236252
│   │   ├── tasks.py // asynchronous tasks to run with celery
237253
│   │   ├── urls.py // app url route definitions
238-
│   │   ── views.py // route behavior definitions
239-
│   │   └── webhooks.py // webhook route behavior, e.g. github pr opened
254+
│   │   ── views.py // route behavior definitions
255+
│   │   └── webhooks.py // GitHub webhook handling (pull_request, push, ping)
240256
│   ├── __init__.py
241257
│   └── conftest.py // global test configuration and fixture definitions
242258
├── docs // documentation setup and files
243259
│   ├── api // files automatically generated from source code by apidocs
244260
│   │   ├── *
245261
│   ├── __init__.py
246262
│   ├── conf.py // sphinx configuration file
263+
│   ├── CONTRIBUTING.rst // contributing guide (included in Sphinx toctree)
247264
│   ├── howto.rst // instructions for creating docs
248265
│   ├── index.rst
249266
│   ├── make.bat // build commands for sphinx using windows
250267
│   ├── Makefile // build commands for sphinx
251-
│   ├── readthedocs.db // dummy database for local development
268+
│   ├── README.rst // project overview (mirrors root README for RTD)
252269
│   ├── users.rst
253270
│   └── webiscite.rst
254271
├── locale // translations
255272
│   └── README.rst
256273
├── requirements // python dependencies
257-
│   ├── base.txt // base dependencies shared across enviornments
274+
│   ├── base.txt // base dependencies shared across environments
258275
│   ├── local.txt // local development
259276
│   └── production.txt // production deployment
260277
├── .dockerignore // files not to copy into docker containers
@@ -263,21 +280,23 @@ word or are not familiar with a tool, google it!
263280
├── .gitignore // files which should not be tracked by git
264281
├── .pre-commit-config.yaml // configuration for linting and checks to run before each commit
265282
├── .readthedocs.yml // configuration for documentation website
283+
├── CLAUDE.md // guidance for Claude Code / AI assistants working in this repo
266284
├── constitution.json // constitution definition, see about page
267285
├── CONTRIBUTING.rst // contributing guide
268286
├── CONTRIBUTORS.txt // list of project contributors. Be sure to add yourself!
269287
│   // dockerfiles for docker compose live in "compose/"
270288
├── docker-compose.local.yml // docker compose configuration for local development
271289
├── docker-compose.production.yml // docker compose configuration for production deployment
290+
├── docker-compose.telemetry.yml // Prometheus, Loki, Tempo, Grafana (expects external compose networks)
272291
├── justfile // command shortcuts for local development NOT using devcontainer
273292
├── LICENSE // Legal permissible uses of the software. MIT license is very liberal
274293
├── manage.py // file for running django management commands
275294
├── pyproject.toml // python tool configuration, incl. pytest, mypy, and ruff
276295
├── README.rst // general info and introduction to project
277296
└── repository_map.txt // documentation about the layout and purpose of the repository (this file!)
278297

279-
63 directories, 228 files // that's kinda a lot ngl
298+
71 directories, 260 files
280299

281300
This file was generated using:
282-
rg --files --hidden --ignore --glob '!.git/' "$@" | tree --fromfile --dirsfirst -a
301+
git ls-files | tree --fromfile --dirsfirst -a
283302
and annotated by hand. Other methods generally ignore too few or too many files.

0 commit comments

Comments
 (0)