|
| 1 | +import os |
| 2 | +import sys |
| 3 | +from datetime import datetime |
| 4 | +from pathlib import Path |
| 5 | +from typing import Any, List |
| 6 | + |
| 7 | +import tomli |
| 8 | + |
| 9 | +# import tlcpack_sphinx_addon |
| 10 | +# Configuration file for the Sphinx documentation builder. |
| 11 | +# |
| 12 | +# For the full list of built-in configuration values, see the documentation: |
| 13 | +# https://www.sphinx-doc.org/en/master/usage/configuration.html |
| 14 | + |
| 15 | +# -- Project information ----------------------------------------------------- |
| 16 | +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information |
| 17 | + |
| 18 | +repo_root = Path(__file__).resolve().parents[2] |
| 19 | +sys.path.insert(0, str(repo_root)) |
| 20 | +os.environ["BUILD_DOC"] = "1" |
| 21 | + |
| 22 | +project = "FlashInfer-Bench" |
| 23 | +author = "FlashInfer Community" |
| 24 | +copyright = f"{datetime.now().year}, {author}" |
| 25 | + |
| 26 | +try: |
| 27 | + from setuptools_scm import get_version as scm_get_version |
| 28 | +except Exception: |
| 29 | + scm_get_version = None |
| 30 | + |
| 31 | + |
| 32 | +def _compute_version() -> str: |
| 33 | + v = os.environ.get("FLASHINFER_BENCH_VERSION") |
| 34 | + if v: |
| 35 | + return v |
| 36 | + if scm_get_version is not None: |
| 37 | + try: |
| 38 | + return scm_get_version(root=str(repo_root), fallback_version="0.0.0") |
| 39 | + except Exception: |
| 40 | + pass |
| 41 | + try: |
| 42 | + with open(repo_root / "pyproject.toml", "rb") as f: |
| 43 | + data = tomli.load(f) |
| 44 | + v = data.get("project", {}).get("version") |
| 45 | + if v: |
| 46 | + return v |
| 47 | + except Exception: |
| 48 | + pass |
| 49 | + return "0.0.0+docs" |
| 50 | + |
| 51 | + |
| 52 | +__version__ = _compute_version() |
| 53 | + |
| 54 | + |
| 55 | +# -- General configuration --------------------------------------------------- |
| 56 | +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration |
| 57 | + |
| 58 | +extensions = [ |
| 59 | + "myst_parser", |
| 60 | + "sphinx_tabs.tabs", |
| 61 | + "sphinx.ext.autodoc", |
| 62 | + "sphinx.ext.napoleon", |
| 63 | + "sphinx.ext.autosummary", |
| 64 | + "sphinx.ext.mathjax", |
| 65 | + "sphinxcontrib.autodoc_pydantic", |
| 66 | +] |
| 67 | + |
| 68 | +autodoc_mock_imports = [ |
| 69 | + "torch", |
| 70 | + "triton", |
| 71 | + "flashinfer._build_meta", |
| 72 | + "cuda", |
| 73 | + "numpy", |
| 74 | + "einops", |
| 75 | + "mpi4py", |
| 76 | + "safetensors", |
| 77 | +] |
| 78 | +autodoc_default_flags = ["members"] |
| 79 | +autodoc_class_signature = "separated" |
| 80 | +autodoc_member_order = "bysource" |
| 81 | +autodoc_default_options = {"exclude-members": "model_config"} |
| 82 | +autodoc_typehints = "both" |
| 83 | + |
| 84 | +autodoc_pydantic_model_show_validator_summary = False |
| 85 | +autodoc_pydantic_model_show_validator_members = False |
| 86 | +autodoc_pydantic_model_show_config_summary = False |
| 87 | +autodoc_pydantic_field_list_validators = False |
| 88 | +autodoc_pydantic_model_summary_list_order = "bysource" |
| 89 | +autodoc_pydantic_model_member_order = "bysource" |
| 90 | + |
| 91 | +autosummary_generate = True |
| 92 | + |
| 93 | +source_suffix = [".rst", ".md"] |
| 94 | + |
| 95 | +language = "en" |
| 96 | + |
| 97 | +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".sphinx-deps", ".sphinx-deps/**"] |
| 98 | + |
| 99 | +# The name of the Pygments (syntax highlighting) style to use. |
| 100 | +pygments_style = "sphinx" |
| 101 | + |
| 102 | +# A list of ignored prefixes for module index sorting. |
| 103 | +# If true, `todo` and `todoList` produce output, else they produce nothing. |
| 104 | +todo_include_todos = False |
| 105 | + |
| 106 | +myst_enable_extensions = [ |
| 107 | + "dollarmath", |
| 108 | + "amsmath", |
| 109 | + "deflist", |
| 110 | + "colon_fence", |
| 111 | + "html_image", |
| 112 | + "linkify", |
| 113 | + "substitution", |
| 114 | +] |
| 115 | + |
| 116 | +myst_heading_anchors = 3 |
| 117 | +myst_ref_domains = ["std", "py"] |
| 118 | +myst_all_links_external = False |
| 119 | + |
| 120 | +# -- Options for HTML output ---------------------------------------------- |
| 121 | + |
| 122 | +html_theme = "shibuya" |
| 123 | + |
| 124 | +templates_path: List[Any] = ["_templates"] |
| 125 | + |
| 126 | +html_static_path = ["_static"] |
| 127 | + |
| 128 | + |
| 129 | +html_theme_options = { |
| 130 | + "accent_color": "indigo", |
| 131 | + "logo_target": "/", |
| 132 | + "light_logo": "_static/brand/fib-light.png", |
| 133 | + "dark_logo": "_static/brand/fib-dark.png", |
| 134 | + "nav_links": [{"title": "Docs", "url": f"/docs", "external": True}], |
| 135 | + "globaltoc_expand_depth": 1, |
| 136 | +} |
0 commit comments