Skip to content

Commit

Permalink
Re-template ablog and use ruff more widely (#271)
Browse files Browse the repository at this point in the history
* Retemplate + ruff

* changelog for 0.12

* fix circle

* removed old templates

* add defusedxml
  • Loading branch information
nabobalis authored Apr 18, 2024
1 parent 2e3ac8d commit a85a561
Show file tree
Hide file tree
Showing 60 changed files with 644 additions and 1,288 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ version: 2
jobs:
twine-check:
docker:
- image: circleci/python:3.8
- image: cimg/python:3.12
steps:
- checkout
- run: python setup.py sdist
- run: python -m pip install -U --user --force-reinstall twine
- run: python -m pip install -U --user build
- run: python -m build . --sdist
- run: python -m pip install -U --user twine
- run: python -m twine check dist/*

workflows:
version: 2
twine-check:
Expand Down
8 changes: 8 additions & 0 deletions .codecov.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
codecov:
token: a0dfd87f-8eb9-4a41-9e4e-a06919f216cd
comment: off
coverage:
status:
project:
default:
threshold: 0.2%
33 changes: 15 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ name: CI
on:
push:
branches:
- 'main'
- '*.*'
- '!*backport*'
- "main"
- "*.*"
- "!*backport*"
tags:
- 'v*'
- '!*dev*'
- '!*pre*'
- '!*post*'
- "v*"
- "!*dev*"
- "!*pre*"
- "!*post*"
pull_request:
workflow_dispatch:
schedule:
# ┌───────── minute (0 - 59)
# │ ┌───────── hour (0 - 23)
# │ │ ┌───────── day of the month (1 - 31)
# │ │ │ ┌───────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────── day of the week (0 - 6 or SUN-SAT)
- cron: '0 7 * * *' # Every day at 07:00 UTC
# ┌───────── minute (0 - 59)
# │ ┌───────── hour (0 - 23)
# │ │ ┌───────── day of the month (1 - 31)
# │ │ │ ┌───────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────── day of the week (0 - 6 or SUN-SAT)
- cron: "0 7 * * *" # Every day at 07:00 UTC

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -57,17 +57,15 @@ jobs:
- pandoc
- graphviz
envs: |
- linux: py311-sphinx6
- macos: py310-sphinx5
- windows: py39-sphinx5
- macos: py311-sphinx6
- windows: py310-sphinx6
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

docs:
needs: [test]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
with:
default_python: '3.9'
submodules: false
pytest: false
envs: |
Expand All @@ -77,7 +75,6 @@ jobs:
needs: [test]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
with:
default_python: '3.9'
submodules: false
coverage: codecov
libraries: |
Expand Down
32 changes: 16 additions & 16 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -U --user --force-reinstall pep517 setuptools_scm twine
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python -m pep517.build --binary --source --out-dir wheelhouse .
python -m twine upload --skip-existing wheelhouse/*
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -U --user --force-reinstall pep517 setuptools_scm twine
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python -m pep517.build --binary --source --out-dir wheelhouse .
python -m twine upload --skip-existing wheelhouse/*
38 changes: 2 additions & 36 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ instance/
# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

Expand Down Expand Up @@ -138,24 +135,10 @@ Icon

### MacOS: https://raw.githubusercontent.com/github/gitignore/master/Global/macOS.gitignore

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

Expand Down Expand Up @@ -195,28 +178,12 @@ $RECYCLE.BIN/
### VScode: https://raw.githubusercontent.com/github/gitignore/master/Global/VisualStudioCode.gitignore
.vscode/*

### Extra Python Items and SunPy Specific
.hypothesis
.pytest_cache
sunpydata.sqlite
sunpydata.sqlite-journal
sunpy/_compiler.c
sunpy/cython_version.py
docs/_build
docs/generated
docs/api/
docs/whatsnew/latest_changelog.txt
examples/**/*.asdf
# This is incase you run the figure tests
figure_test_images*
tags

### Pycharm(?)
.idea

# Release script
# Ablog
.github_cache

src/ablog/version.py
docs/_build/
docs/.doctrees/
docs/_website/
Expand All @@ -226,5 +193,4 @@ test/
.history/
pydata-sphinx-theme/
_build
_version.py
demo/
76 changes: 39 additions & 37 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,49 @@
ci:
autofix_prs: false
autoupdate_schedule: "quarterly"
autofix_prs: false
autoupdate_schedule: "quarterly"
repos:
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.1
- repo: https://github.com/myint/docformatter
rev: v1.7.5
hooks:
- id: autoflake
args: ['--in-place', '--remove-all-unused-imports', '--remove-unused-variable']
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
- id: docformatter
args: ["--in-place", "--pre-summary-newline", "--make-summary-multi"]
- repo: https://github.com/myint/autoflake
rev: v2.3.1
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 24.4.0
- id: autoflake
args:
[
"--in-place",
"--remove-all-unused-imports",
"--remove-unused-variable",
]
exclude: ".*(.fits|.fts|.fit|.txt|tca.*|extern.*|.rst|.md|docs/conf.py)$"
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.4.0"
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
- id: ruff
args: ["--fix", "--unsafe-fixes"]
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-ast
- id: check-case-conflict
- id: trailing-whitespace
- id: mixed-line-ending
- id: end-of-file-fixer
- id: check-yaml
- id: debug-statements
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.3.7'
hooks:
- id: ruff
args: ['--fix']
- repo: https://github.com/awebdeveloper/pre-commit-stylelint
rev: '0.0.2'
- id: check-ast
- id: check-case-conflict
- id: trailing-whitespace
exclude: ".*(.fits|.fts|.fit|.txt|.csv)$"
- id: mixed-line-ending
exclude: ".*(.fits|.fts|.fit|.txt|.csv)$"
- id: end-of-file-fixer
exclude: ".*(.fits|.fts|.fit|.txt|.csv)$"
- id: check-yaml
- id: debug-statements
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: stylelint
additional_dependencies: ['[email protected]', '[email protected]']
- repo: https://github.com/pre-commit/mirrors-prettier
- id: codespell
additional_dependencies:
- tomli
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
types_or: [css, scss, javascript]
- repo: https://github.com/Riverside-Healthcare/djLint
rev: v1.34.1
hooks:
- id: djlint-jinja
types_or: ["html"]
- id: prettier
8 changes: 4 additions & 4 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ sphinx:
configuration: docs/conf.py
fail_on_warning: false
python:
install:
- method: pip
extra_requirements:
install:
- method: pip
extra_requirements:
- all
- docs
path: .
path: .
2 changes: 1 addition & 1 deletion .rtd-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: rtd_ablog
channels:
- conda-forge
dependencies:
- python=3.10
- python=3.12
- pip
- graphviz
- make
Expand Down
2 changes: 1 addition & 1 deletion .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "stylelint-config-standard"
"extends": "stylelint-config-standard"
}
10 changes: 4 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
ABlog for Sphinx
================

|Build Status|

.. |Build Status| image:: https://dev.azure.com/sunpy/ablog/_apis/build/status/sunpy.ablog?repoName=sunpy%2Fablog&branchName=main
:target: https://dev.azure.com/sunpy/ablog/_build/latest?definitionId=17&repoName=sunpy%2Fablog&branchName=main
[![CI](https://github.com/sunpy/ablog/actions/workflows/ci.yml/badge.svg)](https://github.com/sunpy/ablog/actions/workflows/ci.yml)
[![Upload Python Package](https://github.com/sunpy/ablog/actions/workflows/pythonpublish.yml/badge.svg)](https://github.com/sunpy/ablog/actions/workflows/pythonpublish.yml)

ABlog is a Sphinx extension that converts any documentation or personal website project into a full-fledged blog

Expand All @@ -19,6 +17,6 @@ The original project is no longer maintained and the `SunPy Project <https://www
Warning
-------

**This version is maintained with the aim to keep it working for SunPy Project website and thus new features or bugfixes are highly unlikely unless they directly impact.**
**This version is maintained with the aim to keep it working for SunPy Project website and thus new features or bugfixes are highly unlikely unless they directly impact the SunPy Project**

**We strongly encourage users and interested in parties in submitting patches to ``ablog``.**
**We strongly encourage users and interested in parties in submitting patches to ``ablog``**
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def rootdir():
return Path(__file__).parent.absolute() / "roots"


@pytest.fixture(scope="function", autouse=True)
@pytest.fixture(autouse=True)
def reset_blog_config():
# Reset cached configurations to enable confoverrides
from ablog.blog import Blog
Expand Down
11 changes: 5 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import re
from pathlib import Path

import ablog
from packaging.version import parse as _parse
from sphinx import addnodes

import ablog

ablog_builder = "dirhtml"
ablog_website = "_website"
extensions = [
Expand All @@ -24,7 +23,7 @@

version = str(_parse(ablog.__version__))
project = "ABlog"
copyright = "2014-2022, ABlog Team"
copyright = "2014-2022, ABlog Team" # NOQA: A001
master_doc = "index"
source_suffix = {
".rst": "restructuredtext",
Expand Down Expand Up @@ -59,10 +58,10 @@
blog_feed_fulltext = True
blog_feed_templates = {
"atom": {
"content": "{{ title }}{% for tag in post.tags %}" " #{{ tag.name|trim()|replace(' ', '') }}" "{% endfor %}",
"content": "{{ title }}{% for tag in post.tags %} #{{ tag.name|trim()|replace(' ', '') }} {% endfor %}",
},
"social": {
"content": "{{ title }}{% for tag in post.tags %}" " #{{ tag.name|trim()|replace(' ', '') }}" "{% endfor %}",
"content": "{{ title }}{% for tag in post.tags %} #{{ tag.name|trim()|replace(' ', '') }} {% endfor %}",
},
}
disqus_shortname = "https-ablog-readthedocs-io"
Expand All @@ -82,7 +81,7 @@
"ablog/languages.html",
"ablog/locations.html",
"searchbox.html",
]
],
}
html_theme_options = {
"travis_button": False,
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Once you have content (in ``.rst`` files), you can post *any page* using the :rs
:location: SF
:language: en
An alterative method is:
An alternative method is:

.. code-block:: rst
Expand Down
Loading

0 comments on commit a85a561

Please sign in to comment.