import sys
import os
import logging
import datetime
from pathlib import Path
sys.path.append(os.path.abspath('.'))
from icons import ICONS
from blog_data import BLOG_DATA
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO
)
if os.getenv("BUILD_WITH_PACKAGE", "").lower() == "false":
sys.path.insert(0, str(Path("..", "api", "python").resolve()))
else:
logging.info("The installed openYuanrong package will be used to generate the Python API doc")
ENV_YR_GIT_COMMIT_ID = os.environ.get("YR_DOC_GIT_COMMIT_ID", "")
ENV_BUILD_VERSION = os.environ.get("BUILD_VERSION", "")
build_time = datetime.datetime.now(tz=datetime.timezone.utc) + datetime.timedelta(
hours=8
)
current_time_str = build_time.strftime("%Y-%m-%d %H:%M:%S")
project = "openYuanrong"
copyright = f"{build_time.year}, openEuler openYuanrong"
author = "openYuanrong with CC BY 4.0 LICENSE"
language = "zh_CN"
logging.info(
f"""Doc build configs:
ENV_YR_GIT_COMMIT_ID: {ENV_YR_GIT_COMMIT_ID}
ENV_BUILD_VERSION: {ENV_BUILD_VERSION}
current_date: {current_time_str}
project: {project}
copyright: {copyright}
author: {author}
"""
)
templates_path = ["_templates"]
exclude_patterns = [
"_build",
"README.md",
"sample_code",
"observability/trace_optimization.md",
""
]
extensions = [
"sphinx_sitemap",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
"sphinx_design",
"sphinx_copybutton",
"sphinx_togglebutton",
"myst_parser",
"breathe",
"sphinxcontrib.openapi",
]
sitemap_url_scheme = "{link}"
sitemap_show_lastmod = True
sitemap_excludes = [
"search.html",
"genindex.html",
"_modules/**",
]
autoclass_content = "both"
copybutton_exclude = ".linenos, .gp, .go"
autodoc_mock_imports = ["acl", "requests", "fastapi", "numpy"]
autosummary_generate = True
autosummary_generate_overwrite = True
autosummary_ignore_module_all = False
autosummary_imported_members = True
html_logo = "../images/logo-small.png"
html_theme = "sphinx_book_theme"
html_static_path = ["../_static"]
html_favicon = "../_static/favicon.ico"
html_extra_path = ["robots.txt"]
html_css_files = [
"custom.css",
"css/dismissable-banner.css",
]
html_js_files = [
"language-switcher.js",
"js/dismissable-banner.js",
]
html_baseurl = "https://docs.openyuanrong.org/zh-cn/latest/"
html_theme_options = {
"show_navbar_depth": 1,
"max_navbar_depth": 7,
"collapse_navigation": True,
"home_page_in_toc": True,
"check_switcher": False,
"announcement": (
"🚀 <b>openYuanrong v0.9.0</b> 已发布 — 新增企业级Agent分布式运行时"
" · "
"<a href='https://gitcode.com/openeuler/yuanrong/releases'>查看详情 →</a>"
"<button type='button' id='close-banner' aria-label='关闭横幅'>×</button>"
),
"extra_footer": """
Built with
<a href="https://www.sphinx-doc.org/en/master/">Sphinx</a>
using a
<a href="https://github.com/executablebooks/sphinx-book-theme">theme</a>
provided by
<a href="https://github.com/executablebooks">Executable Books Project</a>.
""",
"navbar_start": [
"navbar-logo",
"navbar-nav",
],
"navbar_end": [
"language-switcher",
"version-switcher",
],
"switcher": {
"json_url": "https://docs.openyuanrong.org/versions.json",
"version_match": os.getenv("BUILD_VERSION", "latest"),
},
"logo": {
"image_light": "_static/image-light.png",
"image_dark": "_static/image-dark.png"
},
"secondary_sidebar_items": {
"**": ["page-toc"],
"index": []
},
}
html_sidebars = {
"**": ["search-button-field.html", "sbt-sidebar-nav.html"]
}
html_additional_pages = {
'index': 'custom-index.html'
}
myst_enable_extensions = [
"dollarmath",
"amsmath",
"deflist",
"fieldlist",
"html_admonition",
"html_image",
"colon_fence",
"smartquotes",
"replacements",
"strikethrough",
"substitution",
"tasklist",
"attrs_inline",
"attrs_block",
]
breathe_projects = {"openYuanrong": "./../.doxygendocs/xml"}
breathe_default_project = "openYuanrong"
html_context = {
**ICONS,
"blog_data": BLOG_DATA,
"doc_language": "zh-cn",
"base_url": html_baseurl,
"metatags": """
<meta name="author" content="openYuanrong Team">
<meta name="keywords" content="openYuanrong, 分布式计算引擎, AI推理, Serverless">
"""
}