conf.py 6.9 KB

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