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

Compile and render Synapse's docs into a browsable, mobile-friendly and searchable website #10086

Merged
merged 26 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e453c3b
Setup; add book.toml
anoadragon453 May 10, 2021
f8f770a
Add book/ directory to .gitignore
anoadragon453 May 14, 2021
035d696
Add a favicon
anoadragon453 May 26, 2021
706f64a
Add github actions workflow to deploy docs to gh-pages
anoadragon453 May 11, 2021
99e7ffe
Organise existing documentation into a tree structure.
anoadragon453 May 26, 2021
069712e
Add some section pages
anoadragon453 May 26, 2021
db46987
Add a table of contents plugin
anoadragon453 May 26, 2021
3f9f35d
Remove chapter navigation buttons on desktop
anoadragon453 May 26, 2021
3712044
Update docs/README.md with information on the site and how to build it
anoadragon453 May 26, 2021
fe65330
Update oft-linked to admin_api directory with info about the new site
anoadragon453 May 26, 2021
b4bf418
Refine the sidebar: switch to headers without labels
anoadragon453 May 26, 2021
c6e5eaf
Changelog
anoadragon453 May 27, 2021
8d774a4
Apply suggestions from code review
anoadragon453 May 28, 2021
e9ba348
Apply suggestions from code review
anoadragon453 May 28, 2021
14cb114
Remove comments in workflow, latest -> develop
anoadragon453 May 28, 2021
b6adbd7
Split out homeserver and logging sample config files
anoadragon453 May 28, 2021
2568e5b
Move structured logging up next to the logging configuration chapter
anoadragon453 Jun 1, 2021
9157b8e
Don't link to register_new_matrix_user
anoadragon453 Jun 1, 2021
92c514f
Update docs/usage/configuration/README.md
anoadragon453 Jun 1, 2021
7cb4fd9
Merge branch 'develop' of github.com:matrix-org/synapse into anoa/mdbook
anoadragon453 Jun 3, 2021
170fed8
Switch admin_api SUMMARY entries to their markdown versions; fix link…
anoadragon453 Jun 3, 2021
2b39299
Feature Documentation -> Internal Documentation
anoadragon453 Jun 3, 2021
071a6ef
Add Media Storage Providers draft chapter
anoadragon453 Jun 3, 2021
90520ae
Update mdbooks to 0.4.9; re-enable edit button
anoadragon453 Jun 3, 2021
f896a1b
Drop 'Writing a Module' chapter draft until new module API exists
anoadragon453 Jun 3, 2021
6991e88
Fix links to documentation
anoadragon453 Jun 3, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.8'

- 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
40 changes: 40 additions & 0 deletions book.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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
# Disabled until https://github.com/rust-lang/mdBook/issues/1543 is fixed
#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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we put a link here to the rendered version or maybe we should add it to the release notes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Release notes sounds good - we'll need to flip the switch on the GitHub Pages settings once we've merged anyhow.

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.com/synapse).**
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved
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.com/synapse) for easier discoverability.
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved

## 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)
- [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)
- [Writing a Module]()
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved
- [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.rst)
- [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.rst)
- [Purge Rooms](admin_api/purge_room.md)
- [Register Users](admin_api/register_api.rst)
- [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.rst)
- [Server Version](admin_api/version_api.rst)
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved
- [Manhole](manhole.md)
- [Monitoring](metrics-howto.md)
- [Structured Logging](structured_logging.md)
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved
- [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)
- [Feature Documentation](development/feature_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>`_.
7 changes: 7 additions & 0 deletions docs/development/contributing_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--
Include the contents of CONTRIBUTING.md from the project root (where GitHub likes it
to be)
-->
# Contributing

{{#include ../../CONTRIBUTING.md}}
12 changes: 12 additions & 0 deletions docs/development/feature_documentation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Feature Documentation
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved

This section covers implementation documentation for various features of Synapse.

If a developer is planning to make a change to a feature of Synapse, it can be useful for
general documentation of how that feature is implemented to be available. This saves the
developer time in place of needing to understand how the feature works by reading the
code.

Documentation that would be more useful for the perspective of a sysadmin, rather than
a developer who's intended to change to code, should instead be placed in
[Usage](../../usage/).
Binary file added docs/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions docs/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions docs/setup/installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--
Include the contents of INSTALL.md from the project root without moving it, which may
break links around the internet. Additionally, note that SUMMARY.md is unable to
directly link to content outside of the docs/ directory. So we use this file as a
redirection.
-->
{{#include ../../INSTALL.md}}
7 changes: 7 additions & 0 deletions docs/upgrading/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--
Include the contents of UPGRADE.rst from the project root without moving it, which may
break links around the internet. Additionally, note that SUMMARY.md is unable to
directly link to content outside of the docs/ directory. So we use this file as a
redirection.
-->
{{#include ../../UPGRADE.rst}}
Loading