conf.py 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. # -*- coding: utf-8 -*-
  2. #
  3. # Godot Engine documentation build configuration file
  4. import sphinx_rtd_theme
  5. import sys
  6. import os
  7. # -- General configuration ------------------------------------------------
  8. needs_sphinx = "1.3"
  9. # Sphinx extension module names and templates location
  10. sys.path.append(os.path.abspath("_extensions"))
  11. extensions = [
  12. "sphinx_tabs.tabs",
  13. "sphinx.ext.imgmath",
  14. ]
  15. # Warning when the Sphinx Tabs extension is used with unknown
  16. # builders (like the dummy builder) - as it doesn't cause errors,
  17. # we can ignore this so we still can treat other warnings as errors.
  18. sphinx_tabs_nowarn = True
  19. if not os.getenv("SPHINX_NO_GDSCRIPT"):
  20. extensions.append("gdscript")
  21. if not os.getenv("SPHINX_NO_SEARCH"):
  22. extensions.append("sphinx_search.extension")
  23. if not os.getenv("SPHINX_NO_DESCRIPTIONS"):
  24. extensions.append("godot_descriptions")
  25. templates_path = ["_templates"]
  26. # You can specify multiple suffix as a list of string: ['.rst', '.md']
  27. source_suffix = ".rst"
  28. source_encoding = "utf-8-sig"
  29. # The master toctree document
  30. master_doc = "index"
  31. # General information about the project
  32. project = "Godot Engine"
  33. copyright = (
  34. "2014-2020, Juan Linietsky, Ariel Manzur and the Godot community (CC-BY 3.0)"
  35. )
  36. author = "Juan Linietsky, Ariel Manzur and the Godot community"
  37. # Version info for the project, acts as replacement for |version| and |release|
  38. # The short X.Y version
  39. version = os.getenv("READTHEDOCS_VERSION", "latest")
  40. # The full version, including alpha/beta/rc tags
  41. release = version
  42. # Parse Sphinx tags passed from RTD via environment
  43. env_tags = os.getenv("SPHINX_TAGS")
  44. if env_tags is not None:
  45. for tag in env_tags.split(","):
  46. print("Adding Sphinx tag: %s" % tag.strip())
  47. tags.add(tag.strip()) # noqa: F821
  48. # Language / i18n
  49. supported_languages = {
  50. "en": "Godot Engine (%s) documentation in English",
  51. "de": "Godot Engine (%s) Dokumentation auf Deutsch",
  52. "es": "Documentación de Godot Engine (%s) en español",
  53. "fr": "Documentation de Godot Engine (%s) en français",
  54. "fi": "Godot Engine (%s) dokumentaatio suomeksi",
  55. "it": "Godot Engine (%s) documentazione in italiano",
  56. "ja": "Godot Engine (%s)の日本語のドキュメント",
  57. "ko": "Godot Engine (%s) 문서 (한국어)",
  58. "pl": "Dokumentacja Godot Engine (%s) w języku polskim",
  59. "pt_BR": "Documentação da Godot Engine (%s) em Português Brasileiro",
  60. "ru": "Документация Godot Engine (%s) на русском языке",
  61. "uk": "Документація до Godot Engine (%s) українською мовою",
  62. "zh_CN": "Godot Engine (%s) 简体中文文档",
  63. }
  64. language = os.getenv("READTHEDOCS_LANGUAGE", "en")
  65. if not language in supported_languages.keys():
  66. print("Unknown language: " + language)
  67. print("Supported languages: " + ", ".join(supported_languages.keys()))
  68. print(
  69. "The configured language is either wrong, or it should be added to supported_languages in conf.py. Falling back to 'en'."
  70. )
  71. language = "en"
  72. is_i18n = tags.has("i18n") # noqa: F821
  73. exclude_patterns = ["_build"]
  74. # fmt: off
  75. # These imports should *not* be moved to the start of the file,
  76. # they depend on the sys.path.append call registering "_extensions".
  77. # GDScript syntax highlighting
  78. from gdscript import GDScriptLexer
  79. from sphinx.highlighting import lexers
  80. lexers["gdscript"] = GDScriptLexer()
  81. # fmt: on
  82. # Pygments (syntax highlighting) style to use
  83. pygments_style = "sphinx"
  84. highlight_language = "gdscript"
  85. # -- Options for HTML output ----------------------------------------------
  86. # on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org
  87. on_rtd = os.environ.get("READTHEDOCS", None) == "True"
  88. html_theme = "sphinx_rtd_theme"
  89. html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
  90. if on_rtd:
  91. using_rtd_theme = True
  92. # Theme options
  93. html_theme_options = {
  94. # if we have a html_logo below, this shows /only/ the logo with no title text
  95. "logo_only": True,
  96. # Collapse navigation (False makes it tree-like)
  97. "collapse_navigation": False,
  98. }
  99. html_title = supported_languages[language] % version
  100. # VCS options: https://docs.readthedocs.io/en/latest/vcs.html#github
  101. html_context = {
  102. "display_github": not is_i18n, # Integrate GitHub
  103. "github_user": "godotengine", # Username
  104. "github_repo": "godot-docs", # Repo name
  105. "github_version": "master", # Version
  106. "conf_py_path": "/", # Path in the checkout to the docs root
  107. "godot_inject_language_links": True,
  108. "godot_docs_supported_languages": list(supported_languages.keys()),
  109. "godot_docs_basepath": "https://docs.godotengine.org/",
  110. "godot_docs_suffix": ".html",
  111. "godot_default_lang": "en",
  112. "godot_canonical_version": "stable",
  113. # Distinguish local development website from production website.
  114. # This prevents people from looking for changes on the production website after making local changes :)
  115. "godot_title_prefix": "" if on_rtd else "(DEV) ",
  116. }
  117. html_logo = "img/docs_logo.png"
  118. # These folders are copied to the documentation's HTML output
  119. html_static_path = ["_static"]
  120. html_extra_path = ["robots.txt"]
  121. # These paths are either relative to html_static_path
  122. # or fully qualified paths (eg. https://...)
  123. html_css_files = [
  124. "css/custom.css",
  125. ]
  126. html_js_files = [
  127. "js/custom.js",
  128. ]
  129. # Output file base name for HTML help builder
  130. htmlhelp_basename = "GodotEnginedoc"
  131. # -- Options for reStructuredText parser ----------------------------------
  132. # Enable directives that insert the contents of external files
  133. file_insertion_enabled = False
  134. # -- Options for LaTeX output ---------------------------------------------
  135. # Grouping the document tree into LaTeX files. List of tuples
  136. # (source start file, target name, title,
  137. # author, documentclass [howto, manual, or own class]).
  138. latex_documents = [
  139. (
  140. master_doc,
  141. "GodotEngine.tex",
  142. "Godot Engine Documentation",
  143. "Juan Linietsky, Ariel Manzur and the Godot community",
  144. "manual",
  145. ),
  146. ]
  147. # -- Options for linkcheck builder ----------------------------------------
  148. # disable checking urls with about.html#this_part_of_page anchors
  149. linkcheck_anchors = False
  150. linkcheck_timeout = 10
  151. # -- I18n settings --------------------------------------------------------
  152. locale_dirs = ["../sphinx/po/"]
  153. gettext_compact = False
  154. # Couldn't find a way to retrieve variables nor do advanced string
  155. # concat from reST, so had to hardcode this in the "epilog" added to
  156. # all pages. This is used in index.rst to display the Weblate badge.
  157. # On English pages, the badge points to the language-neutral engage page.
  158. rst_epilog = """
  159. .. |weblate_widget| image:: https://hosted.weblate.org/widgets/godot-engine/{image_locale}/godot-docs/287x66-white.png
  160. :alt: Translation status
  161. :target: https://hosted.weblate.org/engage/godot-engine{target_locale}/?utm_source=widget
  162. :width: 287
  163. :height: 66
  164. """.format(
  165. image_locale="-" if language == "en" else language,
  166. target_locale="" if language == "en" else "/" + language,
  167. )