You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

conf.py 7.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. # Configuration file for the Sphinx documentation builder.
  2. #
  3. # For the full list of built-in configuration values, see the documentation:
  4. # https://www.sphinx-doc.org/en/master/usage/configuration.html
  5. from sphinx.application import Sphinx
  6. from typing import Any, Dict
  7. from pathlib import Path
  8. import sys
  9. import os
  10. # -- Project information -----------------------------------------------------
  11. # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
  12. import autogen_core
  13. project = "autogen_core"
  14. copyright = "2024, Microsoft"
  15. author = "Microsoft"
  16. version = "0.4"
  17. release_override = os.getenv("SPHINX_RELEASE_OVERRIDE")
  18. if release_override is None or release_override == "":
  19. release = autogen_core.__version__
  20. else:
  21. release = release_override
  22. sys.path.append(str(Path(".").resolve()))
  23. # -- General configuration ---------------------------------------------------
  24. # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
  25. extensions = [
  26. "sphinx.ext.napoleon",
  27. "sphinx.ext.autodoc",
  28. "sphinx.ext.autosummary",
  29. "sphinx.ext.todo",
  30. "sphinx.ext.viewcode",
  31. "sphinx.ext.intersphinx",
  32. "sphinx.ext.graphviz",
  33. "sphinxext.rediraffe",
  34. "sphinx_design",
  35. "sphinx_copybutton",
  36. "_extension.gallery_directive",
  37. "myst_nb",
  38. "sphinxcontrib.autodoc_pydantic",
  39. "_extension.code_lint",
  40. ]
  41. suppress_warnings = ["myst.header"]
  42. napoleon_custom_sections = [("Returns", "params_style")]
  43. templates_path = ["_templates"]
  44. autoclass_content = "class"
  45. # TODO: incldue all notebooks excluding those requiring remote API access.
  46. nb_execution_mode = "off"
  47. # Guides and tutorials must succeed.
  48. nb_execution_raise_on_error = True
  49. nb_execution_timeout = 60
  50. myst_heading_anchors = 5
  51. myst_enable_extensions = [
  52. "colon_fence",
  53. "linkify",
  54. "strikethrough",
  55. ]
  56. if (path := os.getenv("PY_DOCS_DIR")) is None:
  57. path = "dev"
  58. if (switcher_version := os.getenv("PY_SWITCHER_VERSION")) is None:
  59. switcher_version = "dev"
  60. html_baseurl = f"/autogen/{path}/"
  61. # -- Options for HTML output -------------------------------------------------
  62. # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
  63. html_title = "AutoGen"
  64. html_theme = "pydata_sphinx_theme"
  65. html_static_path = ["_static"]
  66. html_css_files = ["custom.css"]
  67. add_module_names = False
  68. html_logo = "_static/images/logo/logo.svg"
  69. html_favicon = "_static/images/logo/favicon-512x512.png"
  70. html_theme_options = {
  71. "header_links_before_dropdown": 6,
  72. "navbar_align": "left",
  73. "check_switcher": False,
  74. # "navbar_start": ["navbar-logo", "version-switcher"],
  75. # "switcher": {
  76. # "json_url": "/_static/switcher.json",
  77. # },
  78. "show_prev_next": True,
  79. "icon_links": [
  80. {
  81. "name": "GitHub",
  82. "url": "https://github.com/microsoft/autogen",
  83. "icon": "fa-brands fa-github",
  84. },
  85. {
  86. "name": "Discord",
  87. "url": "https://aka.ms/autogen-discord",
  88. "icon": "fa-brands fa-discord",
  89. },
  90. {
  91. "name": "Twitter",
  92. "url": "https://twitter.com/pyautogen",
  93. "icon": "fa-brands fa-twitter",
  94. }
  95. ],
  96. "footer_start": ["copyright"],
  97. "footer_center": ["footer-middle-links"],
  98. "footer_end": ["theme-version", "version-banner-override"],
  99. "pygments_light_style": "xcode",
  100. "pygments_dark_style": "monokai",
  101. "navbar_start": ["navbar-logo", "version-switcher"],
  102. "switcher": {
  103. "json_url": "https://raw.githubusercontent.com/microsoft/autogen/refs/heads/main/docs/switcher.json",
  104. "version_match": switcher_version,
  105. },
  106. "show_version_warning_banner": True,
  107. "external_links": [
  108. {"name": ".NET", "url": "https://microsoft.github.io/autogen/dotnet/"},
  109. {"name": "0.2 Docs", "url": "https://microsoft.github.io/autogen/0.2/"},
  110. ]
  111. }
  112. html_js_files = ["custom-icon.js", "banner-override.js", "custom.js"]
  113. html_sidebars = {
  114. "packages/index": [],
  115. "user-guide/core-user-guide/**": ["sidebar-nav-bs-core"],
  116. "user-guide/agentchat-user-guide/**": ["sidebar-nav-bs-agentchat"],
  117. "user-guide/extensions-user-guide/**": ["sidebar-nav-bs-extensions"],
  118. "user-guide/autogenstudio-user-guide/**": ["sidebar-nav-bs-studio"],
  119. }
  120. html_context = {
  121. 'display_github': True,
  122. "github_user": "microsoft",
  123. "github_repo": "autogen",
  124. "github_version": "main",
  125. "doc_path": "python/packages/autogen-core/docs/src/",
  126. }
  127. autodoc_default_options = {
  128. "members": True,
  129. "undoc-members": True,
  130. }
  131. autodoc_pydantic_model_show_config_summary = False
  132. autodoc_pydantic_model_show_json_error_strategy = "coerce"
  133. python_use_unqualified_type_names = True
  134. autodoc_preserve_defaults = True
  135. intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
  136. code_lint_path_prefix = "reference/python"
  137. nb_mime_priority_overrides = [
  138. ('code_lint', 'image/jpeg', 100),
  139. ('code_lint', 'image/png', 100),
  140. ('code_lint', 'text/plain', 100)
  141. ]
  142. rediraffe_redirects = {
  143. "user-guide/agentchat-user-guide/tutorial/selector-group-chat.ipynb": "user-guide/agentchat-user-guide/selector-group-chat.ipynb",
  144. "user-guide/agentchat-user-guide/tutorial/swarm.ipynb": "user-guide/agentchat-user-guide/swarm.ipynb",
  145. "user-guide/core-user-guide/framework/command-line-code-executors.ipynb": "user-guide/core-user-guide/components/command-line-code-executors.ipynb",
  146. "user-guide/core-user-guide/framework/model-clients.ipynb": "user-guide/core-user-guide/components/model-clients.ipynb",
  147. "user-guide/core-user-guide/framework/tools.ipynb": "user-guide/core-user-guide/components/tools.ipynb",
  148. "user-guide/agentchat-user-guide/tutorial/custom-agents.ipynb": "user-guide/agentchat-user-guide/custom-agents.ipynb",
  149. }
  150. def setup_to_main(
  151. app: Sphinx, pagename: str, templatename: str, context, doctree
  152. ) -> None:
  153. """Add a function that jinja can access for returning an "edit this page" link pointing to `main`."""
  154. def to_main(link: str) -> str:
  155. """Transform "edit on github" links and make sure they always point to the main branch.
  156. Args:
  157. link: the link to the github edit interface
  158. Returns:
  159. the link to the tip of the main branch for the same file
  160. """
  161. links = link.split("/")
  162. idx = links.index("edit")
  163. return "/".join(links[: idx + 1]) + "/main/" + "/".join(links[idx + 2:])
  164. context["to_main"] = to_main
  165. def setup(app: Sphinx) -> Dict[str, Any]:
  166. """Add custom configuration to sphinx app.
  167. Args:
  168. app: the Sphinx application
  169. Returns:
  170. the 2 parallel parameters set to ``True``.
  171. """
  172. app.connect("html-page-context", setup_to_main)
  173. # Adding here so it is inline and not in a separate file.
  174. clarity_analytics = """(function(c,l,a,r,i,t,y){
  175. c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
  176. t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
  177. y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
  178. })(window, document, "clarity", "script", "lnxpe6skj1");"""
  179. app.add_js_file(None, body=clarity_analytics)
  180. return {
  181. "parallel_read_safe": True,
  182. "parallel_write_safe": True,
  183. }