conf.py 3.9 KB

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