2
0

conf.py 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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 = ["gdscript", "sphinx_tabs.tabs", "sphinx.ext.imgmath"]
  12. templates_path = ["_templates"]
  13. # You can specify multiple suffix as a list of string: ['.rst', '.md']
  14. source_suffix = ".rst"
  15. source_encoding = "utf-8-sig"
  16. # The master toctree document
  17. master_doc = "index"
  18. # General information about the project
  19. project = "Godot Engine"
  20. copyright = (
  21. "2014-2020, Juan Linietsky, Ariel Manzur and the Godot community (CC-BY 3.0)"
  22. )
  23. author = "Juan Linietsky, Ariel Manzur and the Godot community"
  24. # Version info for the project, acts as replacement for |version| and |release|
  25. # The short X.Y version
  26. version = "latest"
  27. # The full version, including alpha/beta/rc tags
  28. release = "latest"
  29. # Parse Sphinx tags passed from RTD via environment
  30. env_tags = os.getenv("SPHINX_TAGS")
  31. if env_tags is not None:
  32. for tag in env_tags.split(","):
  33. print("Adding Sphinx tag: %s" % tag.strip())
  34. tags.add(tag.strip()) # noqa: F821
  35. # Language / i18n
  36. language = os.getenv("READTHEDOCS_LANGUAGE", "en")
  37. is_i18n = tags.has("i18n") # noqa: F821
  38. exclude_patterns = ["_build"]
  39. # fmt: off
  40. # These imports should *not* be moved to the start of the file,
  41. # they depend on the sys.path.append call registering "extensions".
  42. # GDScript syntax highlighting
  43. from gdscript import GDScriptLexer
  44. from sphinx.highlighting import lexers
  45. lexers["gdscript"] = GDScriptLexer()
  46. # fmt: on
  47. # Pygments (syntax highlighting) style to use
  48. pygments_style = "sphinx"
  49. highlight_language = "gdscript"
  50. # -- Options for HTML output ----------------------------------------------
  51. # on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org
  52. on_rtd = os.environ.get("READTHEDOCS", None) == "True"
  53. html_theme = "sphinx_rtd_theme"
  54. html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
  55. if on_rtd:
  56. using_rtd_theme = True
  57. # Theme options
  58. html_theme_options = {
  59. # if we have a html_logo below, this shows /only/ the logo with no title text
  60. "logo_only": True,
  61. # Collapse navigation (False makes it tree-like)
  62. "collapse_navigation": False,
  63. }
  64. # VCS options: https://docs.readthedocs.io/en/latest/vcs.html#github
  65. html_context = {
  66. "display_github": not is_i18n, # Integrate GitHub
  67. "github_user": "godotengine", # Username
  68. "github_repo": "godot-docs", # Repo name
  69. "github_version": "master", # Version
  70. "conf_py_path": "/", # Path in the checkout to the docs root
  71. }
  72. html_logo = "img/docs_logo.png"
  73. # These folders are copied to the documentation's HTML output
  74. html_static_path = ["_static"]
  75. html_extra_path = ["robots.txt"]
  76. # These paths are either relative to html_static_path
  77. # or fully qualified paths (eg. https://...)
  78. html_css_files = [
  79. "css/custom.css",
  80. ]
  81. html_js_files = [
  82. "js/custom.js",
  83. ]
  84. # Output file base name for HTML help builder
  85. htmlhelp_basename = "GodotEnginedoc"
  86. # -- Options for reStructuredText parser ----------------------------------
  87. # Enable directives that insert the contents of external files
  88. file_insertion_enabled = False
  89. # -- Options for LaTeX output ---------------------------------------------
  90. # Grouping the document tree into LaTeX files. List of tuples
  91. # (source start file, target name, title,
  92. # author, documentclass [howto, manual, or own class]).
  93. latex_documents = [
  94. (
  95. master_doc,
  96. "GodotEngine.tex",
  97. "Godot Engine Documentation",
  98. "Juan Linietsky, Ariel Manzur and the Godot community",
  99. "manual",
  100. ),
  101. ]
  102. # -- Options for linkcheck builder ----------------------------------------
  103. # disable checking urls with about.html#this_part_of_page anchors
  104. linkcheck_anchors = False
  105. linkcheck_timeout = 10
  106. # -- I18n settings --------------------------------------------------------
  107. locale_dirs = ["../sphinx/po/"]
  108. gettext_compact = False
  109. # Couldn't find a way to retrieve variables nor do advanced string
  110. # concat from reST, so had to hardcode this in the "epilog" added to
  111. # all pages. This is used in index.rst to display the Weblate badge.
  112. # On English pages, the badge points to the language-neutral engage page.
  113. rst_epilog = """
  114. .. |weblate_widget| image:: https://hosted.weblate.org/widgets/godot-engine/{image_locale}/godot-docs/287x66-white.png
  115. :alt: Translation status
  116. :target: https://hosted.weblate.org/engage/godot-engine{target_locale}/?utm_source=widget
  117. """.format(
  118. image_locale="-" if language == "en" else language,
  119. target_locale="" if language == "en" else "/" + language,
  120. )
  121. # Exclude class reference when marked with tag i18n.
  122. if is_i18n:
  123. exclude_patterns = ["classes"]