Skip to content

Commit

Permalink
chore: more checks and cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii committed May 22, 2024
1 parent c56fe3e commit a9838c3
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 52 deletions.
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,29 @@ repos:
exclude: "^tests/roots"
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/tox-dev/pyproject-fmt
rev: "2.0.4"
hooks:
- id: pyproject-fmt

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.4
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
exclude: "$sphinxcontrib/moderncmakedomain/(cmake|colors).py$"
- id: ruff-format
exclude: "$sphinxcontrib/moderncmakedomain/(cmake|colors).py$"

- repo: https://github.com/henryiii/validate-pyproject-schema-store
rev: 2024.05.13
hooks:
- id: validate-pyproject

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.28.4
hooks:
- id: check-dependabot
- id: check-github-workflows
- id: check-readthedocs
6 changes: 4 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import nox
import urllib.request
import re
import urllib.request
from pathlib import Path

import nox

nox.needs_version = ">=2024.3.2"
nox.options.sessions = ["lint", "tests"]
nox.options.default_venv_backend = "uv|virtualenv"


@nox.session
def lint(session: nox.Session) -> None:
"""
Expand Down
113 changes: 68 additions & 45 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,66 +1,89 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

requires = [
"hatchling",
]

[project]
name = "sphinxcontrib-moderncmakedomain"
description = "Sphinx Domain for Modern CMake"
readme = "README.md"
requires-python = ">=3.7"
authors = [
{ name = "Kitware" },
]
keywords = [
"cmake",
"documentation",
"kitware",
"sphinx",
"sphinxcontrib",
"cmake",
"documentation",
"kitware",
"sphinx",
"sphinxcontrib",
]
authors = [
{ name = "Kitware" },
]
requires-python = ">=3.7"
classifiers = [
"Environment :: Console",
"Environment :: Web Environment",
"Framework :: Sphinx :: Extension",
"Framework :: Sphinx :: Domain",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Documentation",
"Topic :: Utilities",
"Environment :: Console",
"Environment :: Web Environment",
"Framework :: Sphinx :: Domain",
"Framework :: Sphinx :: Extension",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Documentation",
"Topic :: Utilities",
]
dynamic = [
"version",
]
dependencies = ["sphinx>=2"]
dynamic = ["version"]

[project.urls]
Homepage = "https://github.com/scikit-build/moderncmakedomain"
dependencies = [
"sphinx>=2",
]
optional-dependencies.test = [
"defusedxml",
# Setuptools is required due to sphinx installing sphinxcontrib extensions that use pkg_resources (fixed upstream but not released yet)
"pytest",
]
urls.Homepage = "https://github.com/scikit-build/moderncmakedomain"

[project.optional-dependencies]
test = [
# Setuptools is required due to sphinx installing sphinxcontrib extensions that use pkg_resources (fixed upstream but not released yet)
"pytest",
"defusedxml",
[tool.hatch]
version.path = "sphinxcontrib/moderncmakedomain/__init__.py"
build.targets.wheel.packages = [
"sphinxcontrib",
]

[tool.ruff]
exclude = [
"sphinxcontrib/moderncmakedomain/cmake.py",
"sphinxcontrib/moderncmakedomain/colors.py",
]
lint.extend-select = [
"B", # flake8-bugbear
"RUF", # Ruff-specific
"I", # isort
"UP", # pyupgrade
]

[tool.pytest.ini_options]
minversion = "6.0"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
addopts = [
"-ra",
"--showlocals",
"--strict-markers",
"--strict-config",
]
xfail_strict = true
filterwarnings = [
"error",
"ignore::DeprecationWarning:sphinx.builders.gettext",
"error",
"ignore::DeprecationWarning:sphinx.builders.gettext",
]
log_cli_level = "info"
testpaths = ["tests"]

[tool.hatch]
version.path = "sphinxcontrib/moderncmakedomain/__init__.py"
build.targets.wheel.packages = ["sphinxcontrib"]
testpaths = [
"tests",
]
2 changes: 2 additions & 0 deletions sphinxcontrib/moderncmakedomain/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from .cmake import setup

__version__ = "3.27.0"

__all__ = ["__version__", "setup"]
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import pytest

import sys

import pytest

if sys.version_info < (3, 8):
from importlib_metadata import version
else:
from importlib.metadata import version

sphinx_vesion = tuple(int(d) for d in version("sphinx").split(".")[:2])

pytest_plugins = 'sphinx.testing.fixtures'
pytest_plugins = "sphinx.testing.fixtures"

if sphinx_vesion < (7, 3):
from sphinx.testing.path import path
Expand Down
6 changes: 5 additions & 1 deletion tests/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest


@pytest.mark.parametrize("parallel", [0, 1, 2])
@pytest.mark.sphinx(
"html",
Expand All @@ -19,6 +20,9 @@ def test_simple_html(app, status, warning, parallel):
with open(str(external_pth), encoding="utf-8") as f:
external = f.read()

print(local)
assert 'href="#variable:MYVAR"' in local
assert 'id="variable:MYVAR"' in local

assert 'id="index-0-command:find_program"' in external
assert "find_program()" in external
assert 'class="xref cmake cmake-command docutils literal notranslate"' in external
3 changes: 2 additions & 1 deletion tests/test_version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Version tests."""

from sphinxcontrib.moderncmakedomain import __version__


def test_version():
"""Test that version has at least 3 parts."""
assert __version__.count('.') >= 2
assert __version__.count(".") >= 2

0 comments on commit a9838c3

Please sign in to comment.