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

Commit d5324ee

Browse files
reivilibreclokep
andauthored
Add developer documentation for the Federation Sender and add a documentation mechanism using Sphinx. (#15265)
Co-authored-by: Patrick Cloke <[email protected]>
1 parent 5f7c908 commit d5324ee

File tree

12 files changed

+1280
-509
lines changed

12 files changed

+1280
-509
lines changed

.ci/scripts/prepare_old_deps.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ sed -i \
3535
# compatible (as far the package metadata declares, anyway); pip's package resolver
3636
# is more lax.
3737
#
38-
# Rather than `poetry install --no-dev`, we drop all dev dependencies from the
39-
# toml file. This means we don't have to ensure compatibility between old deps and
40-
# dev tools.
38+
# Rather than `poetry install --no-dev`, we drop all dev dependencies and the dev-docs
39+
# group from the toml file. This means we don't have to ensure compatibility between
40+
# old deps and dev tools.
4141

4242
pip install toml wheel
4343

@@ -47,6 +47,7 @@ with open('pyproject.toml', 'r') as f:
4747
data = toml.loads(f.read())
4848
4949
del data['tool']['poetry']['dev-dependencies']
50+
del data['tool']['poetry']['group']['dev-docs']
5051
5152
with open('pyproject.toml', 'w') as f:
5253
toml.dump(data, f)

.github/workflows/docs.yaml

+58-19
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,10 @@ on:
1313
workflow_dispatch:
1414

1515
jobs:
16-
pages:
17-
name: GitHub Pages
16+
pre:
17+
name: Calculate variables for GitHub Pages deployment
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v3
21-
22-
- name: Setup mdbook
23-
uses: peaceiris/actions-mdbook@adeb05db28a0c0004681db83893d56c0388ea9ea # v1.2.0
24-
with:
25-
mdbook-version: '0.4.17'
26-
27-
- name: Build the documentation
28-
# mdbook will only create an index.html if we're including docs/README.md in SUMMARY.md.
29-
# However, we're using docs/README.md for other purposes and need to pick a new page
30-
# as the default. Let's opt for the welcome page instead.
31-
run: |
32-
mdbook build
33-
cp book/welcome_and_overview.html book/index.html
34-
3520
# Figure out the target directory.
3621
#
3722
# The target directory depends on the name of the branch
@@ -55,11 +40,65 @@ jobs:
5540
5641
# finally, set the 'branch-version' var.
5742
echo "branch-version=$branch" >> "$GITHUB_OUTPUT"
58-
43+
outputs:
44+
branch-version: ${{ steps.vars.outputs.branch-version }}
45+
46+
################################################################################
47+
pages-docs:
48+
name: GitHub Pages
49+
runs-on: ubuntu-latest
50+
needs:
51+
- pre
52+
steps:
53+
- uses: actions/checkout@v3
54+
55+
- name: Setup mdbook
56+
uses: peaceiris/actions-mdbook@adeb05db28a0c0004681db83893d56c0388ea9ea # v1.2.0
57+
with:
58+
mdbook-version: '0.4.17'
59+
60+
- name: Build the documentation
61+
# mdbook will only create an index.html if we're including docs/README.md in SUMMARY.md.
62+
# However, we're using docs/README.md for other purposes and need to pick a new page
63+
# as the default. Let's opt for the welcome page instead.
64+
run: |
65+
mdbook build
66+
cp book/welcome_and_overview.html book/index.html
67+
5968
# Deploy to the target directory.
6069
- name: Deploy to gh pages
6170
uses: peaceiris/actions-gh-pages@bd8c6b06eba6b3d25d72b7a1767993c0aeee42e7 # v3.9.2
6271
with:
6372
github_token: ${{ secrets.GITHUB_TOKEN }}
6473
publish_dir: ./book
65-
destination_dir: ./${{ steps.vars.outputs.branch-version }}
74+
destination_dir: ./${{ needs.pre.outputs.branch-version }}
75+
76+
################################################################################
77+
pages-devdocs:
78+
name: GitHub Pages (developer docs)
79+
runs-on: ubuntu-latest
80+
needs:
81+
- pre
82+
steps:
83+
- uses: action/checkout@v3
84+
85+
- name: "Set up Sphinx"
86+
uses: matrix-org/setup-python-poetry@v1
87+
with:
88+
python-version: "3.x"
89+
poetry-version: "1.3.2"
90+
groups: "dev-docs"
91+
extras: ""
92+
93+
- name: Build the documentation
94+
run: |
95+
cd dev-docs
96+
poetry run make html
97+
98+
# Deploy to the target directory.
99+
- name: Deploy to gh pages
100+
uses: peaceiris/actions-gh-pages@bd8c6b06eba6b3d25d72b7a1767993c0aeee42e7 # v3.9.2
101+
with:
102+
github_token: ${{ secrets.GITHUB_TOKEN }}
103+
publish_dir: ./dev-docs/_build/html
104+
destination_dir: ./dev-docs/${{ needs.pre.outputs.branch-version }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ __pycache__/
5353
/coverage.*
5454
/dist/
5555
/docs/build/
56+
/dev-docs/_build/
5657
/htmlcov
5758
/pip-wheel-metadata/
5859

changelog.d/15265.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add developer documentation for the Federation Sender and add a documentation mechanism using Sphinx.

dev-docs/Makefile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

dev-docs/conf.py

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
6+
# -- Project information -----------------------------------------------------
7+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8+
9+
project = "Synapse development"
10+
copyright = "2023, The Matrix.org Foundation C.I.C."
11+
author = "The Synapse Maintainers and Community"
12+
13+
# -- General configuration ---------------------------------------------------
14+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
15+
16+
extensions = [
17+
"autodoc2",
18+
"myst_parser",
19+
]
20+
21+
templates_path = ["_templates"]
22+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
23+
24+
25+
# -- Options for Autodoc2 ----------------------------------------------------
26+
27+
autodoc2_docstring_parser_regexes = [
28+
# this will render all docstrings as 'MyST' Markdown
29+
(r".*", "myst"),
30+
]
31+
32+
autodoc2_packages = [
33+
{
34+
"path": "../synapse",
35+
# Don't render documentation for everything as a matter of course
36+
"auto_mode": False,
37+
},
38+
]
39+
40+
41+
# -- Options for MyST (Markdown) ---------------------------------------------
42+
43+
# myst_heading_anchors = 2
44+
45+
46+
# -- Options for HTML output -------------------------------------------------
47+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
48+
49+
html_theme = "furo"
50+
html_static_path = ["_static"]

dev-docs/index.rst

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.. Synapse Developer Documentation documentation master file, created by
2+
sphinx-quickstart on Mon Mar 13 08:59:51 2023.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
Welcome to the Synapse Developer Documentation!
7+
===========================================================
8+
9+
.. toctree::
10+
:maxdepth: 2
11+
:caption: Contents:
12+
13+
modules/federation_sender
14+
15+
16+
17+
Indices and tables
18+
==================
19+
20+
* :ref:`genindex`
21+
* :ref:`modindex`
22+
* :ref:`search`

dev-docs/modules/federation_sender.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Federation Sender
2+
=================
3+
4+
```{autodoc2-docstring} synapse.federation.sender
5+
```

0 commit comments

Comments
 (0)