conf.py 6.3 KB

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