conf   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 184
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 74
dl 0
loc 184
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A ShutupSphinxAutodocTypehintsFilter.filter() 0 4 2
1
# Configuration file for the Sphinx documentation builder.
2
#
3
# This file only contains a selection of the most common options. For a full
4
# list see the documentation:
5
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6
7
import logging
8
import os
9
import sys
10
import tomllib
11
from datetime import datetime
12
13
from asgardpy.version import __public_version__, __version__  # noqa: E402
14
15
# -- Path setup --------------------------------------------------------------
16
17
# If extensions (or modules to document with autodoc) are in another directory,
18
# add these directories to sys.path here. If the directory is relative to the
19
# documentation root, use os.path.abspath to make it absolute, like shown here.
20
#
21
22
sys.path.insert(0, os.path.abspath("../../"))
23
24
# -- Project information -----------------------------------------------------
25
26
work_dir_path = os.path.join(os.path.dirname(__file__), "../../")
27
28
with open(os.path.join(work_dir_path, "pyproject.toml"), "rb") as f:
29
    project_info = tomllib.load(f)
30
31
project = project_info["project"]["name"]
32
33
# Read the list of author names
34
author = ""
35
for auth in project_info["project"]["authors"]:
36
    author += auth["name"] + ", "
37
author = author[:-2]
38
39
copyright = f"{datetime.today().year}, {author}"
40
41
version = __version__
42
# The full version contains alpha, beta, rc tags
43
release = __public_version__
44
45
46
# -- General configuration ---------------------------------------------------
47
48
# Add any Sphinx extension module names here, as strings. They can be
49
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
50
# ones.
51
extensions = [
52
    "sphinx.ext.autodoc",
53
    "sphinx.ext.autosummary",
54
    "sphinx.ext.napoleon",
55
    "myst_parser",
56
    "sphinx.ext.intersphinx",
57
    "sphinx.ext.extlinks",
58
    "sphinx.ext.mathjax",
59
    "sphinx.ext.viewcode",
60
    "matplotlib.sphinxext.plot_directive",
61
    "IPython.sphinxext.ipython_directive",
62
    "IPython.sphinxext.ipython_console_highlighting",
63
    "sphinx.ext.doctest",
64
    "sphinx_copybutton",
65
    "sphinx_autodoc_typehints",
66
    "sphinx.ext.inheritance_diagram",
67
    "sphinxcontrib.autodoc_pydantic",
68
    "sphinxcontrib.towncrier.ext",
69
    "sphinx_changelog",
70
]
71
72
# Tell myst-parser to assign header anchors for h1-h3.
73
myst_heading_anchors = 3
74
75
suppress_warnings = ["myst.header"]
76
77
# Add any paths that contain templates here, relative to this directory.
78
templates_path = ["_templates"]
79
80
# List of patterns, relative to source directory, that match files and
81
# directories to ignore when looking for source files.
82
# This pattern also affects html_static_path and html_extra_path.
83
exclude_patterns = ["_build", "changes"]
84
85
source_suffix = [".rst", ".md"]
86
87
intersphinx_mapping = {
88
    "python": ("https://docs.python.org/3.11/", None),
89
    "gammapy": ("https://docs.gammapy.org/1.3/", None),
90
    "astropy": ("https://docs.astropy.org/en/latest/", None),
91
    # Uncomment these if you use them in your codebase:
92
    #  "torch": ("https://pytorch.org/docs/stable", None),
93
    #  "datasets": ("https://huggingface.co/docs/datasets/master/en", None),
94
    #  "transformers": ("https://huggingface.co/docs/transformers/master/en", None),
95
}
96
97
# By default, sort documented members by type within classes and modules.
98
autodoc_member_order = "groupwise"
99
100
autodoc_pydantic_model_show_json = False
101
autodoc_pydantic_model_show_config = False
102
autodoc_pydantic_model_show_config_member = False
103
autodoc_pydantic_model_show_config_summary = False
104
autodoc_pydantic_model_show_field_summary = True
105
106
# Options: draft/sphinx-version/sphinx-release
107
towncrier_draft_autoversion_mode = "draft"
108
towncrier_draft_include_empty = True
109
towncrier_draft_working_directory = work_dir_path
110
# Not yet supported:
111
# towncrier_draft_config_path = 'pyproject.toml'  # relative to cwd
112
113
# Include default values when documenting parameter types.
114
typehints_defaults = "comma"
115
116
117
# Define the json_url for our version switcher.
118
# json_url = "https://asgardpy.readthedocs.io/en/latest/_static/switcher.json"
119
120
# Define the version we use for matching in the version switcher.,
121
# version_match = os.getenv("READTHEDOCS_VERSION")
122
# If READTHEDOCS_VERSION doesn't exist, we're not on RTD
123
# If it is an integer, we're in a PR build and the version isn't correct.
124
# if not version_match or version_match.isdigit():
125
# For local development, infer the version to match from the package.
126
# if "dev" in release or "rc" in release:
127
#     version_match = "latest"
128
# else:
129
#     version_match = release
130
131
# We want to keep the relative reference when on a pull request or locally
132
# json_url = "_static/switcher.json"
133
134
135
# -- Options for HTML output -------------------------------------------------
136
137
# The theme to use for HTML and HTML Help pages.  See the documentation for
138
# a list of builtin themes.
139
#
140
html_theme = "furo"
141
142
html_title = f"{project} v{__version__}"
143
144
# Add any paths that contain custom static files (such as style sheets) here,
145
# relative to this directory. They are copied after the builtin static files,
146
# so a file named "default.css" will overwrite the builtin "default.css".
147
html_static_path = ["_static"]
148
149
html_css_files = ["css/custom.css"]
150
151
html_favicon = "_static/favicon.ico"
152
153
html_theme_options = {
154
    "footer_icons": [
155
        {
156
            "name": "GitHub",
157
            "url": "https://github.com/chaimain/asgardpy",
158
            "html": """
159
                <svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
160
                    <path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
161
                </svg>
162
            """,  # noqa: E501
163
            "class": "",
164
        },
165
    ],
166
    # "navbar_start": ["navbar-logo", "version-switcher"],
167
    # "switcher": {
168
    #     "version_match": version_match,
169
    #     "json_url": json_url,
170
    # },
171
}
172
173
# -- Hack to get rid of stupid warnings from sphinx_autodoc_typehints --------
174
175
176
class ShutupSphinxAutodocTypehintsFilter(logging.Filter):
177
    def filter(self, record: logging.LogRecord) -> bool:
178
        if "Cannot resolve forward reference" in record.msg:
179
            return False
180
        return True
181
182
183
logging.getLogger("sphinx.sphinx_autodoc_typehints").addFilter(ShutupSphinxAutodocTypehintsFilter())
184