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

Commit

Permalink
Compile and render Synapse's docs into a browsable, mobile-friendly a…
Browse files Browse the repository at this point in the history
…nd searchable website (#10086)
  • Loading branch information
anoadragon453 authored Jun 3, 2021
1 parent 9eea464 commit fd9856e
Show file tree
Hide file tree
Showing 35 changed files with 978 additions and 54 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Deploy the documentation

on:
push:
branches:
- develop

workflow_dispatch:

jobs:
pages:
name: GitHub Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup mdbook
uses: peaceiris/actions-mdbook@4b5ef36b314c2599664ca107bb8c02412548d79d # v1.1.14
with:
mdbook-version: '0.4.9'

- name: Build the documentation
run: mdbook build

- name: Deploy latest documentation
uses: peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305 # v3.8.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
keep_files: true
publish_dir: ./book
destination_dir: ./develop
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ __pycache__/
/docs/build/
/htmlcov
/pip-wheel-metadata/

# docs
book/
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ exclude mypy.ini
exclude sytest-blacklist
exclude test_postgresql.sh

include book.toml
include pyproject.toml
recursive-include changelog.d *

Expand Down
39 changes: 39 additions & 0 deletions book.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Documentation for possible options in this file is at
# https://rust-lang.github.io/mdBook/format/config.html
[book]
title = "Synapse"
authors = ["The Matrix.org Foundation C.I.C."]
language = "en"
multilingual = false

# The directory that documentation files are stored in
src = "docs"

[build]
# Prevent markdown pages from being automatically generated when they're
# linked to in SUMMARY.md
create-missing = false

[output.html]
# The URL visitors will be directed to when they try to edit a page
edit-url-template = "https://github.com/matrix-org/synapse/edit/develop/{path}"

# Remove the numbers that appear before each item in the sidebar, as they can
# get quite messy as we nest deeper
no-section-label = true

# The source code URL of the repository
git-repository-url = "https://github.com/matrix-org/synapse"

# The path that the docs are hosted on
site-url = "/synapse/"

# Additional HTML, JS, CSS that's injected into each page of the book.
# More information available in docs/website_files/README.md
additional-css = [
"docs/website_files/table-of-contents.css",
"docs/website_files/remove-nav-buttons.css",
"docs/website_files/indent-section-headers.css",
]
additional-js = ["docs/website_files/table-of-contents.js"]
theme = "docs/website_files/theme"
1 change: 1 addition & 0 deletions changelog.d/10086.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add initial infrastructure for rendering Synapse documentation with mdbook.
71 changes: 68 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,72 @@
# Synapse Documentation

This directory contains documentation specific to the `synapse` homeserver.
**The documentation is currently hosted [here](https://matrix-org.github.io/synapse).**
Please update any links to point to the new website instead.

All matrix-generic documentation now lives in its own project, located at [matrix-org/matrix-doc](https://github.com/matrix-org/matrix-doc)
## About

(Note: some items here may be moved to [matrix-org/matrix-doc](https://github.com/matrix-org/matrix-doc) at some point in the future.)
This directory currently holds a series of markdown files documenting how to install, use
and develop Synapse, the reference Matrix homeserver. The documentation is readable directly
from this repository, but it is recommended to instead browse through the
[website](https://matrix-org.github.io/synapse) for easier discoverability.

## Adding to the documentation

Most of the documentation currently exists as top-level files, as when organising them into
a structured website, these files were kept in place so that existing links would not break.
The rest of the documentation is stored in folders, such as `setup`, `usage`, and `development`
etc. **All new documentation files should be placed in structured folders.** For example:

To create a new user-facing documentation page about a new Single Sign-On protocol named
"MyCoolProtocol", one should create a new file with a relevant name, such as "my_cool_protocol.md".
This file might fit into the documentation structure at:

- Usage
- Configuration
- User Authentication
- Single Sign-On
- **My Cool Protocol**

Given that, one would place the new file under
`usage/configuration/user_authentication/single_sign_on/my_cool_protocol.md`.

Note that the structure of the documentation (and thus the left sidebar on the website) is determined
by the list in [SUMMARY.md](SUMMARY.md). The final thing to do when adding a new page is to add a new
line linking to the new documentation file:

```markdown
- [My Cool Protocol](usage/configuration/user_authentication/single_sign_on/my_cool_protocol.md)
```

## Building the documentation

The documentation is built with [mdbook](https://rust-lang.github.io/mdBook/), and the outline of the
documentation is determined by the structure of [SUMMARY.md](SUMMARY.md).

First, [get mdbook](https://github.com/rust-lang/mdBook#installation). Then, **from the root of the repository**,
build the documentation with:

```sh
mdbook build
```

The rendered contents will be outputted to a new `book/` directory at the root of the repository. You can
browse the book by opening `book/index.html` in a web browser.

You can also have mdbook host the docs on a local webserver with hot-reload functionality via:

```sh
mdbook serve
```

The URL at which the docs can be viewed at will be logged.

## Configuration and theming

The look and behaviour of the website is configured by the [book.toml](../book.toml) file
at the root of the repository. See
[mdbook's documentation on configuration](https://rust-lang.github.io/mdBook/format/config.html)
for available options.

The site can be themed and additionally extended with extra UI and features. See
[website_files/README.md](website_files/README.md) for details.
87 changes: 87 additions & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Summary

# Introduction
- [Welcome and Overview](welcome_and_overview.md)

# Setup
- [Installation](setup/installation.md)
- [Using Postgres](postgres.md)
- [Configuring a Reverse Proxy](reverse_proxy.md)
- [Configuring a Turn Server](turn-howto.md)
- [Delegation](delegate.md)

# Upgrading
- [Upgrading between Synapse Versions](upgrading/README.md)
- [Upgrading from pre-Synapse 1.0](MSC1711_certificates_FAQ.md)

# Usage
- [Federation](federate.md)
- [Configuration](usage/configuration/README.md)
- [Homeserver Sample Config File](usage/configuration/homeserver_sample_config.md)
- [Logging Sample Config File](usage/configuration/logging_sample_config.md)
- [Structured Logging](structured_logging.md)
- [User Authentication](usage/configuration/user_authentication/README.md)
- [Single-Sign On]()
- [OpenID Connect](openid.md)
- [SAML]()
- [CAS]()
- [SSO Mapping Providers](sso_mapping_providers.md)
- [Password Auth Providers](password_auth_providers.md)
- [JSON Web Tokens](jwt.md)
- [Registration Captcha](CAPTCHA_SETUP.md)
- [Application Services](application_services.md)
- [Server Notices](server_notices.md)
- [Consent Tracking](consent_tracking.md)
- [URL Previews](url_previews.md)
- [User Directory](user_directory.md)
- [Message Retention Policies](message_retention_policies.md)
- [Pluggable Modules]()
- [Third Party Rules]()
- [Spam Checker](spam_checker.md)
- [Presence Router](presence_router_module.md)
- [Media Storage Providers]()
- [Workers](workers.md)
- [Using `synctl` with Workers](synctl_workers.md)
- [Systemd](systemd-with-workers/README.md)
- [Administration](usage/administration/README.md)
- [Admin API](usage/administration/admin_api/README.md)
- [Account Validity](admin_api/account_validity.md)
- [Delete Group](admin_api/delete_group.md)
- [Event Reports](admin_api/event_reports.md)
- [Media](admin_api/media_admin_api.md)
- [Purge History](admin_api/purge_history_api.md)
- [Purge Rooms](admin_api/purge_room.md)
- [Register Users](admin_api/register_api.md)
- [Manipulate Room Membership](admin_api/room_membership.md)
- [Rooms](admin_api/rooms.md)
- [Server Notices](admin_api/server_notices.md)
- [Shutdown Room](admin_api/shutdown_room.md)
- [Statistics](admin_api/statistics.md)
- [Users](admin_api/user_admin_api.md)
- [Server Version](admin_api/version_api.md)
- [Manhole](manhole.md)
- [Monitoring](metrics-howto.md)
- [Scripts]()

# Development
- [Contributing Guide](development/contributing_guide.md)
- [Code Style](code_style.md)
- [Git Usage](dev/git.md)
- [Testing]()
- [OpenTracing](opentracing.md)
- [Synapse Architecture]()
- [Log Contexts](log_contexts.md)
- [Replication](replication.md)
- [TCP Replication](tcp_replication.md)
- [Internal Documentation](development/internal_documentation/README.md)
- [Single Sign-On]()
- [SAML](dev/saml.md)
- [CAS](dev/cas.md)
- [State Resolution]()
- [The Auth Chain Difference Algorithm](auth_chain_difference_algorithm.md)
- [Media Repository](media_repository.md)
- [Room and User Statistics](room_and_user_statistics.md)
- [Scripts]()

# Other
- [Dependency Deprecation Policy](deprecation_policy.md)
30 changes: 8 additions & 22 deletions docs/admin_api/README.rst
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
Admin APIs
==========

This directory includes documentation for the various synapse specific admin
APIs available.

Authenticating as a server admin
--------------------------------

Many of the API calls in the admin api will require an `access_token` for a
server admin. (Note that a server admin is distinct from a room admin.)

A user can be marked as a server admin by updating the database directly, e.g.:

.. code-block:: sql
**Note**: The latest documentation can be viewed `here <https://matrix-org.github.io/synapse>`_.
See `docs/README.md <../docs/README.md>`_ for more information.

UPDATE users SET admin = 1 WHERE name = '@foo:bar.com';
**Please update links to point to the website instead.** Existing files in this directory
are preserved to maintain historical links, but may be moved in the future.

A new server admin user can also be created using the
``register_new_matrix_user`` script.

Finding your user's `access_token` is client-dependent, but will usually be shown in the client's settings.

Once you have your `access_token`, to include it in a request, the best option is to add the token to a request header:

``curl --header "Authorization: Bearer <access_token>" <the_rest_of_your_API_request>``
This directory includes documentation for the various synapse specific admin
APIs available. Updates to the existing Admin API documentation should still
be made to these files, but any new documentation files should instead be placed under
`docs/usage/administration/admin_api <../docs/usage/administration/admin_api>`_.

Fore more details, please refer to the complete `matrix spec documentation <https://matrix.org/docs/spec/client_server/r0.5.0#using-access-tokens>`_.
2 changes: 1 addition & 1 deletion docs/admin_api/delete_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ POST /_synapse/admin/v1/delete_group/<group_id>
```

To use it, you will need to authenticate by providing an `access_token` for a
server admin: see [README.rst](README.rst).
server admin: see [Admin API](../../usage/administration/admin_api).
4 changes: 2 additions & 2 deletions docs/admin_api/event_reports.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The api is:
GET /_synapse/admin/v1/event_reports?from=0&limit=10
```
To use it, you will need to authenticate by providing an `access_token` for a
server admin: see [README.rst](README.rst).
server admin: see [Admin API](../../usage/administration/admin_api).

It returns a JSON body like the following:

Expand Down Expand Up @@ -95,7 +95,7 @@ The api is:
GET /_synapse/admin/v1/event_reports/<report_id>
```
To use it, you will need to authenticate by providing an `access_token` for a
server admin: see [README.rst](README.rst).
server admin: see [Admin API](../../usage/administration/admin_api).

It returns a JSON body like the following:

Expand Down
4 changes: 2 additions & 2 deletions docs/admin_api/media_admin_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The API is:
GET /_synapse/admin/v1/room/<room_id>/media
```
To use it, you will need to authenticate by providing an `access_token` for a
server admin: see [README.rst](README.rst).
server admin: see [Admin API](../../usage/administration/admin_api).

The API returns a JSON body like the following:
```json
Expand Down Expand Up @@ -311,7 +311,7 @@ The following fields are returned in the JSON response body:
* `deleted`: integer - The number of media items successfully deleted

To use it, you will need to authenticate by providing an `access_token` for a
server admin: see [README.rst](README.rst).
server admin: see [Admin API](../../usage/administration/admin_api).

If the user re-requests purged remote media, synapse will re-request the media
from the originating server.
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 @@ -17,7 +17,7 @@ POST /_synapse/admin/v1/purge_history/<room_id>[/<event_id>]
```

To use it, you will need to authenticate by providing an `access_token` for a
server admin: [Admin API](README.rst)
server admin: [Admin API](../../usage/administration/admin_api)

By default, events sent by local users are not deleted, as they may represent
the only copies of this content in existence. (Events sent by remote users are
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 @@ -24,7 +24,7 @@ POST /_synapse/admin/v1/join/<room_id_or_alias>
```

To use it, you will need to authenticate by providing an `access_token` for a
server admin: see [README.rst](README.rst).
server admin: see [Admin API](../../usage/administration/admin_api).

Response:

Expand Down
2 changes: 1 addition & 1 deletion docs/admin_api/rooms.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ with a body of:
```

To use it, you will need to authenticate by providing an ``access_token`` for a
server admin: see [README.rst](README.rst).
server admin: see [Admin API](../../usage/administration/admin_api).

A response body like the following is returned:

Expand Down
2 changes: 1 addition & 1 deletion docs/admin_api/statistics.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GET /_synapse/admin/v1/statistics/users/media
```

To use it, you will need to authenticate by providing an `access_token`
for a server admin: see [README.rst](README.rst).
for a server admin: see [Admin API](../../usage/administration/admin_api).

A response body like the following is returned:

Expand Down
Loading

0 comments on commit fd9856e

Please sign in to comment.