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

Improvements & general refactoring #133

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
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
38 changes: 38 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Lint source code

on:
push:
pull_request:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
FORCE_COLOR: "1"
UV_SYSTEM_PYTHON: "1" # make uv do global installs

jobs:
ruff:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install Ruff
uses: astral-sh/ruff-action@v3
with:
args: --version
version: 0.9.2

- name: Lint with Ruff
run: ruff check --output-format=github

- name: Format with Ruff
run: ruff format --diff
68 changes: 32 additions & 36 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,12 @@
name: Test and Deploy
on:
pull_request:
branches:
- main
push:

env:
FORCE_COLOR: 1
FORCE_COLOR: "1"

jobs:
check:
runs-on: ubuntu-latest

# We want to run on external PRs, but not on our own internal PRs as they'll be run
# by the push to the branch.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: pip
cache-dependency-path: .github/workflows/workflow.yml
- name: Black
run: |
pip install black
black --check --exclude /docs --diff .

build-wheel:
runs-on: ubuntu-latest
steps:
@@ -37,7 +16,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.9"
cache: pip
cache-dependency-path: |
.github/workflows/workflow.yml
@@ -47,7 +26,7 @@ jobs:
set -xe
python -VV
python -m site
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade pip
python -m pip install -r dev-requirements.txt
- name: Install package
run: |
@@ -62,22 +41,39 @@ jobs:
name: my-dist
path: dist/*


test:
needs: build-wheel
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['pypy3.9', '3.8', '3.9', '3.10', '3.11', '3.12']
sphinx-version: ['>=5,<6', '>=6a0,<7', '>=7,<8', '>=8,<9']
os: [windows-latest, macos-latest, ubuntu-latest]
python-version:
- "pypy3.9"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
sphinx-version:
- ">=6,<7"
- ">=7,<8"
- ">=8,<9"
os:
- windows-latest
- macos-latest
- ubuntu-latest
exclude:
- python-version: '3.8'
sphinx-version: '>=8,<9'
- python-version: '3.9'
sphinx-version: '>=8,<9'
- python-version: 'pypy3.9'
sphinx-version: '>=8,<9'
- python-version: "3.9"
sphinx-version: ">=8,<9"
- python-version: "pypy3.9"
sphinx-version: ">=6,<7"
os: "macos-latest"
- python-version: "pypy3.9"
sphinx-version: ">=7,<8"
os: "macos-latest"
- python-version: "pypy3.9"
sphinx-version: ">=8,<9"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
@@ -92,7 +88,7 @@ jobs:
run: |
python -VV
python -m site
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade pip
python -m pip install -r dev-requirements.txt
python -m pip install "sphinx${{ matrix.sphinx-version }}"
- name: Download sdist and wheel artifacts
@@ -108,7 +104,7 @@ jobs:
python -m pytest -vv
- name: Install matplotlib
run: |
python -m pip install matplotlib
python -m pip install --only-binary :all: matplotlib
- name: Run tests with matplotlib for ${{ matrix.python-version }}
run: |
python -m pytest -vv
@@ -122,7 +118,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
python-version: "3"
cache: pip
cache-dependency-path: docs/requirements.txt
- name: Install dependencies
95 changes: 95 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
target-version = "py39" # Pin Ruff to Python 3.9
line-length = 88
output-format = "full"

[format]
quote-style = "double"
docstring-code-format = true

[lint]
select = [
"ANN", # flake8-annotations
"ASYNC", # flake8-async
"B", # flake8-bugbear
"BLE", # flake8-blind-except
"C4", # flake8-comprehensions
"D", # pydocstyle
"D212", # Multi-line docstring summary should start at the first line
"D417", # Missing argument description in the docstring for `{definition}`: `{name}`
"DTZ", # flake8-datetimez
"E", # pycodestyle
"EM", # flake8-errmsg
"EXE", # flake8-executable
"F", # pyflakes
"FA", # flake8-future-annotations
"FIX", # flake8-fixme
"FLY", # flynt
"FURB", # refurb
"G", # flake8-logging-format
"I", # isort
"ICN", # flake8-import-conventions
"INT", # flake8-gettext
"ISC", # flake8-implicit-str-concat
"LOG", # flake8-logging
"N", # pep8-naming
"PERF", # perflint
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PLC", # pylint
"PLE", # pylint
"PLW", # pylint
"PT", # flake8-pytest-style
"PTH", # flake8-use-pathlib
"Q", # flake8-quotes
"RET", # flake8-return
"RSE", # flake8-raise
"RUF", # Ruff-specific rules
"S", # flake8-bandit
"SIM", # flake8-simplify
"SLF", # flake8-self
"SLOT", # flake8-slots
"T10", # flake8-debugger
"TC", # flake8-type-checking
"TD", # flake8-todos
"TID", # flake8-tidy-imports
"TRY", # tryceratops
"UP", # pyupgrade
"W", # pycodestyle
"W", # pycodestyle
"YTT", # flake8-2020
]
ignore = [
# pydocstyle
"D100", # Missing docstring in public module
"D102", # Missing docstring in public method
"D103", # Missing docstring in public function
"D104", # Missing docstring in public package
"D107", # Missing docstring in `__init__`
"D400", # First line should end with a period
# pycodestyle
"E501", # Ignore line length errors (we use auto-formatting)
]

[lint.per-file-ignores]
"tests/*" = [
"ANN", # tests don't need annotations
"S101", # allow use of assert
"SLF001", # allow private member access
]

[lint.flake8-type-checking]
exempt-modules = []
strict = true

[lint.isort]
forced-separate = [
"tests",
]
required-imports = [
"from __future__ import annotations",
]

[lint.pydocstyle]
convention = "pep257"
ignore-decorators = ["typing.overload"]
ignore-var-parameters = true
19 changes: 10 additions & 9 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -3,14 +3,15 @@ All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the FIRST nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the FIRST nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY FIRST AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -21,4 +22,4 @@ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# sphinxext-opengraph

[![Build](https://github.com/wpilibsuite/sphinxext-opengraph/workflows/Test%20and%20Deploy/badge.svg)](https://github.com/wpilibsuite/sphinxext-opengraph/actions)
[![Code style: Black](https://img.shields.io/badge/code%20style-Black-000000.svg)](https://github.com/psf/black)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/format.json)](https://github.com/astral-sh/ruff)

Sphinx extension to generate [Open Graph metadata](https://ogp.me/) for each page of your documentation.

@@ -11,6 +11,12 @@ Sphinx extension to generate [Open Graph metadata](https://ogp.me/) for each pag
python -m pip install sphinxext-opengraph
```

The `matplotlib` package is required to generate social cards:

```sh
python -m pip install sphinxext-opengraph[social_cards]
```

## Usage
Just add `sphinxext.opengraph` to your extensions list in your `conf.py`

@@ -19,6 +25,8 @@ extensions = [
"sphinxext.opengraph",
]
```


## Options
These values are placed in the `conf.py` of your Sphinx project.

3 changes: 1 addition & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
sphinx
wheel==0.43.0
build>=1
pytest==7.4.4
beautifulsoup4==4.12.3
setuptools==70.1.0
8 changes: 4 additions & 4 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
myst-parser==0.18.1
furo==2022.9.29
sphinx==5.2.3
myst-parser>=4
furo>=2024
sphinx~=8.1.0
sphinx-design
./
matplotlib
matplotlib
Loading