Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed documentation to work with project.toml instead of setup.py #48

Merged
merged 4 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,12 @@ Run the following for basic usage information:
```bash
fillname -h
```

To generate and open the documentation, run

```bash
nox -s doc -- open
```

Instructions to install and use `nox` can be found in
[DEVELOPMENT.md](./DEVELOPMENT.md)
24 changes: 13 additions & 11 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]])
rkaminsk marked this conversation as resolved.
Show resolved Hide resolved
url = toml_config["project"]["urls"]["Homepage"]
copyright = f'{datetime.datetime.now().date().strftime("%Y")}, {author}'
rkaminsk marked this conversation as resolved.
Show resolved Hide resolved

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 = [
Expand Down Expand Up @@ -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 -------------------------------------------------

Expand All @@ -86,7 +88,7 @@
"footer_icons": [
{
"name": "GitHub",
"url": _meta["url"],
"url": url,
"html": """
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
<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>
Expand Down
25 changes: 10 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]" }
]
authors = [{ name = "Author Fillname", email = "[email protected]" }]
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"
Expand Down
7 changes: 1 addition & 6 deletions src/fillname/utils/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@
The command line parser for the project.
"""

import sys
from argparse import ArgumentParser
from importlib import metadata
from textwrap import dedent
from typing import Any, Optional, cast

from . import logging

__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")


Expand Down