From 0c421dadc9f8044949bc0a1e01dc5aa607e435e5 Mon Sep 17 00:00:00 2001 From: Susana Hahn Date: Wed, 13 Nov 2024 17:26:39 -0600 Subject: [PATCH] Fixed documentation to work with project.toml instead of setup.py --- README.md | 10 ++++++++++ doc/conf.py | 26 +++++++++++++++----------- pyproject.toml | 25 ++++++++++--------------- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index fb72587..63a47c6 100644 --- a/README.md +++ b/README.md @@ -24,3 +24,13 @@ Run the following for basic usage information: ```bash fillname -h ``` + +For detailed information on the project one can compile and open the +documentation + +```bash +nox -s doc -- open +``` + +Instructions to install and use `nox` can be found in +[DEVELOPMENT.md](./DEVELOPMENT.md) diff --git a/doc/conf.py b/doc/conf.py index 80d51a4..537e891 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -6,10 +6,10 @@ # -- Path setup -------------------------------------------------------------- -import configparser import datetime import os import sys +import toml sys.path.insert(0, os.path.abspath(".")) # modules that autodock should mock @@ -18,23 +18,27 @@ # -- Project information ----------------------------------------------------- -_config = configparser.RawConfigParser() -_config.read(os.path.join("..", "setup.cfg")) -_meta = dict(_config.items("metadata")) +toml_config = toml.load(os.path.join("..", "pyproject.toml")) +project = toml_config["project"]["name"] +author = ", ".join([a["name"] for a in toml_config["project"]["authors"]]) +url = toml_config["project"]["urls"]["Homepage"] +copyright = f'{datetime.datetime.now().date().strftime("%Y")}, {author}' -project = _meta["name"] -copyright = f'{datetime.datetime.now().date().strftime("%Y")}, {_meta["author"]}' -author = _meta["author"] # The full version, including alpha/beta/rc tags -release = _meta["version"] +if sys.version_info[1] < 8: + import importlib_metadata as metadata +else: + from importlib import metadata + +release = metadata.version("fillname") # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. Make sure that custom extensions are listed in the doc field of -# [options.extras_require] in setup.cfg so they are available when building +# [options.extras_require] in project.toml")) so they are available when building # the documentation. extensions = [ @@ -70,7 +74,7 @@ # This pattern also affects html_static_path and html_extra_path. exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] -html_title = _meta["name"] +html_title = project # -- Options for HTML output ------------------------------------------------- @@ -86,7 +90,7 @@ "footer_icons": [ { "name": "GitHub", - "url": _meta["url"], + "url": url, "html": """ diff --git a/pyproject.toml b/pyproject.toml index 22fe43f..f3e2cb7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,31 +1,26 @@ [build-system] -requires = [ - "setuptools", - "setuptools-scm", -] +requires = ["setuptools", "setuptools-scm"] build-backend = "setuptools.build_meta" [project] name = "fillname" -authors = [ - { name = "Author Fillname", email = "author@fillname.org" } -] +authors = [{ name = "Author Fillname", email = "author@fillname.org" }] description = "A template project." requires-python = ">=3.9" -license = {file = "LICENSE"} -dynamic = [ "version" ] +license = { file = "LICENSE" } +dynamic = ["version"] readme = "README.md" [project.urls] Homepage = "https://fillname.org/" [project.optional-dependencies] -format = [ "black", "isort", "autoflake" ] -lint_pylint = [ "pylint" ] -typecheck = [ "types-setuptools", "mypy" ] -test = [ "coverage[toml]" ] -doc = [ "sphinx", "furo", "nbsphinx", "sphinx_copybutton", "myst-parser" ] -dev = [ "fillname[test,typecheck,lint_pylint]" ] +format = ["black", "isort", "autoflake"] +lint_pylint = ["pylint"] +typecheck = ["types-setuptools", "mypy"] +test = ["coverage[toml]"] +doc = ["sphinx", "furo", "nbsphinx", "sphinx_copybutton", "myst-parser", "importlib_metadata", "toml"] +dev = ["fillname[test,typecheck,lint_pylint]"] [project.scripts] fillname = "fillname.__main__:main"