Skip to content

Commit 81a04f3

Browse files
committed
docs: add Sphinx documentation for 4.0.0
Port the documentation from the Django-based patchwork, rewritten for the Go binary. Cover installation with postfix transport maps, configuration reference, management commands, a migration guide from Django to Go with command and settings mappings, and 4.0.0 release notes via reno. Signed-off-by: Robin Jarry <robin@jarry.cc>
1 parent 61372bd commit 81a04f3

22 files changed

Lines changed: 1704 additions & 1 deletion

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/patchwork.toml
22
/pw
33
*_templ.go
4+
/docs/.venv
5+
/docs/_build

‎Makefile‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,22 @@ install: pw
3434
install -Dm644 etc/nginx.conf $(DESTDIR)$(sysconfdir)/nginx/conf.d/patchwork.conf
3535
$(DESTDIR)$(prefix)/bin/pw config > $(DESTDIR)$(sysconfdir)/patchwork.toml
3636

37+
PYTHON ?= python3
38+
39+
.PHONY: docs
40+
docs:
41+
$Q if ! [ -x docs/.venv/bin/sphinx-build ]; then \
42+
set -xe && \
43+
$(PYTHON) -m venv docs/.venv && \
44+
docs/.venv/bin/pip install -q -r docs/requirements.txt; \
45+
fi
46+
docs/.venv/bin/sphinx-build -b html docs docs/_build
47+
3748
import_reviser ?= github.com/incu6us/goimports-reviser/v3@v3.12.6
3849
import_reviser_flags ?= -rm-unused -project-name github.com/getpatchwork/patchwork
3950
gofumpt ?= mvdan.cc/gofumpt@v0.9.2
4051
golangci_lint ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2
41-
license_exclude = ':!:*.md' ':!:*.asc' ':!:CONTRIBUTORS' ':!:LICENSE' ':!:.*' ':!:go.mod' ':!:go.sum' ':!:pkg/mail/testdata'
52+
license_exclude = ':!:*.md' ':!:*.asc' ':!:*.yaml' ':!:docs/requirements.txt' ':!:*.service' ':!:CONTRIBUTORS' ':!:LICENSE' ':!:.*' ':!:go.mod' ':!:go.sum' ':!:pkg/mail/testdata'
4253

4354
.PHONY: test
4455
test:

‎docs/api/index.rst‎

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
.. Patchwork - automated patch tracking system
2+
.. Copyright (C) The Patchwork Contributors (see CONTRIBUTORS)
3+
..
4+
.. SPDX-License-Identifier: GPL-2.0-or-later
5+
6+
The REST API
7+
============
8+
9+
Patchwork provides a REST API. This API can be used to retrieve and modify
10+
information about patches, projects and more.
11+
12+
This guide provides an overview of how one can interact with the REST API. For
13+
detailed information on type and response format of the various resources
14+
exposed by the API, refer to the auto-generated OpenAPI documentation at::
15+
16+
https://patchwork.example.com/api/docs
17+
18+
where ``patchwork.example.com`` refers to the URL of your Patchwork instance.
19+
20+
.. versionchanged:: 4.0
21+
22+
The OpenAPI schema is now auto-generated at runtime and served at
23+
``/api/docs``. Static schema files are no longer shipped.
24+
25+
.. versionchanged:: 4.0
26+
27+
The XML-RPC API has been removed. Use the REST API with clients like
28+
:program:`git-pw` instead.
29+
30+
Getting Started
31+
---------------
32+
33+
The easiest way to start experimenting with the API is to visit the
34+
auto-generated documentation at ``/api/docs``.
35+
36+
REST APIs run over plain HTTP(S), thus, the API can be interfaced using
37+
applications or libraries that support this widespread protocol. One such
38+
application is `curl`_, which can be used to both retrieve and send information
39+
to the REST API. For example, to get the version of the REST API for a
40+
Patchwork instance hosted at ``patchwork.example.com``, run:
41+
42+
.. code-block:: shell
43+
44+
$ curl -s 'https://patchwork.example.com/api/1.4/' | python -m json.tool
45+
{
46+
"bundles": "https://patchwork.example.com/api/1.4/bundles/",
47+
"covers": "https://patchwork.example.com/api/1.4/covers/",
48+
"events": "https://patchwork.example.com/api/1.4/events/",
49+
"patches": "https://patchwork.example.com/api/1.4/patches/",
50+
"people": "https://patchwork.example.com/api/1.4/people/",
51+
"projects": "https://patchwork.example.com/api/1.4/projects/",
52+
"series": "https://patchwork.example.com/api/1.4/series/",
53+
"users": "https://patchwork.example.com/api/1.4/users/"
54+
}
55+
56+
Tools like `curl` and libraries like `requests` can be used to build anything
57+
from small utilities to full-fledged clients targeting the REST API. For an
58+
overview of existing API clients, refer to :doc:`/usage/clients`.
59+
60+
Versioning
61+
----------
62+
63+
By default, all requests will receive the latest version of the API: currently
64+
``1.4``:
65+
66+
.. code-block:: http
67+
68+
GET /api HTTP/1.1
69+
70+
You should explicitly request this version through the URL to prevent API
71+
changes breaking your application:
72+
73+
.. code-block:: http
74+
75+
GET /api/1.4 HTTP/1.1
76+
77+
Older API versions will be deprecated and removed over time.
78+
79+
.. csv-table::
80+
:header: "API Version", "Supported?"
81+
82+
1.0, yes
83+
1.1, yes
84+
1.2, yes
85+
1.3, yes
86+
1.4, yes
87+
88+
Schema
89+
------
90+
91+
Responses are returned as JSON. Blank fields are returned as ``null``, rather
92+
than being omitted. Timestamps use the ISO 8601 format, times are in UTC::
93+
94+
YYYY-MM-DDTHH:MM:SSZ
95+
96+
Requests should use either query parameters or form-data, depending on the
97+
method.
98+
99+
The auto-generated OpenAPI schema is available at ``/api/docs`` and describes
100+
all endpoints, parameters, and response formats.
101+
102+
Parameters
103+
----------
104+
105+
For ``GET`` requests, parameters should be passed as HTTP query string
106+
parameters:
107+
108+
.. code-block:: shell
109+
110+
$ curl 'https://patchwork.example.com/api/patches?state=under-review'
111+
112+
For ``POST`` and ``PATCH`` requests, parameters should be encoded as JSON with
113+
a ``Content-Type`` of ``application/json``:
114+
115+
.. code-block:: shell
116+
117+
$ curl -X PATCH \
118+
--header "Content-Type: application/json" \
119+
--data '{"state":"under-review"}' \
120+
'https://patchwork.example.com/api/patches/123/'
121+
122+
Authentication
123+
--------------
124+
125+
Patchwork supports authentication using basic authentication (username and
126+
password) or token authentication (recommended).
127+
128+
To authenticate with a token, first obtain one from your profile page, then::
129+
130+
$ curl -H "Authorization: Token ${token}" \
131+
'https://patchwork.example.com/api/'
132+
133+
Not all resources require authentication. Those that do will return
134+
``404 (Not Found)`` if authentication is not provided.
135+
136+
Pagination
137+
----------
138+
139+
Requests that return multiple items are paginated by 30 items by default. You
140+
can change page using the ``?page`` parameter and set custom page sizes up to
141+
250 using the ``?per_page`` parameter:
142+
143+
.. code-block:: shell
144+
145+
$ curl 'https://patchwork.example.com/api/patches?page=2&per_page=100'
146+
147+
The ``Link`` header includes pagination information::
148+
149+
Link: <https://patchwork.example.com/api/patches?page=3&per_page=100>; rel="next",
150+
<https://patchwork.example.com/api/patches?page=50&per_page=100>; rel="last"
151+
152+
153+
.. _curl: https://curl.haxx.se/

‎docs/conf.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Patchwork - automated patch tracking system
2+
# Copyright (C) The Patchwork Contributors (see CONTRIBUTORS)
3+
#
4+
# SPDX-License-Identifier: GPL-2.0-or-later
5+
6+
extensions = [
7+
"reno.sphinxext",
8+
]
9+
10+
templates_path = []
11+
master_doc = "index"
12+
13+
project = "Patchwork"
14+
copyright = "The Patchwork Contributors"
15+
author = "The Patchwork Contributors"
16+
17+
version = "4.0"
18+
release = "4.0.0"
19+
20+
exclude_patterns = ["_build", ".venv"]
21+
22+
html_theme = "sphinx_rtd_theme"

‎docs/deployment/configuration.rst‎

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
.. Patchwork - automated patch tracking system
2+
.. Copyright (C) The Patchwork Contributors (see CONTRIBUTORS)
3+
..
4+
.. SPDX-License-Identifier: GPL-2.0-or-later
5+
6+
Configuration
7+
=============
8+
9+
Patchwork is configured through a TOML file. The default configuration can be
10+
generated with::
11+
12+
$ pw config
13+
14+
Configuration files are loaded in the following order, with later files
15+
overriding earlier ones:
16+
17+
1. ``/etc/patchwork.toml``
18+
2. ``patchwork.toml`` (current directory)
19+
3. ``$PATCHWORK_TOML`` (environment variable)
20+
21+
Command-line flags take precedence over all configuration files.
22+
23+
24+
Settings Reference
25+
------------------
26+
27+
``[database]``
28+
~~~~~~~~~~~~~~
29+
30+
``url``
31+
Database connection URL. Supported schemes:
32+
33+
- ``postgres://user:pass@host/dbname?sslmode=disable``
34+
- ``mysql://user:pass@host/dbname``
35+
- ``sqlite:///path/to/file.db``
36+
37+
``auto-sync``
38+
Automatically run pending migrations when the HTTP server starts.
39+
Default: ``false``.
40+
41+
``[http]``
42+
~~~~~~~~~~
43+
44+
``listen``
45+
HTTP listen address. Default: ``127.0.0.1:8080``.
46+
47+
``base-url``
48+
The public base URL of the Patchwork instance, used for generating links in
49+
emails and API responses. Example: ``https://patchwork.example.com``.
50+
51+
``[ingress]``
52+
~~~~~~~~~~~~~
53+
54+
``listen``
55+
SMTP listen address for the ingress daemon. Default: ``127.0.0.1:2525``.
56+
57+
``max-message-size``
58+
Maximum email message size in bytes. Default: ``10485760`` (10 MB).
59+
60+
``max-recipients``
61+
Maximum number of recipients per message. Default: ``100``.
62+
63+
``[smtp]``
64+
~~~~~~~~~~
65+
66+
Outgoing mail configuration for notifications.
67+
68+
``transport``
69+
SMTP encryption mode. One of ``none``, ``starttls``, ``tls``.
70+
Default: ``none``.
71+
72+
``host``
73+
SMTP server hostname. Default: ``localhost``.
74+
75+
``port``
76+
SMTP server port. Default: ``25``.
77+
78+
``user``
79+
SMTP authentication username. Leave empty for unauthenticated delivery.
80+
81+
``password``
82+
SMTP authentication password.
83+
84+
``from``
85+
Sender email address for outgoing notifications.
86+
Default: ``patchwork@localhost``.
87+
88+
89+
Global Flags
90+
------------
91+
92+
``-S``, ``--syslog``
93+
Redirect logging to syslog instead of stderr.

‎docs/deployment/index.rst‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.. Patchwork - automated patch tracking system
2+
.. Copyright (C) The Patchwork Contributors (see CONTRIBUTORS)
3+
..
4+
.. SPDX-License-Identifier: GPL-2.0-or-later
5+
6+
Deployment
7+
==========
8+
9+
.. toctree::
10+
:maxdepth: 2
11+
12+
installation
13+
configuration
14+
management
15+
upgrading
16+
migration

0 commit comments

Comments
 (0)