conf.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. # Configuration file for the Sphinx documentation builder.
  2. #
  3. # This file only contains a selection of the most common options. For a full
  4. # list see the documentation:
  5. # https://www.sphinx-doc.org/en/master/usage/configuration.html
  6. # -- Path setup --------------------------------------------------------------
  7. # If extensions (or modules to document with autodoc) are in another directory,
  8. # add these directories to sys.path here. If the directory is relative to the
  9. # documentation root, use os.path.abspath to make it absolute, like shown here.
  10. #
  11. import os
  12. # import sys
  13. # sys.path.insert(0, os.path.abspath('.'))
  14. # -- Project information -----------------------------------------------------
  15. project = 'DragonOS'
  16. copyright = '2022-2025, DragonOS Community'
  17. author = 'longjin'
  18. github_org = 'DragonOS-Community'
  19. github_repo = 'DragonOS'
  20. # The full version, including alpha/beta/rc tags
  21. release = 'dev'
  22. # -- General configuration ---------------------------------------------------
  23. # Add any Sphinx extension module names here, as strings. They can be
  24. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
  25. # ones.
  26. extensions = [
  27. 'myst_parser',
  28. 'sphinx_multiversion',
  29. 'sphinxcontrib.mermaid',
  30. 'sphinx.ext.extlinks',
  31. ]
  32. # Add any paths that contain templates here, relative to this directory.
  33. templates_path = ['_templates']
  34. # The language for content autogenerated by Sphinx. Refer to documentation
  35. # for a list of supported languages.
  36. #
  37. # This is also used if you do content translation via gettext catalogs.
  38. # Usually you set "language" from the command line for these cases.
  39. language = 'zh_CN'
  40. locale_dirs = ['locale/'] # path is example but recommended.
  41. # List of patterns, relative to source directory, that match files and
  42. # directories to ignore when looking for source files.
  43. # This pattern also affects html_static_path and html_extra_path.
  44. exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
  45. source_suffix = ['.rst', '.md']
  46. # -- Options for HTML output -------------------------------------------------
  47. # The theme to use for HTML and HTML Help pages. See the documentation for
  48. # a list of builtin themes.
  49. #
  50. html_theme = 'sphinx_rtd_theme'
  51. html_context = dict()
  52. # Add any paths that contain custom static files (such as style sheets) here,
  53. # relative to this directory. They are copied after the builtin static files,
  54. # so a file named "default.css" will overwrite the builtin "default.css".
  55. html_static_path = ['_static']
  56. html_sidebars = {
  57. '**': [
  58. 'versioning.html',
  59. ],
  60. }
  61. myst_enable_extensions = [
  62. "amsmath",
  63. "colon_fence",
  64. "deflist",
  65. "dollarmath",
  66. "fieldlist",
  67. "html_admonition",
  68. "html_image",
  69. "replacements",
  70. "smartquotes",
  71. "strikethrough",
  72. "substitution",
  73. "tasklist",
  74. ]
  75. # sphinx-multiversion 指定哪个分支为 lastest 版本
  76. smv_latest_version = 'master'
  77. smv_released_pattern = r'^tags/.*$' # Tags only
  78. smv_tag_whitelist = r'^(V.*|v.*)$'
  79. smv_branch_whitelist = "master"
  80. # Define the canonical URL if you are using a custom domain on Read the Docs
  81. html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "")
  82. # Tell Jinja2 templates the build is running on Read the Docs
  83. if os.environ.get("READTHEDOCS", "") == "True":
  84. html_context["READTHEDOCS"] = True
  85. if os.environ.get("SPHINX_MULTIVERSION_GIT_COMMIT", "") != "":
  86. html_context["commit"] = os.environ["SPHINX_MULTIVERSION_GIT_COMMIT"]
  87. elif os.environ.get("CURRENT_GIT_COMMIT_HASH", "") != "":
  88. html_context["commit"] = os.environ["CURRENT_GIT_COMMIT_HASH"]
  89. # 截取前 7 位 commit hash,如果长度不足则不截取
  90. if "commit" in html_context:
  91. html_context["commit"] = html_context["commit"][:7]
  92. if os.environ.get("CURRENT_GIT_COMMIT_DIRTY", "") == "1":
  93. html_context["commit"] += "-dirty"
  94. # -- Set GitHub URL for Edit on GitHub links ---
  95. html_context['display_github'] = True
  96. html_context['github_user'] = github_org
  97. html_context['github_repo'] = github_repo
  98. html_context['github_version'] = html_context['commit'] if 'commit' in html_context else 'master'
  99. html_context['conf_py_path'] = '/docs/'