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

Pull Sphinx fields from metadata rather than pyproject.toml #29

Merged
merged 1 commit into from
Dec 31, 2022
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
4 changes: 4 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 0.1.18 unreleased

* Pull Sphinx fields from metadata rather than parsing pyproject.toml.

Version 0.1.17 30 Dec 2022

* Convert to latest readthedocs.io standard.
Expand Down
52 changes: 33 additions & 19 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,34 @@
import os
import sys
from pathlib import Path

import toml
from importlib_metadata import metadata

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('.'))

# Insert uciparse path into the system.
# Insert the source tree into the system path
sys.path.insert(0, os.path.abspath("../src"))
sys.path.insert(0, os.path.abspath("_themes"))

# Pull metadata from the pyproject.toml file
metadata = toml.load(Path(__file__).parent.parent / "pyproject.toml")["tool"]["poetry"]
# Configure the GitHub repository
GITHUB_OWNER = "pronovic"
GITHUB_REPO = "uci-parse"

# Configure attributes based on metadata
_METADATA = metadata("uciparse")
PROJECT = _METADATA["Name"]
SUMMARY = _METADATA["Summary"]
AUTHOR = _METADATA["Author"]
VERSION = _METADATA["Version"]

# Dump metadata so it's obvious in the build log
print("GitHub repo: %s/%s" % (GITHUB_OWNER, GITHUB_REPO))
print("Project....: %s" % PROJECT)
print("Summary....: %s" % SUMMARY)
print("Author.....: %s" % AUTHOR)
print("Version....: %s" % VERSION)

# -- General configuration ------------------------------------------------

Expand Down Expand Up @@ -81,18 +95,18 @@
master_doc = "index"

# General information about the project.
project = "UCI Parse"
copyright = "2020-2021 Kenneth J. Pronovici"
author = "Kenneth J. Pronovici"
project = PROJECT
copyright = "(c) %s" % AUTHOR
author = AUTHOR

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = metadata["version"]
version = VERSION
# The full version, including alpha/beta/rc tags.
release = metadata["version"]
release = VERSION

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down Expand Up @@ -149,8 +163,8 @@
# documentation.
html_theme_options = {
"show_powered_by": False,
"github_user": "pronovic",
"github_repo": "uciparse",
"github_user": GITHUB_OWNER,
"github_repo": GITHUB_REPO,
"github_banner": True,
"show_related": False,
"note_bg": "#FFF59C",
Expand Down Expand Up @@ -241,7 +255,7 @@
# html_search_scorer = 'scorer.js'

# Output file base name for HTML help builder.
htmlhelp_basename = "UCIParseDoc"
htmlhelp_basename = PROJECT

# -- Options for LaTeX output ---------------------------------------------

Expand All @@ -259,7 +273,7 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [(master_doc, "UCIParse.tex", "UC Parse Documentation", "Kenneth J. Pronovici", "manual")]
latex_documents = [(master_doc, "%s.tex" % PROJECT, "%s Documentation" % PROJECT, AUTHOR, "manual")]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
Expand All @@ -286,7 +300,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, "uciparse", "UCI Parse Documentation", [author], 1)]
man_pages = [(master_doc, PROJECT, "%s Documentation" % PROJECT, [author], 1)]

# If true, show URL addresses after external links.
# man_show_urls = False
Expand All @@ -300,11 +314,11 @@
texinfo_documents = [
(
master_doc,
"UCI Parse",
"UCI Parse Documentation",
PROJECT,
"%s Documentation" % PROJECT,
author,
"UCI Parse",
"Python library to parse and emit OpenWRT uci config files",
PROJECT,
SUMMARY,
"Miscellaneous",
)
]
Expand Down
16 changes: 2 additions & 14 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ ucidiff = "uciparse.cli:diff"

[tool.poetry.dependencies]
python = ">=3.7.2,<4"
importlib-metadata = { version="^5.2.0", optional=true }
sphinx = { version="^4.5.0", optional=true }
sphinx-autoapi = { version="^1.8.4", optional=true }
toml = { version="^0.10.2", optional=true }

[tool.poetry.extras]
docs = [ "sphinx", "sphinx-autoapi", "toml" ]
docs = [ "importlib-metadata", "sphinx", "sphinx-autoapi" ]

[tool.poetry.group.dev.dependencies]
pytest = "^7.1.2"
Expand Down