conf.py 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. #
  2. # Wagtail documentation build configuration file, created by
  3. # sphinx-quickstart on Tue Jan 14 17:38:55 2014.
  4. #
  5. # This file is execfile()d with the current directory set to its
  6. # containing dir.
  7. #
  8. # Note that not all possible configuration values are present in this
  9. # autogenerated file.
  10. #
  11. # All configuration values have a default; values that are commented out
  12. # serve to show the default.
  13. import os
  14. import sys
  15. from datetime import datetime
  16. import django
  17. import sphinx_wagtail_theme
  18. from sphinx.builders.html import StandaloneHTMLBuilder
  19. from wagtail import VERSION, __version__
  20. # use png images as fallback, required to build pdf
  21. StandaloneHTMLBuilder.supported_image_types = ["image/gif", "image/png"]
  22. # on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org
  23. on_rtd = os.environ.get("READTHEDOCS", None) == "True"
  24. html_theme = "sphinx_wagtail_theme"
  25. html_theme_path = [sphinx_wagtail_theme.get_html_theme_path()]
  26. html_theme_options = {
  27. "project_name": "Wagtail Documentation",
  28. "github_url": "https://github.com/wagtail/wagtail/blob/main/docs/",
  29. }
  30. # If extensions (or modules to document with autodoc) are in another directory,
  31. # add these directories to sys.path here. If the directory is relative to the
  32. # documentation root, use os.path.abspath to make it absolute, like shown here.
  33. sys.path.insert(0, os.path.abspath(".."))
  34. # Autodoc may need to import some models modules which require django settings
  35. # be configured
  36. os.environ["DJANGO_SETTINGS_MODULE"] = "wagtail.test.settings"
  37. django.setup()
  38. # Use SQLite3 database engine so it doesn't attempt to use psycopg2 on RTD
  39. os.environ["DATABASE_ENGINE"] = "django.db.backends.sqlite3"
  40. # -- General configuration ------------------------------------------------
  41. # If your documentation needs a minimal Sphinx version, state it here.
  42. # needs_sphinx = '1.0'
  43. # Add any Sphinx extension module names here, as strings. They can be
  44. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
  45. # ones.
  46. extensions = [
  47. "sphinx.ext.autodoc",
  48. "sphinx.ext.intersphinx",
  49. "sphinx_copybutton",
  50. "myst_parser",
  51. "sphinx_wagtail_theme",
  52. ]
  53. autodoc_type_aliases = {
  54. "File": "django.core.files.File",
  55. }
  56. # Silence warnings that are not due to missing references:
  57. nitpick_ignore = [
  58. # Sphinx currently cannot resolve type hint names, warns "target not found":
  59. ("py:class", "wagtail.images.models.Filter"),
  60. ("py:class", "wagtail.url_routing.RouteResult"),
  61. ("py:class", "wagtail.blocks.base.Block"),
  62. ("py:class", "wagtail.blocks.field_block.BaseChoiceBlock"),
  63. ("py:class", "wagtail.blocks.field_block.ChooserBlock"),
  64. # Warnings due factors other than type hints:
  65. ("py:class", "wagtail.documents.views.chooser.BaseDocumentChooserBlock"),
  66. ("py:class", "wagtail.blocks.struct_block.BaseStructBlock"),
  67. ("py:class", "wagtail.blocks.stream_block.BaseStreamBlock"),
  68. ]
  69. # We have .txt and .ico files in the static directory that trigger unknown mime
  70. # type warnings when building the epub and are ignored by the builder. For the
  71. # table markup files, they are already rendered in the output. Other files are
  72. # not relevant to the epub. Suppress the warnings so we don't have to explicitly
  73. # list the files in `epub_exclude_files`.
  74. suppress_warnings = [
  75. "epub.unknown_project_files",
  76. ]
  77. if not on_rtd:
  78. extensions.append("sphinxcontrib.spelling")
  79. # Add any paths that contain templates here, relative to this directory.
  80. templates_path = ["_templates"]
  81. # The suffix of source filenames.
  82. source_suffix = ".rst"
  83. # The encoding of source files.
  84. # source_encoding = 'utf-8-sig'
  85. # The master toctree document.
  86. master_doc = "index"
  87. # General information about the project.
  88. project = "Wagtail Documentation"
  89. copyright = f"{datetime.now().year}, Wagtail core team and contributors. BSD license"
  90. # The version info for the project you're documenting, acts as replacement for
  91. # |version| and |release|, also used in various other places throughout the
  92. # built documents.
  93. # The short X.Y version.
  94. version = f"{VERSION[0]}.{VERSION[1]}"
  95. # The full version, including alpha/beta/rc tags.
  96. release = __version__
  97. # The language for content autogenerated by Sphinx. Refer to documentation
  98. # for a list of supported languages.
  99. # language = None
  100. # There are two options for replacing |today|: either, you set today to some
  101. # non-false value, then it is used:
  102. # today = ''
  103. # Else, today_fmt is used as the format for a strftime call.
  104. # today_fmt = '%B %d, %Y'
  105. # List of patterns, relative to source directory, that match files and
  106. # directories to ignore when looking for source files.
  107. exclude_patterns = ["_build", "README.md"]
  108. # The reST default role (used for this markup: `text`) to use for all
  109. # documents.
  110. # default_role = None
  111. # If true, '()' will be appended to :func: etc. cross-reference text.
  112. # add_function_parentheses = True
  113. # If true, the current module name will be prepended to all description
  114. # unit titles (such as .. function::).
  115. # add_module_names = True
  116. # If true, sectionauthor and moduleauthor directives will be shown in the
  117. # output. They are ignored by default.
  118. # show_authors = False
  119. # The name of the Pygments (syntax highlighting) style to use.
  120. pygments_style = None
  121. # A list of ignored prefixes for module index sorting.
  122. # modindex_common_prefix = []
  123. # If true, keep warnings as "system message" paragraphs in the built documents.
  124. # keep_warnings = False
  125. # splhinxcontrib.spelling settings
  126. spelling_lang = "en_GB"
  127. spelling_word_list_filename = "spelling_wordlist.txt"
  128. # sphinx.ext.intersphinx settings
  129. intersphinx_mapping = {
  130. "django": (
  131. "https://docs.djangoproject.com/en/stable/",
  132. "https://docs.djangoproject.com/en/stable/_objects/",
  133. ),
  134. "python": (
  135. "https://docs.python.org/3/",
  136. None,
  137. ),
  138. "treebeard": (
  139. "https://django-treebeard.readthedocs.io/en/stable/",
  140. None,
  141. ),
  142. "sphinx": (
  143. "https://www.sphinx-doc.org/en/master/",
  144. None,
  145. ),
  146. "myst": (
  147. "https://myst-parser.readthedocs.io/en/stable/",
  148. None,
  149. ),
  150. }
  151. myst_url_schemes = {
  152. "https": None,
  153. "http": None,
  154. "mailto": None,
  155. }
  156. # -- Options for HTML output ----------------------------------------------
  157. # Theme options are theme-specific and customise the look and feel of a theme
  158. # further. For a list of options available for each theme, see the
  159. # documentation.
  160. # html_theme_options = {}
  161. # The name for this set of Sphinx documents. If None, it defaults to
  162. # "<project> v<release> documentation".
  163. # html_title = None
  164. # A shorter title for the navigation bar. Default is the same as html_title.
  165. # html_short_title = None
  166. # The name of an image file (relative to this directory) to place at the top
  167. # of the sidebar.
  168. # html_logo = 'logo.png'
  169. # The name of an image file (within the static path) to use as favicon of the
  170. # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
  171. # pixels large.
  172. html_favicon = "favicon.ico"
  173. # Add any paths that contain custom static files (such as style sheets) here,
  174. # relative to this directory. They are copied after the builtin static files,
  175. # so a file named "default.css" will overwrite the builtin "default.css".
  176. html_static_path = ["_static"]
  177. # Add any extra paths that contain custom files (such as robots.txt or
  178. # .htaccess) here, relative to this directory. These files are copied
  179. # directly to the root of the documentation.
  180. html_extra_path = ["public"]
  181. # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
  182. # using the given strftime format.
  183. # html_last_updated_fmt = '%b %d, %Y'
  184. # If true, SmartyPants will be used to convert quotes and dashes to
  185. # typographically correct entities.
  186. # html_use_smartypants = True
  187. # Custom sidebar templates, maps document names to template names.
  188. # html_sidebars = {}
  189. # Additional templates that should be rendered to pages, maps page names to
  190. # template names.
  191. # html_additional_pages = {}
  192. # If false, no module index is generated.
  193. # html_domain_indices = True
  194. # If false, no index is generated.
  195. # Since we are implementing search with Algolia DocSearch, we do not need Sphinx to
  196. # generate its own index. It might not hurt to keep the Sphinx index, but it
  197. # could potentially speed up the build process.
  198. html_use_index = False
  199. # If true, the index is split into individual pages for each letter.
  200. # html_split_index = False
  201. # If true, links to the reST sources are added to the pages.
  202. # html_show_sourcelink = True
  203. # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
  204. # html_show_sphinx = True
  205. # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
  206. # html_show_copyright = True
  207. # If true, an OpenSearch description file will be output, and all pages will
  208. # contain a <link> tag referring to it. The value of this option must be the
  209. # base URL from which the finished HTML is served.
  210. # html_use_opensearch = ''
  211. # This is the file name suffix for HTML files (for example ".xhtml").
  212. # html_file_suffix = None
  213. # Output file base name for HTML help builder.
  214. htmlhelp_basename = "Wagtaildoc"
  215. # -- Options for LaTeX output ---------------------------------------------
  216. # Xelatex engine is required to include unicode characters in the doc
  217. latex_engine = "xelatex"
  218. latex_elements = {
  219. # The paper size ('letterpaper' or 'a4paper').
  220. # 'papersize': 'letterpaper',
  221. # The font size ('10pt', '11pt' or '12pt').
  222. # 'pointsize': '10pt',
  223. # Additional stuff for the LaTeX preamble.
  224. # 'preamble': '',
  225. }
  226. # Grouping the document tree into LaTeX files. List of tuples
  227. # (source start file, target name, title,
  228. # author, documentclass [howto, manual, or own class]).
  229. latex_documents = [
  230. (
  231. "index",
  232. "Wagtail.tex",
  233. "Wagtail Documentation",
  234. "Wagtail core team and contributors",
  235. "manual",
  236. ),
  237. ]
  238. # The name of an image file (relative to this directory) to place at the top of
  239. # the title page.
  240. # latex_logo = None
  241. # For "manual" documents, if this is true, then toplevel headings are parts,
  242. # not chapters.
  243. # latex_use_parts = False
  244. # If true, show page references after internal links.
  245. # latex_show_pagerefs = False
  246. # If true, show URL addresses after external links.
  247. # latex_show_urls = False
  248. # Documents to append as an appendix to all manuals.
  249. # latex_appendices = []
  250. # If false, no module index is generated.
  251. # latex_domain_indices = True
  252. # -- Options for manual page output ---------------------------------------
  253. # One entry per manual page. List of tuples
  254. # (source start file, name, description, authors, manual section).
  255. man_pages = [
  256. (
  257. "index",
  258. "wagtail",
  259. "Wagtail Documentation",
  260. ["Wagtail core team and contributors"],
  261. 1,
  262. )
  263. ]
  264. # If true, show URL addresses after external links.
  265. # man_show_urls = False
  266. # -- Options for Texinfo output -------------------------------------------
  267. # Grouping the document tree into Texinfo files. List of tuples
  268. # (source start file, target name, title, author,
  269. # dir menu entry, description, category)
  270. texinfo_documents = [
  271. (
  272. "index",
  273. "Wagtail",
  274. "Wagtail Documentation",
  275. "Wagtail core team and contributors",
  276. "Wagtail",
  277. "An open source content management system built on Django.",
  278. "Miscellaneous",
  279. ),
  280. ]
  281. # Documents to append as an appendix to all manuals.
  282. # texinfo_appendices = []
  283. # If false, no module index is generated.
  284. # texinfo_domain_indices = True
  285. # How to display URL addresses: 'footnote', 'no', or 'inline'.
  286. # texinfo_show_urls = 'footnote'
  287. # If true, do not generate a @detailmenu in the "Top" node's menu.
  288. # texinfo_no_detailmenu = False
  289. # -- Options for Epub output ---------------------------------------------------
  290. # Bibliographic Dublin Core info.
  291. epub_title = project
  292. epub_author = "Wagtail core team and contributors"
  293. epub_publisher = "Wagtail"
  294. epub_copyright = copyright
  295. def setup(app):
  296. app.add_js_file("js/banner.js")
  297. # Django-specific roles, from
  298. # https://github.com/django/django/blob/main/docs/_ext/djangodocs.py:
  299. app.add_crossref_type(
  300. directivename="setting",
  301. rolename="setting",
  302. indextemplate="pair: %s; setting",
  303. )
  304. app.add_crossref_type(
  305. directivename="templatetag",
  306. rolename="ttag",
  307. indextemplate="pair: %s; template tag",
  308. )
  309. app.add_crossref_type(
  310. directivename="templatefilter",
  311. rolename="tfilter",
  312. indextemplate="pair: %s; template filter",
  313. )
  314. app.add_crossref_type(
  315. directivename="fieldlookup",
  316. rolename="lookup",
  317. indextemplate="pair: %s; field lookup type",
  318. )
  319. # Stop Sphinx from looking in the wrong place for HttpRequest when resolving
  320. # type annotations - see https://github.com/wagtail/wagtail/pull/12777
  321. from django.http import HttpRequest
  322. HttpRequest.__module__ = "django.http"