Debian Codegraph @

docs/conf.py

raw ◀ ▶
1 Debian patch touch this file
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 import os
7 import sys
8 import datetime
9
10 sys.path.append(os.path.abspath("./_pygments"))
11
12 # -- Project information -----------------------------------------------------
13 # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
14
15 project = "autoray"
16 copyright = f"2019-{datetime.date.today().year}, Johnnie Gray"
17 author = "Johnnie Gray"
18
19 try:
•20 sys.path.append(os.path.abspath("../"))
21 from autoray import __version__
22
23 release = __version__
24 except ImportError:
25 try:
26 from importlib.metadata import version as _version
27
28 release = _version("autoray")
29 except ImportError:
30 release = "0.0.0+unknown"
31
32 # -- General configuration ---------------------------------------------------
33 # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
34
35 extensions = [
36 "sphinx.ext.intersphinx",
37 "sphinx.ext.extlinks",
38 "sphinx.ext.napoleon",
39 "sphinx.ext.linkcode",
40 "sphinx_copybutton",
41 "autoapi.extension",
42 ]
43
44 # sphinx-autoapi
45 autoapi_dirs = ["../autoray"]
46
47 templates_path = ["_templates"]
48 exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "**.ipynb_checkpoints"]
49
50 # -- Options for HTML output -------------------------------------------------
51 # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
52
53 html_theme = "furo"
54
55 html_theme_options = {
56 "sidebar_hide_name": True,
57 "light_css_variables": {
58 # "color-brand-primary": "hsl(72, 75%, 40%)",
59 # "color-brand-content": "hsl(238, 50%, 60%)",
60 "font-stack": "Atkinson Hyperlegible, sans-serif",
61 "font-stack--monospace": "Spline Sans Mono, monospace",
62 "font-stack--headings": "Spline Sans Mono, monospace",
63 },
64 # "dark_css_variables": {
65 # "color-brand-primary": "hsl(72, 75%, 60%)",
66 # "color-brand-content": "hsl(238, 75%, 70%)",
67 # },
68 "light_logo": "autoray-header.png",
69 "dark_logo": "autoray-header.png",
70 }
71
72 html_css_files = ["my-styles.css"]
73 html_static_path = ["_static"]
74 html_favicon = "_static/autoray.ico"
75
76 pygments_style = "_pygments_light.MarianaLight"
77 pygments_dark_style = "_pygments_dark.MarianaDark"
78
79
80 def linkcode_resolve(domain, info):
81 """
82 Determine the URL corresponding to Python object
83 """
84 import autoray
85 import inspect
86
87 if domain != "py":
88 return None
89
90 modname = info["module"]
91 fullname = info["fullname"]
92
93 submod = sys.modules.get(modname)
94 if submod is None:
95 return None
96
97 obj = submod
98 for part in fullname.split("."):
99 try:
100 obj = getattr(obj, part)
101 except AttributeError:
102 return None
103
104 try:
105 fn = inspect.getsourcefile(inspect.unwrap(obj))
106 except TypeError:
107 fn = None
108 if not fn:
109 return None
110
111 try:
112 source, lineno = inspect.getsourcelines(obj)
113 except OSError:
114 lineno = None
115
116 if lineno:
117 linespec = f"#L{lineno}-L{lineno + len(source) - 1}"
118 else:
119 linespec = ""
120
121 fn = os.path.relpath(fn, start=os.path.dirname(autoray.__file__))
122
123 if "+" in autoray.__version__:
124 return (
125 f"https://github.com/jcmgray/autoray/blob/"
126 f"HEAD/autoray/{fn}{linespec}"
127 )
128 else:
129 return (
130 f"https://github.com/jcmgray/autoray/blob/"
131 f"v{autoray.__version__}/autoray/{fn}{linespec}"
132 )