2023-12-01 03:12:53 +08:00
|
|
|
# Copyright © 2023 Apple Inc.
|
|
|
|
|
2023-11-30 02:30:41 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
|
2024-01-19 04:00:24 +08:00
|
|
|
import mlx.core as mx
|
|
|
|
|
2023-11-30 02:30:41 +08:00
|
|
|
# -- Project information -----------------------------------------------------
|
|
|
|
|
|
|
|
project = "MLX"
|
|
|
|
copyright = "2023, MLX Contributors"
|
|
|
|
author = "MLX Contributors"
|
2024-01-26 03:01:05 +08:00
|
|
|
version = ".".join(mx.__version__.split(".")[:3])
|
2024-01-19 04:00:24 +08:00
|
|
|
release = version
|
2023-11-30 02:30:41 +08:00
|
|
|
|
|
|
|
# -- General configuration ---------------------------------------------------
|
|
|
|
|
|
|
|
extensions = [
|
|
|
|
"sphinx.ext.autodoc",
|
|
|
|
"sphinx.ext.autosummary",
|
|
|
|
"sphinx.ext.intersphinx",
|
|
|
|
"sphinx.ext.napoleon",
|
2024-04-27 03:56:05 +08:00
|
|
|
"breathe",
|
2023-11-30 02:30:41 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
python_use_unqualified_type_names = True
|
|
|
|
autosummary_generate = True
|
2024-02-15 06:14:58 +08:00
|
|
|
autosummary_filename_map = {"mlx.core.Stream": "stream_class"}
|
2023-11-30 02:30:41 +08:00
|
|
|
|
|
|
|
intersphinx_mapping = {
|
2024-03-19 11:12:25 +08:00
|
|
|
"python": ("https://docs.python.org/3", None),
|
|
|
|
"numpy": ("https://numpy.org/doc/stable/", None),
|
2023-11-30 02:30:41 +08:00
|
|
|
}
|
|
|
|
|
2024-04-27 03:56:05 +08:00
|
|
|
breathe_projects = {"mlx": "../build/xml"}
|
|
|
|
breathe_default_project = "mlx"
|
|
|
|
|
2023-11-30 02:30:41 +08:00
|
|
|
templates_path = ["_templates"]
|
|
|
|
html_static_path = ["_static"]
|
|
|
|
source_suffix = ".rst"
|
2024-03-25 06:03:27 +08:00
|
|
|
main_doc = "index"
|
2023-11-30 02:30:41 +08:00
|
|
|
highlight_language = "python"
|
|
|
|
pygments_style = "sphinx"
|
2024-03-25 06:03:27 +08:00
|
|
|
add_module_names = False
|
2023-11-30 02:30:41 +08:00
|
|
|
|
|
|
|
# -- Options for HTML output -------------------------------------------------
|
|
|
|
|
2023-12-06 04:08:05 +08:00
|
|
|
html_theme = "sphinx_book_theme"
|
|
|
|
|
|
|
|
html_theme_options = {
|
|
|
|
"show_toc_level": 2,
|
|
|
|
"repository_url": "https://github.com/ml-explore/mlx",
|
|
|
|
"use_repository_button": True,
|
|
|
|
"navigation_with_keys": False,
|
2024-02-21 02:57:02 +08:00
|
|
|
"logo": {
|
|
|
|
"image_light": "_static/mlx_logo.png",
|
|
|
|
"image_dark": "_static/mlx_logo_dark.png",
|
|
|
|
},
|
2023-12-06 04:08:05 +08:00
|
|
|
}
|
|
|
|
|
2023-11-30 02:30:41 +08:00
|
|
|
|
|
|
|
# -- Options for HTMLHelp output ---------------------------------------------
|
|
|
|
|
|
|
|
htmlhelp_basename = "mlx_doc"
|
2024-03-19 11:12:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
def setup(app):
|
2024-03-25 06:03:27 +08:00
|
|
|
from sphinx.util import inspect
|
2024-03-19 11:12:25 +08:00
|
|
|
|
2024-03-25 06:03:27 +08:00
|
|
|
wrapped_isfunc = inspect.isfunction
|
2024-03-19 11:12:25 +08:00
|
|
|
|
2024-03-25 06:03:27 +08:00
|
|
|
def isfunc(obj):
|
|
|
|
type_name = str(type(obj))
|
|
|
|
if "nanobind.nb_method" in type_name or "nanobind.nb_func" in type_name:
|
|
|
|
return True
|
|
|
|
return wrapped_isfunc(obj)
|
|
|
|
|
|
|
|
inspect.isfunction = isfunc
|
|
|
|
|
|
|
|
|
|
|
|
# -- Options for LaTeX output ------------------------------------------------
|
|
|
|
|
|
|
|
latex_documents = [(main_doc, "MLX.tex", "MLX Documentation", author, "manual")]
|
2024-07-30 02:44:06 +08:00
|
|
|
latex_elements = {
|
|
|
|
"preamble": r"""
|
|
|
|
\usepackage{enumitem}
|
|
|
|
\setlistdepth{5}
|
|
|
|
\setlist[itemize,1]{label=$\bullet$}
|
|
|
|
\setlist[itemize,2]{label=$\bullet$}
|
|
|
|
\setlist[itemize,3]{label=$\bullet$}
|
|
|
|
\setlist[itemize,4]{label=$\bullet$}
|
|
|
|
\setlist[itemize,5]{label=$\bullet$}
|
|
|
|
\renewlist{itemize}{itemize}{5}
|
|
|
|
""",
|
|
|
|
}
|