From 155922ff064dd8841a7e853dd1bda9b2fb44ed70 Mon Sep 17 00:00:00 2001 From: Susana Hahn Date: Wed, 13 Nov 2024 17:26:39 -0600 Subject: [PATCH 1/4] Fixed documentation to work with project.toml instead of setup.py --- README.md | 10 ++++++++++ doc/conf.py | 24 +++++++++++++----------- pyproject.toml | 25 ++++++++++--------------- src/fillname/utils/parser.py | 7 +------ 4 files changed, 34 insertions(+), 32 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..40a1a3f 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -6,10 +6,12 @@ # -- Path setup -------------------------------------------------------------- -import configparser import datetime import os import sys +from importlib import metadata + +import toml sys.path.insert(0, os.path.abspath(".")) # modules that autodock should mock @@ -18,23 +20,23 @@ # -- 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"] + +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 +72,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 +88,7 @@ "footer_icons": [ { "name": "GitHub", - "url": _meta["url"], + "url": url, "html": """ diff --git a/pyproject.toml b/pyproject.toml index 22fe43f..17aec66 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", "toml"] +dev = ["fillname[test,typecheck,lint_pylint]"] [project.scripts] fillname = "fillname.__main__:main" diff --git a/src/fillname/utils/parser.py b/src/fillname/utils/parser.py index 1be5ce8..b53332f 100644 --- a/src/fillname/utils/parser.py +++ b/src/fillname/utils/parser.py @@ -2,8 +2,8 @@ The command line parser for the project. """ -import sys from argparse import ArgumentParser +from importlib import metadata # nocoverage from textwrap import dedent from typing import Any, Optional, cast @@ -11,11 +11,6 @@ __all__ = ["get_parser"] -if sys.version_info[1] < 8: - import importlib_metadata as metadata # nocoverage -else: - from importlib import metadata # nocoverage - VERSION = metadata.version("fillname") From 96ec8a8d43bc9ee22fb1d9b26dcb647d1bc66081 Mon Sep 17 00:00:00 2001 From: Roland Kaminski Date: Thu, 14 Nov 2024 01:06:24 +0100 Subject: [PATCH 2/4] Update README.md just wording --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 63a47c6..cdd189a 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,7 @@ Run the following for basic usage information: fillname -h ``` -For detailed information on the project one can compile and open the -documentation +To generate and open the documentation, run ```bash nox -s doc -- open From 95fc126757f9c00f262320d6345d99e26857d527 Mon Sep 17 00:00:00 2001 From: Roland Kaminski Date: Thu, 14 Nov 2024 01:07:30 +0100 Subject: [PATCH 3/4] Update conf.py --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 40a1a3f..a4b4e2e 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -36,7 +36,7 @@ # 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 project.toml")) so they are available when building +# [options.extras_require] in project.toml so they are available when building # the documentation. extensions = [ From dc573f8c3b4272a2ae65baf8619be7bce4f7dfb1 Mon Sep 17 00:00:00 2001 From: Roland Kaminski Date: Thu, 14 Nov 2024 10:56:43 +0100 Subject: [PATCH 4/4] Update parser.py --- src/fillname/utils/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fillname/utils/parser.py b/src/fillname/utils/parser.py index b53332f..677c5b6 100644 --- a/src/fillname/utils/parser.py +++ b/src/fillname/utils/parser.py @@ -3,7 +3,7 @@ """ from argparse import ArgumentParser -from importlib import metadata # nocoverage +from importlib import metadata from textwrap import dedent from typing import Any, Optional, cast