|
| 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 | + |
| 6 | +# -- Project information ----------------------------------------------------- |
| 7 | +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information |
| 8 | + |
| 9 | +project = 'MLIR Python bindings' |
| 10 | +copyright = '2025, MLIR authors' |
| 11 | +author = 'MLIR authors' |
| 12 | + |
| 13 | +# -- General configuration --------------------------------------------------- |
| 14 | +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration |
| 15 | + |
| 16 | +extensions = [ |
| 17 | + 'autoapi.extension' |
| 18 | +] |
| 19 | + |
| 20 | +templates_path = ['_templates'] |
| 21 | +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] |
| 22 | + |
| 23 | + |
| 24 | +# -- Options for HTML output ------------------------------------------------- |
| 25 | +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output |
| 26 | + |
| 27 | +html_theme = 'furo' |
| 28 | +html_static_path = ['_static'] |
| 29 | + |
| 30 | +# -- Options and custom logic for autoapi extension -------------------------- |
| 31 | +# https://sphinx-autoapi.readthedocs.io/en/latest/reference/config.html |
| 32 | + |
| 33 | +import os |
| 34 | +import mlir |
| 35 | + |
| 36 | +autoapi_dirs = list(mlir.__path__) |
| 37 | +autoapi_python_use_implicit_namespaces = True |
| 38 | + |
| 39 | + |
| 40 | +def ensure_mlir_index(_): |
| 41 | + mlir_dir = os.path.join(os.path.dirname(__file__), "autoapi/mlir") |
| 42 | + os.makedirs(mlir_dir, exist_ok=True) |
| 43 | + mlir_index = os.path.join(mlir_dir, "index.rst") |
| 44 | + with open(mlir_index, "w", encoding="utf-8") as f: |
| 45 | + f.write("mlir namespace\n===============\n\n.. toctree::\n :maxdepth: 2\n :glob:\n\n **\n") |
| 46 | + |
| 47 | + |
| 48 | +def setup(app): |
| 49 | + app.connect("builder-inited", ensure_mlir_index) |
0 commit comments