diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..19f50e0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,78 @@ +name: CI +on: + push: + pull_request: + schedule: + - cron: '0 6 * * 6' +defaults: + run: + shell: bash +jobs: + test: + strategy: + fail-fast: false + matrix: + include: + - python: '^3.10' + os: macos-latest + - python: '3.10' + os: windows-latest + - python: 3.9 + os: ubuntu-latest + - python: 3.8 + os: macos-latest + - python: 3.7 + os: windows-latest + - python: 3.7 + os: ubuntu-latest + versions: minimal + runs-on: ${{matrix.os}} + steps: + - name: Download source + uses: actions/checkout@v3 + - name: Install Python + uses: actions/setup-python@v4 + with: + python-version: ${{matrix.python}} + - name: Pin to lowest versions + if: matrix.versions == 'minimal' + run: | + sed -i -E 's/#min //; s/\b >=([0-9])/ ==\1/' pyproject.toml + - name: Install Hatch + run: | + pip install hatch + - name: Install dependencies + run: | + hatch run test:pip freeze + - name: Run tests + run: | + hatch run test:test + style: + runs-on: ubuntu-latest + steps: + - name: Download source + uses: actions/checkout@v3 + - name: Install Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Install Hatch + run: | + pip install hatch + - name: Install dependencies + run: | + hatch run style:pip freeze + hatch run types:pip freeze + - name: Check style + if: always() + run: | + hatch run style:fix + - name: Check formatting + if: always() + run: | + hatch run style:format + git diff --color --exit-code + - name: Check types + if: always() + run: | + hatch run types:check diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 085ea30..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- -name: Tests - -on: - push: - branches: ["master"] - pull_request: - branches: ["master"] - -jobs: - tests: - name: "Python ${{ matrix.python-version }}" - runs-on: "ubuntu-latest" - - strategy: - matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] - - steps: - - uses: "actions/checkout@v2" - - uses: "actions/setup-python@v2" - with: - python-version: "${{ matrix.python-version }}" - - uses: "actions/cache@v2" - with: - path: ~/.pip/cache - key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - ${{ runner.os }}- - - - name: "Install dependencies" - run: scripts/install - - name: "Run tests" - run: scripts/test diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 754a2f9..6378a11 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,7 +22,7 @@ scripts/install You can run the example docs site that lives in `example/` locally using: ```bash -scripts/docs serve +hatch run docs:mkdocs serve ``` ## Testing and linting @@ -30,19 +30,13 @@ scripts/docs serve Once dependencies are installed, you can run the test suite using: ```bash -scripts/test +hatch run test ``` -You can run code auto-formatting using: +You can run code auto-formatting and style checks using: ```bash -scripts/format -``` - -To run style checks, use: - -```bash -scripts/style +hatch run style:fix ``` ## Releasing diff --git a/example/index.md b/example/docs/index.md similarity index 100% rename from example/index.md rename to example/docs/index.md diff --git a/mkdocs.yml b/example/mkdocs.yml similarity index 92% rename from mkdocs.yml rename to example/mkdocs.yml index 3265c43..ebbad69 100644 --- a/mkdocs.yml +++ b/example/mkdocs.yml @@ -3,8 +3,6 @@ site_name: mkdocs-click example theme: readthedocs -docs_dir: example - markdown_extensions: - attr_list - mkdocs-click diff --git a/pyproject.toml b/pyproject.toml index 75f4dce..8de03f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,48 +7,126 @@ name = "mkdocs-click" description = "An MkDocs extension to generate documentation for Click command line applications" readme = "README.md" license = "Apache-2.0" -requires-python = ">=3.7" +keywords = ["click", "datadog", "mkdocs", "mkdocs-plugin"] authors = [ - { name = "Datadog", email = "packages@datadoghq.com" }, -] -keywords = [ - "click", - "datadog", - "mkdocs", + {name = "Datadog", email = "packages@datadoghq.com"}, ] classifiers = [ "Development Status :: 4 - Beta", + "Environment :: Console", + "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", - "Programming Language :: Python :: 3", + "Programming Language :: Python", "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", + "Topic :: Documentation", + "Topic :: Software Development :: Documentation", + "Topic :: Text Processing :: Markup :: Markdown", + "Typing :: Typed", ] +dynamic = ["version"] +requires-python = ">=3.7" dependencies = [ - "click~=8.1", - "markdown==3.*", + "click >=8.1", + "markdown >=3.0", ] -dynamic = ["version"] + +[project.urls] +Source = "https://github.com/mkdocs/mkdocs-click" +Issues = "https://github.com/mkdocs/mkdocs-click/issues" +Changelog = "https://github.com/mkdocs/mkdocs-click/blob/master/CHANGELOG.md" [project.entry-points."markdown.extensions"] mkdocs-click = "mkdocs_click:MKClickExtension" -[project.urls] -Homepage = "https://github.com/DataDog/mkdocs-click" -Changelog = "https://github.com/DataDog/mkdocs-click/blob/master/CHANGELOG.md" - [tool.hatch.version] path = "mkdocs_click/__version__.py" [tool.hatch.build.targets.sdist] -include = [ - "/mkdocs_click", - "/CHANGELOG.md", +include = ["/mkdocs_click", "/CHANGELOG.md", "/tests"] + +[tool.hatch.envs.default.scripts] +all = [ + "hatch run style:fix", + "hatch run types:check", + "hatch run test:test", +] + +[tool.hatch.envs.test] +dependencies = [ + "pytest", + "mkdocs >=1.1.2", +] +[tool.hatch.envs.test.scripts] +test = [ + "pytest -q", + "mkdocs build -q --strict -f example/mkdocs.yml", +] + +[tool.hatch.envs.types] +dependencies = [ + "mypy", + "types-Markdown >=3.4.2", +] +[tool.hatch.envs.types.scripts] +check = [ + "mypy mkdocs_click" +] + +[tool.hatch.envs.style] +skip-install = true +dependencies = [ + "ruff", + "isort", + "black", +] +[tool.hatch.envs.style.scripts] +fix = [ + "ruff check --fix mkdocs_click tests", + "format", +] +format = [ + "isort -q mkdocs_click tests", + "black -q mkdocs_click tests", ] [tool.black] line-length = 120 -target-version = ["py37"] + +[tool.isort] +profile = "black" +line_length = 120 + +[tool.ruff] +select = [ + "F", "W", "E", "UP", "YTT", "C4", "FA", "PIE", "T20", "RSE", "TCH", "DTZ", + "B002", "B003", "B005", "B007", "B009", "B012", "B013", "B014", "B015", "B018", "B020", "B021", "B023", "B026", "B033", "B034", "B905", + "COM818", + "PERF101", + "PGH002", "PGH004", "PGH005", + "PLE", "PLW0120", "PLW0127", + "RUF001", "RUF007", "RUF010", "RUF100", "RUF200", + "SIM101", "SIM107", "SIM201", "SIM202", "SIM208", "SIM210", "SIM211", "SIM300", "SIM401", "SIM910", +] +ignore = ["E501", "E731"] +[tool.ruff.flake8-comprehensions] +allow-dict-calls-with-keyword-arguments = true + +[tool.mypy] +disallow_untyped_defs = true +ignore_missing_imports = true +warn_unreachable = true +no_implicit_optional = true +show_error_codes = true + +[tool.pytest.ini_options] +addopts = "--tb=native" +enable_assertion_pass_hook = true +filterwarnings = ["ignore::DeprecationWarning:.*:", + "default::DeprecationWarning:mkdocs_click.*:"] +testpaths = ["tests"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 59773a6..0000000 --- a/requirements.txt +++ /dev/null @@ -1,18 +0,0 @@ --e . - -# Packaging -twine -build - -# Linters -black==22.3.0 -flake8==3.8.4 - -# Type checking -mypy==0.950 -types-Markdown - -# Testing -mock==4.0.2 -pytest==7.1.2 -pytest-cov==3.0.0 diff --git a/scripts/build b/scripts/build deleted file mode 100755 index 5b2ded4..0000000 --- a/scripts/build +++ /dev/null @@ -1,8 +0,0 @@ -#! /bin/sh -e - -BIN="venv/bin/" - -set -x - -${BIN}python -m build -${BIN}twine check dist/* diff --git a/scripts/docs b/scripts/docs deleted file mode 100755 index a5685f6..0000000 --- a/scripts/docs +++ /dev/null @@ -1,7 +0,0 @@ -#! /bin/sh -e - -BIN="venv/bin/" - -set -x - -${BIN}mkdocs "$@" diff --git a/scripts/format b/scripts/format deleted file mode 100755 index e360bc8..0000000 --- a/scripts/format +++ /dev/null @@ -1,8 +0,0 @@ -#! /bin/sh -e - -BIN="venv/bin/" -FILES="mkdocs_click tests" - -set -x - -${BIN}black $FILES diff --git a/scripts/install b/scripts/install deleted file mode 100755 index 3e875c6..0000000 --- a/scripts/install +++ /dev/null @@ -1,11 +0,0 @@ -#! /bin/sh -e - -VENV="venv" -BIN="$VENV/bin/" - -set -x - -python3 -m venv $VENV - -${BIN}pip install -U pip -${BIN}pip install -r requirements.txt diff --git a/scripts/publish b/scripts/publish deleted file mode 100755 index c4e878d..0000000 --- a/scripts/publish +++ /dev/null @@ -1,17 +0,0 @@ -#! /bin/sh -e - -PACKAGE="mkdocs_click" -BIN="venv/bin/" - -if [ "$GITHUB_ACTIONS" ]; then - VERSION=`${BIN}python -c "import $PACKAGE; print($PACKAGE.__version__)"` - - if [ "${GITHUB_REF}" != "refs/tags/${VERSION}" ]; then - echo "GitHub ref '${GITHUB_REF}' does not match package version '${VERSION}'" - exit 1 - fi -fi - -set -x - -${BIN}twine upload dist/* diff --git a/scripts/style b/scripts/style deleted file mode 100755 index 4b1637e..0000000 --- a/scripts/style +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/sh -e - -BIN="venv/bin/" -FILES="mkdocs_click tests" - -set -x - -${BIN}black --check --diff $FILES -${BIN}flake8 $FILES -${BIN}mypy $FILES diff --git a/scripts/test b/scripts/test deleted file mode 100755 index 558b78f..0000000 --- a/scripts/test +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/sh -e - -VENV="venv" -BIN="$VENV/bin/" - -set -x - -${BIN}pytest "$@" - -scripts/style diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index b0e9cf4..0000000 --- a/setup.cfg +++ /dev/null @@ -1,19 +0,0 @@ -[flake8] -ignore = E203,E722,E741,W503 -max-line-length = 120 - -[mypy] -disallow_untyped_defs = True -ignore_missing_imports = True - -[mypy-tests.*] -disallow_untyped_defs = False -check_untyped_defs = True - -[tool:pytest] -addopts = - -rxXs - --cov=mkdocs_click - --cov=tests - --cov-report=term-missing - --cov-fail-under=95