Skip to content

Commit 5295b93

Browse files
susuhahnmlrkaminsk
andauthored
Fixed documentation to work with project.toml instead of setup.py (#48)
* Fixed documentation to work with project.toml instead of setup.py --------- Co-authored-by: Roland Kaminski <rkaminsk@users.noreply.github.com>
1 parent 888c874 commit 5295b93

File tree

4 files changed

+33
-32
lines changed

4 files changed

+33
-32
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,12 @@ Run the following for basic usage information:
2424
```bash
2525
fillname -h
2626
```
27+
28+
To generate and open the documentation, run
29+
30+
```bash
31+
nox -s doc -- open
32+
```
33+
34+
Instructions to install and use `nox` can be found in
35+
[DEVELOPMENT.md](./DEVELOPMENT.md)

doc/conf.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66

77
# -- Path setup --------------------------------------------------------------
88

9-
import configparser
109
import datetime
1110
import os
1211
import sys
12+
from importlib import metadata
13+
14+
import toml
1315

1416
sys.path.insert(0, os.path.abspath("."))
1517
# modules that autodock should mock
@@ -18,23 +20,23 @@
1820

1921
# -- Project information -----------------------------------------------------
2022

21-
_config = configparser.RawConfigParser()
22-
_config.read(os.path.join("..", "setup.cfg"))
23-
_meta = dict(_config.items("metadata"))
23+
toml_config = toml.load(os.path.join("..", "pyproject.toml"))
24+
project = toml_config["project"]["name"]
25+
author = ", ".join([a["name"] for a in toml_config["project"]["authors"]])
26+
url = toml_config["project"]["urls"]["Homepage"]
27+
copyright = f'{datetime.datetime.now().date().strftime("%Y")}, {author}'
2428

25-
project = _meta["name"]
26-
copyright = f'{datetime.datetime.now().date().strftime("%Y")}, {_meta["author"]}'
27-
author = _meta["author"]
2829

2930
# The full version, including alpha/beta/rc tags
30-
release = _meta["version"]
31+
32+
release = metadata.version("fillname")
3133

3234
# -- General configuration ---------------------------------------------------
3335

3436
# Add any Sphinx extension module names here, as strings. They can be
3537
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3638
# ones. Make sure that custom extensions are listed in the doc field of
37-
# [options.extras_require] in setup.cfg so they are available when building
39+
# [options.extras_require] in project.toml so they are available when building
3840
# the documentation.
3941

4042
extensions = [
@@ -70,7 +72,7 @@
7072
# This pattern also affects html_static_path and html_extra_path.
7173
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
7274

73-
html_title = _meta["name"]
75+
html_title = project
7476

7577
# -- Options for HTML output -------------------------------------------------
7678

@@ -86,7 +88,7 @@
8688
"footer_icons": [
8789
{
8890
"name": "GitHub",
89-
"url": _meta["url"],
91+
"url": url,
9092
"html": """
9193
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
9294
<path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>

pyproject.toml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11
[build-system]
2-
requires = [
3-
"setuptools",
4-
"setuptools-scm",
5-
]
2+
requires = ["setuptools", "setuptools-scm"]
63
build-backend = "setuptools.build_meta"
74

85
[project]
96
name = "fillname"
10-
authors = [
11-
{ name = "Author Fillname", email = "author@fillname.org" }
12-
]
7+
authors = [{ name = "Author Fillname", email = "author@fillname.org" }]
138
description = "A template project."
149
requires-python = ">=3.9"
15-
license = {file = "LICENSE"}
16-
dynamic = [ "version" ]
10+
license = { file = "LICENSE" }
11+
dynamic = ["version"]
1712
readme = "README.md"
1813

1914
[project.urls]
2015
Homepage = "https://fillname.org/"
2116

2217
[project.optional-dependencies]
23-
format = [ "black", "isort", "autoflake" ]
24-
lint_pylint = [ "pylint" ]
25-
typecheck = [ "types-setuptools", "mypy" ]
26-
test = [ "coverage[toml]" ]
27-
doc = [ "sphinx", "furo", "nbsphinx", "sphinx_copybutton", "myst-parser" ]
28-
dev = [ "fillname[test,typecheck,lint_pylint]" ]
18+
format = ["black", "isort", "autoflake"]
19+
lint_pylint = ["pylint"]
20+
typecheck = ["types-setuptools", "mypy"]
21+
test = ["coverage[toml]"]
22+
doc = ["sphinx", "furo", "nbsphinx", "sphinx_copybutton", "myst-parser", "toml"]
23+
dev = ["fillname[test,typecheck,lint_pylint]"]
2924

3025
[project.scripts]
3126
fillname = "fillname.__main__:main"

src/fillname/utils/parser.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,15 @@
22
The command line parser for the project.
33
"""
44

5-
import sys
65
from argparse import ArgumentParser
6+
from importlib import metadata
77
from textwrap import dedent
88
from typing import Any, Optional, cast
99

1010
from . import logging
1111

1212
__all__ = ["get_parser"]
1313

14-
if sys.version_info[1] < 8:
15-
import importlib_metadata as metadata # nocoverage
16-
else:
17-
from importlib import metadata # nocoverage
18-
1914
VERSION = metadata.version("fillname")
2015

2116

0 commit comments

Comments
 (0)