Debian Codegraph @

docs/conf.py

raw ◀ ▶
1 Debian patch touch this file
1 #
2 # django-polymorphic documentation build configuration file, created by
3 # sphinx-quickstart on Sun May 19 12:20:47 2013.
4 #
5 # This file is execfile()d with the current directory set to its containing dir.
6 #
7 # Note that not all possible configuration values are present in this
8 # autogenerated file.
9 #
10 # All configuration values have a default; values that are commented out
11 # serve to show the default.
12
13 import os
14 import shutil
15 import sys
16 from pathlib import Path
17
18 import django
19
20 # If extensions (or modules to document with autodoc) are in another directory,
21 # add these directories to sys.path here. If the directory is relative to the
22 # documentation root, use os.path.abspath to make it absolute, like shown here.
23 sys.path.insert(0, os.path.abspath("_ext"))
24 sys.path.insert(0, os.path.abspath(".."))
25 os.environ["DJANGO_SETTINGS_MODULE"] = "polymorphic.tests.settings"
26
27 django.setup()
28
29 import polymorphic # noqa: E402
•30 import guardian # noqa: E402
31
32 # -- General configuration -----------------------------------------------------
33
34 # If your documentation needs a minimal Sphinx version, state it here.
35 # needs_sphinx = '1.0'
36
37 # Add any Sphinx extension module names here, as strings. They can be extensions
38 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
39 extensions = [
40 "sphinx.ext.autodoc",
41 "sphinx.ext.graphviz",
42 "sphinx.ext.intersphinx",
43 "sphinx.ext.todo",
44 "sphinxcontrib_django",
45 ]
46
47 # Add any paths that contain templates here, relative to this directory.
48 templates_path = ["_templates"]
49
50 # The suffix of source filenames.
51 source_suffix = ".rst"
52
53 # The encoding of source files.
54 # source_encoding = 'utf-8-sig'
55
56 # The master toctree document.
57 master_doc = "index"
58
59 # -- Project information -----------------------------------------------------
60 project = polymorphic.__title__
61 copyright = polymorphic.__copyright__
62 author = polymorphic.__author__
63 release = polymorphic.__version__
64 version = ".".join(polymorphic.__version__.split(".")[:2])
65
66
67 # The language for content autogenerated by Sphinx. Refer to documentation
68 # for a list of supported languages.
69 # language = None
70
71 # There are two options for replacing |today|: either, you set today to some
72 # non-false value, then it is used:
73 # today = ''
74 # Else, today_fmt is used as the format for a strftime call.
75 # today_fmt = '%B %d, %Y'
76
77 # List of patterns, relative to source directory, that match files and
78 # directories to ignore when looking for source files.
79 exclude_patterns = ["_build"]
80
81 # The reST default role (used for this markup: `text`) to use for all documents.
82 # default_role = None
83
84 # If true, '()' will be appended to :func: etc. cross-reference text.
85 # add_function_parentheses = True
86
87 # If true, the current module name will be prepended to all description
88 # unit titles (such as .. function::).
89 # add_module_names = True
90
91 # If true, sectionauthor and moduleauthor directives will be shown in the
92 # output. They are ignored by default.
93 # show_authors = False
94
95 # The name of the Pygments (syntax highlighting) style to use.
96 # pygments_style = "sphinx"
97
98 # A list of ignored prefixes for module index sorting.
99 # modindex_common_prefix = []
100
101
102 # -- Options for HTML output ---------------------------------------------------
103
104 # The theme to use for HTML and HTML Help pages. See the documentation for
105 # a list of builtin themes.
106 html_theme = "furo"
107 html_theme_options = {
108 "source_repository": "https://github.com/jazzband/django-polymorphic/",
109 "source_branch": "main",
110 "source_directory": "docs",
111 }
112
113 # Theme options are theme-specific and customize the look and feel of a theme
114 # further. For a list of options available for each theme, see the
115 # documentation.
116 # html_theme_options = {}
117
118 # Add any paths that contain custom themes here, relative to this directory.
119 # html_theme_path = []
120
121 # The name for this set of Sphinx documents. If None, it defaults to
122 # "<project> v<release> documentation".
123 # html_title = None
124
125 # A shorter title for the navigation bar. Default is the same as html_title.
126 # html_short_title = None
127
128 # The name of an image file (relative to this directory) to place at the top
129 # of the sidebar.
130 # html_logo = None
131
132 # The name of an image file (within the static path) to use as favicon of the
133 # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
134 # pixels large.
135 # html_favicon = None
136
137 # Add any paths that contain custom static files (such as style sheets) here,
138 # relative to this directory. They are copied after the builtin static files,
139 # so a file named "default.css" will overwrite the builtin "default.css".
140 html_static_path = ["_static"]
141 html_css_files = [
142 "style.css",
143 ]
144
145 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
146 # using the given strftime format.
147 # html_last_updated_fmt = '%b %d, %Y'
148
149 # If true, SmartyPants will be used to convert quotes and dashes to
150 # typographically correct entities.
151 # html_use_smartypants = True
152
153 # Custom sidebar templates, maps document names to template names.
154 # html_sidebars = {}
155
156 # Additional templates that should be rendered to pages, maps page names to
157 # template names.
158 # html_additional_pages = {}
159
160 # If false, no module index is generated.
161 # html_domain_indices = True
162
163 # If false, no index is generated.
164 # html_use_index = True
165
166 # If true, the index is split into individual pages for each letter.
167 # html_split_index = False
168
169 # If true, links to the reST sources are added to the pages.
170 # html_show_sourcelink = True
171
172 # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
173 # html_show_sphinx = True
174
175 # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
176 # html_show_copyright = True
177
178 # If true, an OpenSearch description file will be output, and all pages will
179 # contain a <link> tag referring to it. The value of this option must be the
180 # base URL from which the finished HTML is served.
181 # html_use_opensearch = ''
182
183 # This is the file name suffix for HTML files (e.g. ".xhtml").
184 # html_file_suffix = None
185
186 # Output file base name for HTML help builder.
187 htmlhelp_basename = "django-polymorphicdoc"
188
189
190 # -- Options for LaTeX output --------------------------------------------------
191
192 latex_engine = "xelatex"
193 latex_elements = {
194 # The paper size ('letterpaper' or 'a4paper').
195 #'papersize': 'letterpaper',
196 # The font size ('10pt', '11pt' or '12pt').
197 #'pointsize': '10pt',
198 # Additional stuff for the LaTeX preamble.
199 #'preamble': '',
200 }
201
202 # Grouping the document tree into LaTeX files. List of tuples
203 # (source start file, target name, title, author, documentclass [howto/manual]).
204 latex_documents = [
205 (
206 "index",
207 "django-polymorphic.tex",
208 "django-polymorphic Documentation",
209 "Bert Constantin, Chris Glass, Diederik van der Boor, Brian Kohan",
210 "manual",
211 )
212 ]
213
214 # The name of an image file (relative to this directory) to place at the top of
215 # the title page.
216 # latex_logo = None
217
218 # For "manual" documents, if this is true, then toplevel headings are parts,
219 # not chapters.
220 # latex_use_parts = False
221
222 # If true, show page references after internal links.
223 # latex_show_pagerefs = False
224
225 # If true, show URL addresses after external links.
226 # latex_show_urls = False
227
228 # Documents to append as an appendix to all manuals.
229 # latex_appendices = []
230
231 # If false, no module index is generated.
232 # latex_domain_indices = True
233
234
235 # -- Options for manual page output --------------------------------------------
236
237 # One entry per manual page. List of tuples
238 # (source start file, name, description, authors, manual section).
239 man_pages = [
240 (
241 "index",
242 "django-polymorphic",
243 "django-polymorphic Documentation",
244 ["Bert Constantin, Chris Glass, Diederik van der Boor", "Brian Kohan"],
245 1,
246 )
247 ]
248
249 # If true, show URL addresses after external links.
250 # man_show_urls = False
251
252
253 # -- Options for Texinfo output ------------------------------------------------
254
255 # Grouping the document tree into Texinfo files. List of tuples
256 # (source start file, target name, title, author,
257 # dir menu entry, description, category)
258 texinfo_documents = [
259 (
260 "index",
261 "django-polymorphic",
262 "django-polymorphic Documentation",
263 "Bert Constantin, Chris Glass, Diederik van der Boor, Brian Kohan",
264 "django-polymorphic",
265 "One line description of project.",
266 "Miscellaneous",
267 )
268 ]
269
270 # Documents to append as an appendix to all manuals.
271 # texinfo_appendices = []
272
273 # If false, no module index is generated.
274 # texinfo_domain_indices = True
275
276 # How to display URL addresses: 'footnote', 'no', or 'inline'.
277 # texinfo_show_urls = 'footnote'
278
279
•280 def check_object_path(key, url, path):
281 if os.path.isfile(path):
282 return {key: (url, path)}
283 return {}
284
285
286 intersphinx_mapping = {
•287 **check_object_path(
288 "django",
289 "https://docs.djangoproject.com/en/{v}".format(
290 v=".".join(map(str, django.VERSION[:2]))
291 ),
292 "/usr/share/doc/python-django-doc/html/objects.inv",
293 ),
294 **check_object_path(
295 "python",
296 f"https://docs.python.org/{sys.version_info.major}.{sys.version_info.minor}/",
297 f"/usr/share/doc/python{sys.version_info.major}.{sys.version_info.minor}/html/objects.inv",
298 ),
299 **check_object_path(
300 "typing-extensions",
301 "https://typing-extensions.readthedocs.io/en/latest/",
302 "/usr/share/doc/python-typing-extensions-doc/html/objects.inv",
303 ),
304 **check_object_path(
305 "django-guardian",
306 "https://django-guardian.readthedocs.io/en/{v}/".format(
307 v=".".join(map(str, guardian.VERSION))
308 ),
309 "/usr/share/doc/python3-django-guardian/html/objects.inv",
310 ),
311 **check_object_path(
312 "django-reversion",
313 "https://django-reversion.readthedocs.io/en/stable",
314 "/usr/share/doc/python-django-reversion-doc/html/objects.inv",
315 ),
316 **check_object_path(
317 "django-extra-views",
318 "https://django-extra-views.readthedocs.io/en/stable",
319 "/usr/share/doc/python-django-extra-views-doc/html/objects.inv",
320 ),
321 **check_object_path(
322 "model-bakery",
323 "https://model-bakery.readthedocs.io/en/stable",
324 "/usr/share/doc/python-model-bakery-doc/objects.inv",
325 ),
326 }
327
328 # autodoc settings
329 autodoc_default_options = {
330 "show-inheritance": True,
331 # Add other autodoc options here if desired, e.g.:
332 # 'members': True,
333 # 'inherited-members': True,
334 }
335 # In your Sphinx conf.py
336 autodoc_typehints = "description"
337 autodoc_typehints_format = "short"
338 autodoc_class_signature = "separated"
339 autodoc_member_order = "groupwise" # "bysource"
340
341 # sphinxcontrib-django / Sphinx 9+ autodoc compat
342 autodoc_use_legacy_class_based = True
343
344
345 def pypi_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
346 from docutils import nodes
347
348 url = f"https://pypi.org/project/{text}/"
349 node = nodes.reference(rawtext, text, refuri=url, **options)
350 return [node], []
351
352
353 def setup(app):
354 from docutils.parsers.rst import roles
355
356 # https://sphinxcontrib-typer.readthedocs.io/en/latest/howto.html#build-to-multiple-formats
357 if Path(app.doctreedir).exists():
358 shutil.rmtree(app.doctreedir)
359 app.add_crossref_type(directivename="django-admin", rolename="django-admin")
360 roles.register_local_role("pypi", pypi_role)
361 return app