From e425db2b600d6f008bf70e6e106bc6de0404bd6d Mon Sep 17 00:00:00 2001 From: arjunsavel Date: Mon, 11 Mar 2024 21:06:24 -0400 Subject: [PATCH] read sphinx conf from toml --- docs/conf.py | 34 +++++++--------------------------- docs/doc_requirements.txt | 1 + 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index f3ca8d3..88eeda2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,6 +20,10 @@ import re import sys +from sphinx_pyproject import SphinxConfig + +config = SphinxConfig("../pyproject.toml", globalns=globals()) + # MOCK_MODULES = [ # "numpy", # "scipy", @@ -66,30 +70,6 @@ META_PATH = os.path.join("..", "src", "cortecs", "__init__.py") HERE = os.path.abspath(os.path.dirname(__file__)) - -def read(*parts): - """ - Build an absolute path from *parts* and and return the contents of the - resulting file. Assume UTF-8 encoding. - """ - with codecs.open(os.path.join(HERE, *parts), "rb", "utf-8") as f: - return f.read() - - -def find_meta(meta): - """ - Extract __*meta*__ from META_FILE. - """ - meta_match = re.search( - r"^__{meta}__ = ['\"]([^'\"]*)['\"]".format(meta=meta), META_FILE, re.M - ) - if meta_match: - return meta_match.group(1) - raise RuntimeError("Unable to find __{meta}__ string.".format(meta=meta)) - - -META_FILE = read(META_PATH) - extensions = [ "sphinx.ext.autodoc", "sphinx.ext.doctest", @@ -132,9 +112,9 @@ def find_meta(meta): # built documents. # # The short X.Y version. -version = find_meta("version") -# The full version, including alpha/beta/rc tags. -release = find_meta("release") +# version = find_meta("version") +# # The full version, including alpha/beta/rc tags. +# release = find_meta("release") # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/doc_requirements.txt b/docs/doc_requirements.txt index fd9ff1d..0547253 100644 --- a/docs/doc_requirements.txt +++ b/docs/doc_requirements.txt @@ -14,3 +14,4 @@ matplotlib nbconvert<7.14 ipykernel Sphinx +sphinx-pyproject