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 "sphinx.ext.autodoc",
35 "sphinx_copybutton",
36 "sphinx.ext.doctest",
37 "sphinx.ext.intersphinx",
38 "sphinxext.opengraph",
39 ]
40
41 # Open Graph metadata
42 ogp_title = "urllib3 documentation"
43 ogp_type = "website"
44 ogp_social_cards = {"image": "images/logo.png", "line_color": "#F09837"}
45 ogp_description = "urllib3 is a user-friendly HTTP client library for Python."
46
47 # Test code blocks only when explicitly specified
48 doctest_test_doctest_blocks = ""
49
50 # Add any paths that contain templates here, relative to this directory.
51 templates_path = ["_templates"]
52
53 # The suffix of source filenames.
54 source_suffix = ".rst"
55
56 # The master toctree document.
57 master_doc = "index"
58
59 # General information about the project.
60 project = "urllib3"
61 copyright = f"{date.today().year}, Andrey Petrov"
62
63 # The short X.Y version.
64 version = urllib3.__version__
65 # The full version, including alpha/beta/rc tags.
66 release = version
67
68 # List of patterns, relative to source directory, that match files and
69 # directories to ignore when looking for source files.
70 exclude_patterns = ["_build"]
71
72 # The name of the Pygments (syntax highlighting) style to use.
73 pygments_style = "friendly"
74
75 # The base URL with a proper language and version.
76 html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "/")
77
78 # The theme to use for HTML and HTML Help pages. See the documentation for
79 # a list of builtin themes.
80 html_theme = "furo"
81 html_favicon = "images/favicon.png"
82
83 html_static_path = ["_static"]
84 html_theme_options = {
85 "announcement": """
86 <a style=\"text-decoration: none; color: white;\"
87 href=\"https://opencollective.com/urllib3/updates/urllib3-is-fundraising-for-http-2-support\">
88 <img src=\"/en/latest/_static/favicon.png\"/> urllib3 is fundraising for HTTP/2 support!
89 </a>
90 """,
91 "sidebar_hide_name": True,
92 "light_logo": "banner.svg",
93 "dark_logo": "dark-logo.svg",
94 }
95
96 intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
97
98 # Show typehints as content of the function or method
99 autodoc_typehints = "description"
100
101 # Warn about all references to unknown targets
102 nitpicky = True
103 # Except for these ones, which we expect to point to unknown targets:
104 nitpick_ignore = [
105 ("py:class", "_TYPE_SOCKS_OPTIONS"),
106 ("py:class", "_TYPE_SOCKET_OPTIONS"),
107 ("py:class", "_TYPE_TIMEOUT"),
108 ("py:class", "_TYPE_FIELD_VALUE"),
109 ("py:class", "_TYPE_BODY"),
110 ("py:class", "_HttplibHTTPResponse"),
111 ("py:class", "_HttplibHTTPMessage"),
112 ("py:class", "TracebackType"),
113 ("py:class", "email.errors.MessageDefect"),
114 ("py:class", "MessageDefect"),
115 ("py:class", "http.client.HTTPMessage"),
116 ("py:class", "RequestHistory"),
117 ("py:class", "SSLTransportType"),
118 ("py:class", "VerifyMode"),
119 ("py:class", "_ssl._SSLContext"),
120 ("py:class", "urllib3._collections.HTTPHeaderDict"),
121 ("py:class", "urllib3._collections.RecentlyUsedContainer"),
122 ("py:class", "urllib3._request_methods.RequestMethods"),
123 ("py:class", "urllib3.contrib.socks._TYPE_SOCKS_OPTIONS"),
124 ("py:class", "urllib3.util.timeout._TYPE_DEFAULT"),
125 ("py:class", "BaseHTTPConnection"),
126 ]