File: conf.py

package info (click to toggle)
python-autoray 0.7.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,708 kB
  • sloc: python: 5,490; makefile: 20
file content (128 lines) | stat: -rw-r--r-- 3,564 bytes parent folder | download | duplicates (2)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import os
import sys
sys.path.append(os.path.abspath("./_pygments"))

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'autoray'
copyright = '2019-2023, Johnnie Gray'
author = 'Johnnie Gray'

try:
    sys.path.append(os.path.abspath("../"))
    from autoray import __version__
    release = __version__
except ImportError:
    try:
        from importlib.metadata import version as _version
        release = _version('autoray')
    except ImportError:
        release = '0.0.0+unknown'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
    'sphinx.ext.intersphinx',
    'sphinx.ext.extlinks',
    'sphinx.ext.napoleon',
    'sphinx.ext.linkcode',
    'sphinx_copybutton',
    'autoapi.extension',
]

# sphinx-autoapi
autoapi_dirs = ['../autoray']

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '**.ipynb_checkpoints']

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'furo'

html_theme_options = {
    "sidebar_hide_name": True,
    "light_css_variables": {
    #     "color-brand-primary": "hsl(72, 75%, 40%)",
    #     "color-brand-content": "hsl(238, 50%, 60%)",
        "font-stack": "Atkinson Hyperlegible, sans-serif",
        "font-stack--monospace": "Spline Sans Mono, monospace",
        "font-stack--headings": "Spline Sans Mono, monospace",
    },
    # "dark_css_variables": {
    #     "color-brand-primary": "hsl(72, 75%, 60%)",
    #     "color-brand-content": "hsl(238, 75%, 70%)",
    # },
    "light_logo": "autoray-header.png",
    "dark_logo": "autoray-header.png",
}

html_css_files = ["my-styles.css"]
html_static_path = ['_static']
html_favicon = "_static/autoray.ico"

pygments_style = '_pygments_light.MarianaLight'
pygments_dark_style = "_pygments_dark.MarianaDark"


def linkcode_resolve(domain, info):
    """
    Determine the URL corresponding to Python object
    """
    import autoray
    import inspect

    if domain != "py":
        return None

    modname = info["module"]
    fullname = info["fullname"]

    submod = sys.modules.get(modname)
    if submod is None:
        return None

    obj = submod
    for part in fullname.split("."):
        try:
            obj = getattr(obj, part)
        except AttributeError:
            return None

    try:
        fn = inspect.getsourcefile(inspect.unwrap(obj))
    except TypeError:
        fn = None
    if not fn:
        return None

    try:
        source, lineno = inspect.getsourcelines(obj)
    except OSError:
        lineno = None

    if lineno:
        linespec = f"#L{lineno}-L{lineno + len(source) - 1}"
    else:
        linespec = ""

    fn = os.path.relpath(fn, start=os.path.dirname(autoray.__file__))

    if "+" in autoray.__version__:
        return (
            f"https://github.com/jcmgray/autoray/blob/"
            f"HEAD/autoray/{fn}{linespec}"
        )
    else:
        return (
            f"https://github.com/jcmgray/autoray/blob/"
            f"v{autoray.__version__}/autoray/{fn}{linespec}"
        )