Skip to content

Commit

Permalink
read sphinx conf from toml
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunsavel committed Mar 12, 2024
1 parent 1a77a01 commit e425db2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
34 changes: 7 additions & 27 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
import re
import sys

from sphinx_pyproject import SphinxConfig

config = SphinxConfig("../pyproject.toml", globalns=globals())

# MOCK_MODULES = [
# "numpy",
# "scipy",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions docs/doc_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ matplotlib
nbconvert<7.14
ipykernel
Sphinx
sphinx-pyproject

0 comments on commit e425db2

Please sign in to comment.