conf.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. # List of patterns, relative to source directory, that match files and
  41. # directories to ignore when looking for source files.
  42. # This pattern also affects html_static_path and html_extra_path.
  43. exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
  44. source_suffix = ['.rst', '.md']
  45. # -- Options for HTML output -------------------------------------------------
  46. # The theme to use for HTML and HTML Help pages. See the documentation for
  47. # a list of builtin themes.
  48. #
  49. html_theme = 'sphinx_rtd_theme'
  50. html_context = dict()
  51. # Add any paths that contain custom static files (such as style sheets) here,
  52. # relative to this directory. They are copied after the builtin static files,
  53. # so a file named "default.css" will overwrite the builtin "default.css".
  54. html_static_path = ['_static']
  55. html_sidebars = {
  56. '**': [
  57. 'versioning.html',
  58. ],
  59. }
  60. myst_enable_extensions = [
  61. "amsmath",
  62. "colon_fence",
  63. "deflist",
  64. "dollarmath",
  65. "fieldlist",
  66. "html_admonition",
  67. "html_image",
  68. "replacements",
  69. "smartquotes",
  70. "strikethrough",
  71. "substitution",
  72. "tasklist",
  73. ]
  74. # sphinx-multiversion 指定哪个分支为 lastest 版本
  75. smv_latest_version = 'master'
  76. smv_released_pattern = r'^tags/.*$' # Tags only
  77. smv_tag_whitelist = r'^(V.*|v.*)$'
  78. smv_branch_whitelist = "master"
  79. # Define the canonical URL if you are using a custom domain on Read the Docs
  80. html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "")
  81. # Tell Jinja2 templates the build is running on Read the Docs
  82. if os.environ.get("READTHEDOCS", "") == "True":
  83. html_context["READTHEDOCS"] = True
  84. if os.environ.get("SPHINX_MULTIVERSION_GIT_COMMIT", "") != "":
  85. html_context["commit"] = os.environ["SPHINX_MULTIVERSION_GIT_COMMIT"]
  86. elif os.environ.get("CURRENT_GIT_COMMIT_HASH", "") != "":
  87. html_context["commit"] = os.environ["CURRENT_GIT_COMMIT_HASH"]
  88. # 截取前 7 位 commit hash,如果长度不足则不截取
  89. if "commit" in html_context:
  90. html_context["commit"] = html_context["commit"][:7]
  91. if os.environ.get("CURRENT_GIT_COMMIT_DIRTY", "") == "1":
  92. html_context["commit"] += "-dirty"
  93. # -- Set GitHub URL for Edit on GitHub links ---
  94. html_context['display_github'] = True
  95. html_context['github_user'] = github_org
  96. html_context['github_repo'] = github_repo
  97. html_context['github_version'] = html_context['commit'] if 'commit' in html_context else 'master'
  98. html_context['conf_py_path'] = '/docs/'