conf.py 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. # -*- coding: utf-8 -*-
  2. #
  3. # Godot Engine documentation build configuration file
  4. import sys
  5. import os
  6. # -- General configuration ------------------------------------------------
  7. needs_sphinx = "1.3"
  8. # Sphinx extension module names and templates location
  9. sys.path.append(os.path.abspath("_extensions"))
  10. extensions = [
  11. "gdscript",
  12. "godot_descriptions",
  13. "sphinx_tabs.tabs",
  14. "sphinx.ext.imgmath",
  15. "notfound.extension",
  16. ]
  17. # Custom 4O4 page HTML template.
  18. # https://github.com/readthedocs/sphinx-notfound-page
  19. notfound_context = {
  20. "title": "Page not found",
  21. "body": """
  22. <h1>Page not found</h1>
  23. <p>
  24. Sorry, we couldn't find that page. It may have been renamed or removed
  25. in the version of the documentation you're currently browsing.
  26. </p>
  27. <p>
  28. If you're currently browsing the
  29. <em>stable</em> version of the documentation, try browsing the
  30. <a href="/en/latest/"><em>latest</em> version of the documentation</a>.
  31. </p>
  32. <p>
  33. Alternatively, use the
  34. <a href="#" onclick="$('#rtd-search-form [name=\\'q\\']').focus()">Search docs</a>
  35. box on the left or <a href="/">go to the homepage</a>.
  36. </p>
  37. """,
  38. }
  39. # on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org
  40. on_rtd = os.environ.get("READTHEDOCS", None) == "True"
  41. # Don't add `/en/latest` prefix during local development.
  42. # This makes it easier to test the custom 404 page by loading `/404.html`
  43. # on a local web server.
  44. if not on_rtd:
  45. notfound_urls_prefix = ''
  46. templates_path = ["_templates"]
  47. # You can specify multiple suffix as a list of string: ['.rst', '.md']
  48. source_suffix = ".rst"
  49. source_encoding = "utf-8-sig"
  50. # The master toctree document
  51. master_doc = "index"
  52. # General information about the project
  53. project = "Godot Engine"
  54. copyright = (
  55. "2014-2019, Juan Linietsky, Ariel Manzur and the Godot community (CC-BY 3.0)"
  56. )
  57. author = "Juan Linietsky, Ariel Manzur and the Godot community"
  58. # Version info for the project, acts as replacement for |version| and |release|
  59. # The short X.Y version
  60. version = os.getenv("READTHEDOCS_VERSION", "3.1")
  61. # The full version, including alpha/beta/rc tags
  62. release = version
  63. # Parse Sphinx tags passed from RTD via environment
  64. env_tags = os.getenv("SPHINX_TAGS")
  65. if env_tags != None:
  66. for tag in env_tags.split(","):
  67. print("Adding Sphinx tag: %s" % tag.strip())
  68. tags.add(tag.strip())
  69. # Language / i18n
  70. supported_languages = {
  71. "en": "Godot Engine (%s) documentation in English",
  72. "de": "Godot Engine (%s) Dokumentation auf Deutsch",
  73. "es": "Documentación de Godot Engine (%s) en español",
  74. "fr": "Documentation de Godot Engine (%s) en français",
  75. "fi": "Godot Engine (%s) dokumentaatio suomeksi",
  76. "it": "Godot Engine (%s) documentazione in italiano",
  77. "ja": "Godot Engine (%s)の日本語のドキュメント",
  78. "ko": "Godot Engine (%s) 문서 (한국어)",
  79. "pl": "Dokumentacja Godot Engine (%s) w języku polskim",
  80. "pt_BR": "Documentação da Godot Engine (%s) em Português Brasileiro",
  81. "ru": "Документация Godot Engine (%s) на русском языке",
  82. "uk": "Документація до Godot Engine (%s) українською мовою",
  83. "zh_CN": "Godot Engine (%s) 简体中文文档",
  84. }
  85. language = os.getenv("READTHEDOCS_LANGUAGE", "en")
  86. if not language in supported_languages.keys():
  87. print("Unknown language: " + language)
  88. print("Supported languages: " + ", ".join(supported_languages.keys()))
  89. print(
  90. "The configured language is either wrong, or it should be added to supported_languages in conf.py. Falling back to 'en'."
  91. )
  92. language = "en"
  93. is_i18n = tags.has("i18n") # noqa: F821
  94. exclude_patterns = ["_build"]
  95. # fmt: off
  96. # These imports should *not* be moved to the start of the file,
  97. # they depend on the sys.path.append call registering "extensions".
  98. # GDScript syntax highlighting
  99. from gdscript import GDScriptLexer
  100. from sphinx.highlighting import lexers
  101. lexers["gdscript"] = GDScriptLexer()
  102. # fmt: on
  103. # Pygments (syntax highlighting) style to use
  104. pygments_style = "sphinx"
  105. highlight_language = "gdscript"
  106. # -- Options for HTML output ----------------------------------------------
  107. import sphinx_rtd_theme
  108. html_theme = "sphinx_rtd_theme"
  109. html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
  110. if on_rtd:
  111. using_rtd_theme = True
  112. # Theme options
  113. html_theme_options = {
  114. # 'typekit_id': 'hiw1hhg',
  115. # 'analytics_id': '',
  116. # 'sticky_navigation': True # Set to False to disable the sticky nav while scrolling.
  117. "logo_only": True, # if we have a html_logo below, this shows /only/ the logo with no title text
  118. "collapse_navigation": False, # Collapse navigation (False makes it tree-like)
  119. # 'display_version': True, # Display the docs version
  120. # 'navigation_depth': 4, # Depth of the headers shown in the navigation bar
  121. }
  122. html_title = supported_languages[language] % version
  123. # VCS options: https://docs.readthedocs.io/en/latest/vcs.html#github
  124. html_context = {
  125. "display_github": not is_i18n, # Integrate GitHub
  126. "github_user": "godotengine", # Username
  127. "github_repo": "godot-docs", # Repo name
  128. "github_version": "master", # Version
  129. "conf_py_path": "/", # Path in the checkout to the docs root
  130. "godot_inject_language_links": True,
  131. "godot_docs_supported_languages": list(supported_languages.keys()),
  132. "godot_docs_basepath": "https://docs.godotengine.org/",
  133. "godot_docs_suffix": ".html",
  134. "godot_default_lang": "en",
  135. "godot_canonical_version": "stable",
  136. # Distinguish local development website from production website.
  137. # This prevents people from looking for changes on the production website after making local changes :)
  138. "godot_title_prefix": "" if on_rtd else "(DEV) ",
  139. }
  140. html_logo = "img/docs_logo.png"
  141. # These folders are copied to the documentation's HTML output
  142. html_static_path = ["_static"]
  143. html_extra_path = ["robots.txt"]
  144. # These paths are either relative to html_static_path
  145. # or fully qualified paths (eg. https://...)
  146. html_css_files = [
  147. "css/custom.css",
  148. ]
  149. html_js_files = [
  150. "js/custom.js",
  151. ]
  152. # Output file base name for HTML help builder
  153. htmlhelp_basename = "GodotEnginedoc"
  154. # -- Options for reStructuredText parser ----------------------------------
  155. # Enable directives that insert the contents of external files
  156. file_insertion_enabled = False
  157. # -- Options for LaTeX output ---------------------------------------------
  158. # Grouping the document tree into LaTeX files. List of tuples
  159. # (source start file, target name, title,
  160. # author, documentclass [howto, manual, or own class]).
  161. latex_documents = [
  162. (
  163. master_doc,
  164. "GodotEngine.tex",
  165. "Godot Engine Documentation",
  166. "Juan Linietsky, Ariel Manzur and the Godot community",
  167. "manual",
  168. ),
  169. ]
  170. # -- Options for linkcheck builder ----------------------------------------
  171. # disable checking urls with about.html#this_part_of_page anchors
  172. linkcheck_anchors = False
  173. linkcheck_timeout = 10
  174. # -- I18n settings --------------------------------------------------------
  175. locale_dirs = ["../sphinx/po/"]
  176. gettext_compact = False
  177. # Exclude class reference when marked with tag i18n.
  178. if is_i18n:
  179. exclude_patterns = ["classes"]