File: conf.py

package info (click to toggle)
pygobject 3.55.3-3
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 6,000 kB
  • sloc: ansic: 39,431; python: 26,883; sh: 114; makefile: 81; xml: 35; cpp: 1
file content (82 lines) | stat: -rw-r--r-- 2,350 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
extensions = [
    "sphinx.ext.todo",
    "sphinx.ext.intersphinx",
    "sphinx.ext.extlinks",
    "sphinx_copybutton",
]

import re
import shutil
from pathlib import Path


def post_process_build(app, exception):
    """Flatten static files and fix HTML paths for subdirectories."""
    if exception:
        return

    static = Path(app.outdir) / "_static"
    # Flatten images directory
    if (img := static / "images").exists():
        for f in img.iterdir():
            if f.is_file():
                shutil.move(str(f), str(static / f.name))
        img.rmdir()

    # Fix _static/ paths in HTML
    for html in Path(app.outdir).rglob("*.html"):
        depth = len(html.relative_to(app.outdir).parts) - 1
        prefix = "../" * depth + "_static/" if depth else "_static/"
        content = html.read_text(encoding="utf-8")
        if (new := re.sub(r'src="_static/', f'src="{prefix}', content)) != content:
            html.write_text(new, encoding="utf-8")


def setup(app):
    app.connect("build-finished", post_process_build)


intersphinx_mapping = {
    "python": ("https://docs.python.org/3", None),
    "cairo": ("https://pycairo.readthedocs.io/en/latest", None),
    "apidocs": (
        "https://api.pygobject.gnome.org/",
        None,
    ),
}

source_suffix = {".rst": "restructuredtext"}
master_doc = "index"
exclude_patterns = ["_build", "README.rst"]

pygments_style = "tango"
html_theme = "pydata_sphinx_theme"
html_show_copyright = False
html_favicon = "images/favicon.ico"
project = "PyGObject"
html_title = project

html_context = {
    "extra_css_files": [
        "_static/extra.css",
    ],
    "display_gitlab": True,
    "gitlab_user": "GNOME",
    "gitlab_repo": "pygobject",
    "gitlab_version": "main",
    "conf_py_path": "/docs/",
    "gitlab_host": "gitlab.gnome.org",
}

html_static_path = ["images", "."]

extlinks = {
    "bzbug": ("https://bugzilla.gnome.org/show_bug.cgi?id=%s", "bz#%s"),
    "issue": ("https://gitlab.gnome.org/GNOME/pygobject/-/issues/%s", "#%s"),
    "commit": ("https://gitlab.gnome.org/GNOME/pygobject/commit/%s", "%s"),
    "mr": ("https://gitlab.gnome.org/GNOME/pygobject/-/merge_requests/%s", "!%s"),
    "user": ("https://gitlab.gnome.org/%s", "%s"),
    "devdocs": ("https://developer.gnome.org/documentation/%s.html", None),
}

suppress_warnings = ["image.nonlocal_uri"]