2
0

conf.py 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 = ['en', 'de', 'es', 'fr', 'fi', 'it', 'ja', 'ko', 'pl', 'pt-br', 'ru', 'uk', 'zh-cn']
  42. language = os.getenv("READTHEDOCS_LANGUAGE", "en")
  43. if not language in supported_languages:
  44. print("Unknown language: " + language)
  45. print("Supported languages: " + ", ".join(supported_languages))
  46. print("This is an error or needs to be added to supported_languages in conf.py")
  47. is_i18n = tags.has("i18n") # noqa: F821
  48. exclude_patterns = ["_build"]
  49. # fmt: off
  50. # These imports should *not* be moved to the start of the file,
  51. # they depend on the sys.path.append call registering "_extensions".
  52. # GDScript syntax highlighting
  53. from gdscript import GDScriptLexer
  54. from sphinx.highlighting import lexers
  55. lexers["gdscript"] = GDScriptLexer()
  56. # fmt: on
  57. # Pygments (syntax highlighting) style to use
  58. pygments_style = "sphinx"
  59. highlight_language = "gdscript"
  60. # -- Options for HTML output ----------------------------------------------
  61. # on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org
  62. on_rtd = os.environ.get("READTHEDOCS", None) == "True"
  63. html_theme = "sphinx_rtd_theme"
  64. html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
  65. if on_rtd:
  66. using_rtd_theme = True
  67. # Theme options
  68. html_theme_options = {
  69. # if we have a html_logo below, this shows /only/ the logo with no title text
  70. "logo_only": True,
  71. # Collapse navigation (False makes it tree-like)
  72. "collapse_navigation": False,
  73. }
  74. # VCS options: https://docs.readthedocs.io/en/latest/vcs.html#github
  75. html_context = {
  76. "display_github": not is_i18n, # Integrate GitHub
  77. "github_user": "godotengine", # Username
  78. "github_repo": "godot-docs", # Repo name
  79. "github_version": "master", # Version
  80. "conf_py_path": "/", # Path in the checkout to the docs root
  81. "godot_inject_language_links": True,
  82. "godot_docs_supported_languages": supported_languages,
  83. "godot_docs_basepath": "https://docs.godotengine.org/",
  84. "godot_docs_suffix": ".html",
  85. "godot_default_lang": "en",
  86. "godot_canonical_version": "stable",
  87. }
  88. html_logo = "img/docs_logo.png"
  89. # These folders are copied to the documentation's HTML output
  90. html_static_path = ["_static"]
  91. html_extra_path = ["robots.txt"]
  92. # These paths are either relative to html_static_path
  93. # or fully qualified paths (eg. https://...)
  94. html_css_files = [
  95. "css/custom.css",
  96. ]
  97. html_js_files = [
  98. "js/custom.js",
  99. ]
  100. # Output file base name for HTML help builder
  101. htmlhelp_basename = "GodotEnginedoc"
  102. # -- Options for reStructuredText parser ----------------------------------
  103. # Enable directives that insert the contents of external files
  104. file_insertion_enabled = False
  105. # -- Options for LaTeX output ---------------------------------------------
  106. # Grouping the document tree into LaTeX files. List of tuples
  107. # (source start file, target name, title,
  108. # author, documentclass [howto, manual, or own class]).
  109. latex_documents = [
  110. (
  111. master_doc,
  112. "GodotEngine.tex",
  113. "Godot Engine Documentation",
  114. "Juan Linietsky, Ariel Manzur and the Godot community",
  115. "manual",
  116. ),
  117. ]
  118. # -- Options for linkcheck builder ----------------------------------------
  119. # disable checking urls with about.html#this_part_of_page anchors
  120. linkcheck_anchors = False
  121. linkcheck_timeout = 10
  122. # -- I18n settings --------------------------------------------------------
  123. locale_dirs = ["../sphinx/po/"]
  124. gettext_compact = False
  125. # Couldn't find a way to retrieve variables nor do advanced string
  126. # concat from reST, so had to hardcode this in the "epilog" added to
  127. # all pages. This is used in index.rst to display the Weblate badge.
  128. # On English pages, the badge points to the language-neutral engage page.
  129. rst_epilog = """
  130. .. |weblate_widget| image:: https://hosted.weblate.org/widgets/godot-engine/{image_locale}/godot-docs/287x66-white.png
  131. :alt: Translation status
  132. :target: https://hosted.weblate.org/engage/godot-engine{target_locale}/?utm_source=widget
  133. """.format(
  134. image_locale="-" if language == "en" else language,
  135. target_locale="" if language == "en" else "/" + language,
  136. )