Skip to content

Commit

Permalink
feat: Initial commit
Browse files Browse the repository at this point in the history
- Run 'rye init'
- Copy personal files
- Configure for namespace package
  • Loading branch information
attakei committed Mar 16, 2024
0 parents commit 8c33618
Show file tree
Hide file tree
Showing 23 changed files with 500 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .age.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
current_version = "0.0.0"

[[files]]
path = "pyproject.toml"
search = "version = \"{{current_version}}\""
replace = "version = \"{{new_version}}\""

[[files]]
path = "src/atsphinx/helpers/__init__.py"
search = "__version__ = \"{{current_version}}\""
replace = "__version__ = \"{{new_version}}\""
70 changes: 70 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Run CI

on:
push:
branches:
- '**'
tags-ignore:
- '**'
pull_request:
workflow_dispatch:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version-file: '.python-version'
- name: Lint by pre-commit
run: |
pip install pre-commit
pre-commit run --all-files
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Configure venv
run: |
pip install uv
uv venv
uv pip install -r requirements-dev.lock
- name: Run tests
run: |
source .venv/bin/activate
pytest
doctest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version-file: '.python-version'
- name: Configure venv
run: |
pip install uv
uv venv
uv pip install -r requirements-dev.lock
- name: Run tests
run: |
source .venv/bin/activate
make -C doc linkcheck dirhtml
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version-file: '.python-version'
- name: Build package
run: |
pip install hatch
hatch build
ls -l dist
86 changes: 86 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: 'Release new version'

on:
push:
tags:
- 'v*.*.*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version-file: '.python-version'
- name: Build package
run: |
pip install hatch
hatch build
ls -l dist
- uses: actions/upload-artifact@v4
with:
name: packages-${{ github.ref_name }}
path: dist/
gh-release:
runs-on: ubuntu-latest
needs: [build]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: packages-${{ github.ref_name }}
path: dist/
- uses: ncipollo/release-action@v1
with:
artifacts: 'dist/*'
bodyFile: 'CHANGESLOG.rst'
draft: false
name: Release ${{ github.ref_name }}
tag: ${{ github.ref }}
prerelease: false
publish-pypi:
runs-on: ubuntu-latest
needs: [build]
if: success() && ${{ needs.prepare.outputs.is-release }}
steps:
- uses: actions/download-artifact@v4
with:
name: packages-${{ github.ref_name }}
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
deploy-doc:
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version-file: '.python-version'
- name: Configure venv
run: |
pip install uv
uv venv
uv pip install -r requirements-dev.lock
- name: Run tests
run: |
source .venv/bin/activate
make -C doc dirhtml
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: doc/_build/dirhtml
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# python generated files
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info

# venv
.venv
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.0
hooks:
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
- repo: https://github.com/PyCQA/doc8
rev: v1.0.0
hooks:
- id: doc8
args:
- --max-line-length=119
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.0
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ver 0.0.0
=========

:date: 2024-03-16 JST
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
================
atsphinx-helpers
================


2 changes: 2 additions & 0 deletions doc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_build
api/
4 changes: 4 additions & 0 deletions doc/.ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extend = "../pyproject.toml"

[lint]
ignore = ["D100", "D103"]
20 changes: 20 additions & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
16 changes: 16 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from atsphinx.helpers import __version__

# -- Project information -----------------------------------------------------
project = "atsphinx-helpers"
copyright = "2024, Kazuya Takei"
author = "Kazuya Takei"
release = __version__

# -- General configuration ---------------------------------------------------
extensions = []
templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# -- Options for HTML output -------------------------------------------------
html_theme = "furo"
html_static_path = ["_static"]
3 changes: 3 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
====
Home
====
35 changes: 35 additions & 0 deletions doc/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
64 changes: 64 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
[project]
name = "atsphinx-helpers"
version = "0.0.0"
description = "Helper for my Sphinx extension"
authors = [
{ name = "Kazuya Takei", email = "[email protected]" }
]
dependencies = [
"sphinx",
]
readme = "README.rst"
requires-python = ">= 3.9"
license = "Apache-2.0"
classifiers = [
"Development Status :: 3 - Alpha",
"Framework :: Sphinx",
"Framework :: Sphinx :: Extension",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Documentation :: Sphinx",
]

[project.urls]
Home = "https://github.com/atsphinx/helpers"
Repository = "https://github.com/atsphinx/helpers"
Issues = "https://github.com/atsphinx/helpers/issues"
Changelog = "https://github.com/atsphinx/helpers/blob/main/CHANGES.rst"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.rye]
managed = true
dev-dependencies = [
"furo~=2024.1.29",
"pytest~=8.0.2",
"sphinx~=7.2.6",
]

[tool.rye.scripts]
setup = {chain = ["setup:sync", "setup:pre-commit"]}
"setup:sync" = "rye sync --no-lock --all-features"
"setup:pre-commit" = "pre-commit install"

[tool.ruff.lint]
select = ["C90", "D", "E", "F", "I", "W"]

[tool.ruff.lint.pydocstyle]
convention = "pep257"

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.wheel]
packages = ["src/atsphinx"]
only-includes = ["src/atsphinx"]
Loading

0 comments on commit 8c33618

Please sign in to comment.