Debian Codegraph @

docs/conf.py

raw
1 from __future__ import annotations
2
3 import os
4 import sys
5 from datetime import date
6
7 # If extensions (or modules to document with autodoc) are in another directory,
8 # add these directories to sys.path here. If the directory is relative to the
9 # documentation root, use os.path.abspath to make it absolute, like shown here.
10
11 root_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
12 sys.path.insert(0, root_path)
13
14 # https://docs.readthedocs.io/en/stable/builds.html#build-environment
15 if "READTHEDOCS" in os.environ:
16 import glob
17
18 if glob.glob("../changelog/*.*.rst"):
19 print("-- Found changes; running towncrier --", flush=True)
20 import subprocess
21
22 subprocess.run(
23 ["towncrier", "--yes", "--date", "not released yet"], cwd="..", check=True
24 )
25
26 import urllib3
27
28 # -- General configuration -----------------------------------------------------
29
30
31 # Add any Sphinx extension module names here, as strings. They can be extensions
32 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
33 extensions = [
34 "myst_parser",
35 "sphinx.ext.autodoc",
36 "sphinx_copybutton",
37 "sphinx.ext.doctest",
38 "sphinx.ext.intersphinx",
39 "sphinxext.opengraph",
40 ]
41
42 myst_enable_extensions = ["alert"]
43
44 # Open Graph metadata
45 ogp_title = "urllib3 documentation"
46 ogp_type = "website"
47 ogp_social_cards = {"image": "images/logo.png", "line_color": "#F09837"}
48 ogp_description = "urllib3 is a user-friendly HTTP client library for Python."
49
50 # Test code blocks only when explicitly specified
51 doctest_test_doctest_blocks = ""
52
53 # Add any paths that contain templates here, relative to this directory.
54 templates_path = ["_templates"]
55
56 # The suffix of source filenames.
57 source_suffix = ".rst"
58
59 # The master toctree document.
60 master_doc = "index"
61
62 # General information about the project.
63 project = "urllib3"
64 copyright = f"{date.today().year}, Andrey Petrov"
65
66 # The short X.Y version.
67 version = urllib3.__version__
68 # The full version, including alpha/beta/rc tags.
69 release = version
70
71 # List of patterns, relative to source directory, that match files and
72 # directories to ignore when looking for source files.
73 exclude_patterns = ["_build"]
74
75 # The name of the Pygments (syntax highlighting) style to use.
76 pygments_style = "friendly"
77
78 # The base URL with a proper language and version.
79 html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "/")
80
81 # The theme to use for HTML and HTML Help pages. See the documentation for
82 # a list of builtin themes.
83 html_theme = "furo"
84 html_favicon = "images/favicon.png"
85
86 html_static_path = ["_static"]
87 html_theme_options = {
88 "announcement": """
89 <a style=\"text-decoration: none; color: white;\"
90 href=\"https://opencollective.com/urllib3/updates/urllib3-is-fundraising-for-http-2-support\">
91 <img src=\"/en/latest/_static/favicon.png\"/> urllib3 is fundraising for HTTP/2 support!
92 </a>
93 """,
94 "sidebar_hide_name": True,
95 "light_logo": "banner.svg",
96 "dark_logo": "dark-logo.svg",
97 }
98
99 intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
100
101 # Show typehints as content of the function or method
102 autodoc_typehints = "description"
103
104 # Warn about all references to unknown targets
105 nitpicky = True
106 # Except for these ones, which we expect to point to unknown targets:
107 nitpick_ignore = [
108 ("py:class", "_TYPE_SOCKS_OPTIONS"),
109 ("py:class", "_TYPE_SOCKET_OPTIONS"),
110 ("py:class", "_TYPE_TIMEOUT"),
111 ("py:class", "_TYPE_FIELD_VALUE"),
112 ("py:class", "_TYPE_BODY"),
113 ("py:class", "_HttplibHTTPResponse"),
114 ("py:class", "_HttplibHTTPMessage"),
115 ("py:class", "TracebackType"),
116 ("py:class", "email.errors.MessageDefect"),
117 ("py:class", "MessageDefect"),
118 ("py:class", "http.client.HTTPMessage"),
119 ("py:class", "RequestHistory"),
120 ("py:class", "SSLTransportType"),
121 ("py:class", "VerifyMode"),
122 ("py:class", "_ssl._SSLContext"),
123 ("py:class", "urllib3._collections.HTTPHeaderDict"),
124 ("py:class", "urllib3._collections.RecentlyUsedContainer"),
125 ("py:class", "urllib3._request_methods.RequestMethods"),
126 ("py:class", "urllib3.contrib.socks._TYPE_SOCKS_OPTIONS"),
127 ("py:class", "urllib3.util.timeout._TYPE_DEFAULT"),
128 ("py:class", "BaseHTTPConnection"),
129 ]