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

fix: Update structure and packaging #18

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 0 additions & 7 deletions .flake8

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Unit tests

on:
- push
- pull_request

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: pre-commit/[email protected]

build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: pip install .[test,dev]

- name: Check static typing
run: mypy sphinxcontrib

- name: test with pytest
run: pytest --color=yes --cov --cov-report=xml tests

#- name: coverage
# run: coverage xml
#
#- name: codecov
# uses: codecov/codecov-action@v3
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# verbose: true
10 changes: 3 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ ipython_config.py
# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

Expand Down Expand Up @@ -135,4 +128,7 @@ dmypy.json
# pytype static type analyzer
.pytype/

# ruff
.ruff_cache

# End of https://www.toptal.com/developers/gitignore/api/python
80 changes: 17 additions & 63 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,67 +1,21 @@
default_install_hook_types: [pre-commit]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
- repo: "https://github.com/psf/black"
rev: "22.3.0"
hooks:
- id: check-case-conflict
- id: check-merge-conflict
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: end-of-file-fixer
- id: check-json
- id: check-toml
- id: check-yaml
- id: requirements-txt-fixer
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
- id: black
stages: [commit]

- repo: "https://github.com/pre-commit/mirrors-prettier"
rev: "v2.7.1"
hooks:
- id: prettier
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.2.0
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py37-plus]
## <<< darker ##
## - repo: https://github.com/akaihola/darker
## rev: 1.4.0
## hooks:
## - id: darker
## args: ["--isort"] # TODO: Move to pyproject.toml
## additional_dependencies:
## - isort
## === ##
- repo: https://github.com/PyCQA/isort
rev: 5.11.4
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black # black-jupyter
## >>> black and isort ##
- repo: https://github.com/PyCQA/bandit
rev: 1.7.4
hooks:
- id: bandit
args: [--recursive, --quiet]
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8 # E***, W***, F***
additional_dependencies:
# - dlint # DUO***
- flake8-2020 # YTT***
- flake8-bugbear # B***
- flake8-builtins # A***
- flake8-comprehensions # C4**
- flake8-deprecated # D***
- flake8-variables-names # VNE***
- mccabe # C9**
- pep8-naming # N8**
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v0.790
# hooks:
# - id: mypy
stages: [commit]
exclude: tests\/test_build\/.+\.html$

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.215"
hooks:
- id: ruff
stages: [commit]
1 change: 0 additions & 1 deletion .prettierrc.yaml

This file was deleted.

29 changes: 29 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""All the process that can be run using nox.

The nox run are build in isolated environment that will be stored in .nox. to force the venv update, remove the .nox/xxx folder.
"""

import nox


@nox.session(reuse_venv=True)
def lint(session):
"""Apply the pre-commits."""
session.install("pre-commit")
session.run("pre-commit", "run", "--a", *session.posargs)


@nox.session(reuse_venv=True)
def mypy(session):
"""Run a mypy check of the lib."""
session.install(".[dev]")
test_files = session.posargs or ["sphinxcontrib"]
session.run("mypy", *test_files)


@nox.session(reuse_venv=True)
def test(session):
"""Run all the test using the environment varialbe of the running machine."""
session.install(".[test]")
test_files = session.posargs or ["tests"]
session.run("pytest", "--color=yes", "--cov", "--cov-report=html", *test_files)
79 changes: 69 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,74 @@
[build-system]
requires = [
"setuptools>=45",
"setuptools_scm[toml]>=6.2",
"wheel",
]
requires = ["setuptools>=61.2", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
[project]
name = "sphinxcontrib-email"
version = "0.3.6"
description = "Sphinx email obfuscation extension"
requires-python = ">=3.7"
dependencies = ["sphinx", "lxml>=4.5.2", "importlib_metadata"]
classifiers = [
"Development Status :: 3 - Alpha",
"Environment :: Console",
"Environment :: Web Environment",
"Framework :: Sphinx :: Extension",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Documentation :: Sphinx",
"Topic :: Utilities",
]

[[project.authors]]
name = "Christian Knittl-Frank"
email = "[email protected]"

[project.license]
text = "BSD-3-Clause"

[project.readme]
file = "README.rst"
content-type = "text/x-rst"

[project.urls]
repository = "https://github.com/sphinx-contrib/email"

[project.optional-dependencies]
dev = ["nox", "pre-commit", "mypy"]
test = ["pytest", "beautifulsoup4", "pytest-regressions", "pytest-cov"]

[tool.setuptools]
include-package-data = false
license-files = ["LICENSE"]
packages = ["sphinxcontrib"]

[tool.ruff]
ignore-init-module-imports = true
fix = true
select = ["E", "F", "W", "I", "D", "RUF"]
ignore = ["E501"] # line too long | Black take care of it

[tool.ruff.flake8-quotes]
docstring-quotes = "double"

[tool.ruff.pydocstyle]
convention = "google"

[tool.ruff.per-file-ignores]
"setup.py" = ["D100"] # nothing to see there

[tool.black]
target-version = ["py38", "py39", "py310"]
[tool.coverage.run]
source = ["sphinxcontrib.email"]

[tool.isort]
profile = "black"
[tool.mypy]
scripts_are_modules = true
ignore_missing_imports = true
install_types = true
non_interactive = true
warn_redundant_casts = true
1 change: 0 additions & 1 deletion requirements-dev.txt

This file was deleted.

45 changes: 0 additions & 45 deletions setup.cfg

This file was deleted.

8 changes: 2 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import setuptools
from setuptools import setup

if __name__ == "__main__":
setuptools.setup(
use_scm_version=True,
setup_requires="setuptools-scm>=4.1",
)
setup()
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
"""Provide an email obfuscator for Sphinx-based documentation."""

from typing import Any, Dict

from importlib_metadata import version
from sphinx.application import Sphinx
from sphinx.util import logging

from .handlers import html_page_context_handler
from .roles import EmailRole

try:
from importlib import metadata
except ImportError:
import importlib_metadata as metadata
from .roles import Email

try:
__version__ = metadata.version("sphinxcontrib-email")
except metadata.PackageNotFoundError:
pass
__version__ = version("sphinxcontrib-email")

logger = logging.getLogger("sphinxcontrib-email")


def setup(app: Sphinx) -> Dict[str, Any]:
"""Setup email role parameters."""
app.add_config_value(name="email_automode", default=False, rebuild="env")
app.connect(event="html-page-context", callback=html_page_context_handler)
app.add_role(name="email", role=EmailRole())
app.add_role(name="email", role=Email())

metadata = {
"version": ".".join(__version__.split(".")[:3]),
return {
"version": __version__,
"parallel_read_safe": True,
"parallel_write_safe": True,
}
return metadata
Loading