Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Improve code formatting and fix a few typos in docs (#11221)
Browse files Browse the repository at this point in the history
* Labeled a lot more code blocks with the appropriate type
* Fixed a couple of minor typos (missing/extraneous commas)

Signed-off-by: Sumner Evans <[email protected]>
  • Loading branch information
sumnerevans authored Nov 1, 2021
1 parent 82d2168 commit ece84f2
Show file tree
Hide file tree
Showing 20 changed files with 233 additions and 168 deletions.
1 change: 1 addition & 0 deletions changelog.d/11221.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve code formatting and fix a few typos in docs. Contributed by @sumnerevans at Beeper.
4 changes: 2 additions & 2 deletions docs/CAPTCHA_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ in `homeserver.yaml`, to the list of authorized domains. If you have not set
1. Agree to the terms of service and submit.
1. Copy your site key and secret key and add them to your `homeserver.yaml`
configuration file
```
```yaml
recaptcha_public_key: YOUR_SITE_KEY
recaptcha_private_key: YOUR_SECRET_KEY
```
1. Enable the CAPTCHA for new registrations
```
```yaml
enable_registration_captcha: true
```
1. Go to the settings page for the CAPTCHA you just created
Expand Down
4 changes: 2 additions & 2 deletions docs/admin_api/event_reports.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ server admin: see [Admin API](../usage/administration/admin_api).

It returns a JSON body like the following:

```jsonc
```json
{
"event_id": "$bNUFCwGzWca1meCGkjp-zwslF-GfVcXukvRLI1_FaVY",
"event_json": {
Expand Down Expand Up @@ -132,7 +132,7 @@ It returns a JSON body like the following:
},
"type": "m.room.message",
"unsigned": {
"age_ts": 1592291711430,
"age_ts": 1592291711430
}
},
"id": <report_id>,
Expand Down
2 changes: 1 addition & 1 deletion docs/admin_api/purge_history_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Room state data (such as joins, leaves, topic) is always preserved.

To delete local message events as well, set `delete_local_events` in the body:

```
```json
{
"delete_local_events": true
}
Expand Down
2 changes: 1 addition & 1 deletion docs/admin_api/room_membership.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ server admin: see [Admin API](../usage/administration/admin_api).

Response:

```
```json
{
"room_id": "!636q39766251:server.com"
}
Expand Down
8 changes: 4 additions & 4 deletions docs/admin_api/rooms.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ GET /_synapse/admin/v1/rooms

A response body like the following is returned:

```jsonc
```json
{
"rooms": [
{
Expand Down Expand Up @@ -170,7 +170,7 @@ GET /_synapse/admin/v1/rooms?order_by=size

A response body like the following is returned:

```jsonc
```json
{
"rooms": [
{
Expand Down Expand Up @@ -208,7 +208,7 @@ A response body like the following is returned:
}
],
"offset": 0,
"total_rooms": 150
"total_rooms": 150,
"next_token": 100
}
```
Expand All @@ -224,7 +224,7 @@ GET /_synapse/admin/v1/rooms?order_by=size&from=100

A response body like the following is returned:

```jsonc
```json
{
"rooms": [
{
Expand Down
78 changes: 46 additions & 32 deletions docs/code_style.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ The necessary tools are detailed below.

First install them with:

pip install -e ".[lint,mypy]"
```sh
pip install -e ".[lint,mypy]"
```

- **black**

Expand All @@ -21,7 +23,9 @@ First install them with:
Have `black` auto-format your code (it shouldn't change any
functionality) with:

black . --exclude="\.tox|build|env"
```sh
black . --exclude="\.tox|build|env"
```

- **flake8**

Expand All @@ -30,7 +34,9 @@ First install them with:

Check all application and test code with:

flake8 synapse tests
```sh
flake8 synapse tests
```

- **isort**

Expand All @@ -39,7 +45,9 @@ First install them with:

Auto-fix imports with:

isort -rc synapse tests
```sh
isort -rc synapse tests
```

`-rc` means to recursively search the given directories.

Expand All @@ -66,15 +74,19 @@ save as it takes a while and is very resource intensive.
Example:
from synapse.types import UserID
...
user_id = UserID(local, server)
```python
from synapse.types import UserID
...
user_id = UserID(local, server)
```
is preferred over:
from synapse import types
...
user_id = types.UserID(local, server)
```python
from synapse import types
...
user_id = types.UserID(local, server)
```
(or any other variant).
Expand Down Expand Up @@ -134,28 +146,30 @@ Some guidelines follow:
Example:
## Frobnication ##

# The frobnicator will ensure that all requests are fully frobnicated.
# To enable it, uncomment the following.
#
#frobnicator_enabled: true

# By default, the frobnicator will frobnicate with the default frobber.
# The following will make it use an alternative frobber.
#
#frobincator_frobber: special_frobber

# Settings for the frobber
#
frobber:
# frobbing speed. Defaults to 1.
#
#speed: 10

# frobbing distance. Defaults to 1000.
#
#distance: 100
```yaml
## Frobnication ##
# The frobnicator will ensure that all requests are fully frobnicated.
# To enable it, uncomment the following.
#
#frobnicator_enabled: true
# By default, the frobnicator will frobnicate with the default frobber.
# The following will make it use an alternative frobber.
#
#frobincator_frobber: special_frobber
# Settings for the frobber
#
frobber:
# frobbing speed. Defaults to 1.
#
#speed: 10
# frobbing distance. Defaults to 1000.
#
#distance: 100
```
Note that the sample configuration is generated from the synapse code
and is maintained by a script, `scripts-dev/generate_sample_config`.
Expand Down
2 changes: 1 addition & 1 deletion docs/consent_tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ construct URIs where users can give their consent.
see if an unauthenticated user is viewing the page. This is typically
wrapped around the form that would be used to actually agree to the document:

```
```html
{% if not public_version %}
<!-- The variables used here are only provided when the 'u' param is given to the homeserver -->
<form method="post" action="consent">
Expand Down
2 changes: 1 addition & 1 deletion docs/delegate.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ is running a modern version of Synapse.
### Do I need the same certificate for the client and federation port?

No. There is nothing stopping you from using different certificates,
particularly if you are using a reverse proxy.
particularly if you are using a reverse proxy.
8 changes: 4 additions & 4 deletions docs/development/cas.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ easy to run CAS implementation built on top of Django.
1. Create a new virtualenv: `python3 -m venv <your virtualenv>`
2. Activate your virtualenv: `source /path/to/your/virtualenv/bin/activate`
3. Install Django and django-mama-cas:
```
```sh
python -m pip install "django<3" "django-mama-cas==2.4.0"
```
4. Create a Django project in the current directory:
```
```sh
django-admin startproject cas_test .
```
5. Follow the [install directions](https://django-mama-cas.readthedocs.io/en/latest/installation.html#configuring) for django-mama-cas
6. Setup the SQLite database: `python manage.py migrate`
7. Create a user:
```
```sh
python manage.py createsuperuser
```
1. Use whatever you want as the username and password.
2. Leave the other fields blank.
8. Use the built-in Django test server to serve the CAS endpoints on port 8000:
```
```sh
python manage.py runserver
```

Expand Down
4 changes: 3 additions & 1 deletion docs/development/database_schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ To do so, use `scripts-dev/make_full_schema.sh`. This will produce new

Ensure postgres is installed, then run:

./scripts-dev/make_full_schema.sh -p postgres_username -o output_dir/
```sh
./scripts-dev/make_full_schema.sh -p postgres_username -o output_dir/
```

NB at the time of writing, this script predates the split into separate `state`/`main`
databases so will require updates to handle that correctly.
Expand Down
2 changes: 1 addition & 1 deletion docs/development/saml.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To make Synapse (and therefore Element) use it:
sp_config:
allow_unknown_attributes: true # Works around a bug with AVA Hashes: https://github.com/IdentityPython/pysaml2/issues/388
metadata:
local: ["samling.xml"]
local: ["samling.xml"]
```
5. Ensure that your `homeserver.yaml` has a setting for `public_baseurl`:
```yaml
Expand Down
26 changes: 13 additions & 13 deletions docs/message_retention_policies.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ A default policy can be defined as such, in the `retention` section of
the configuration file:

```yaml
default_policy:
min_lifetime: 1d
max_lifetime: 1y
default_policy:
min_lifetime: 1d
max_lifetime: 1y
```
Here, `min_lifetime` and `max_lifetime` have the same meaning and level
Expand All @@ -95,14 +95,14 @@ depending on an event's room's policy. This can be done by setting the
file. An example of such configuration could be:

```yaml
purge_jobs:
- longest_max_lifetime: 3d
interval: 12h
- shortest_max_lifetime: 3d
longest_max_lifetime: 1w
interval: 1d
- shortest_max_lifetime: 1w
interval: 2d
purge_jobs:
- longest_max_lifetime: 3d
interval: 12h
- shortest_max_lifetime: 3d
longest_max_lifetime: 1w
interval: 1d
- shortest_max_lifetime: 1w
interval: 2d
```

In this example, we define three jobs:
Expand Down Expand Up @@ -141,8 +141,8 @@ purging old events in a room. These limits can be defined as such in the
`retention` section of the configuration file:

```yaml
allowed_lifetime_min: 1d
allowed_lifetime_max: 1y
allowed_lifetime_min: 1d
allowed_lifetime_max: 1y
```

The limits are considered when running purge jobs. If necessary, the
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/password_auth_provider_callbacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ registered by using the Module API's `register_password_auth_provider_callbacks`

_First introduced in Synapse v1.46.0_

```
```python
auth_checkers: Dict[Tuple[str,Tuple], Callable]
```

Expand Down
Loading

0 comments on commit ece84f2

Please sign in to comment.