conf.py 6.5 KB

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