Skip to content

Commit

Permalink
MVP (#2)
Browse files Browse the repository at this point in the history
* MVP

Signed-off-by: GitHub <[email protected]>

* Setup Trusted Publishing

Signed-off-by: GitHub <[email protected]>

* Copy/paste typo

Signed-off-by: GitHub <[email protected]>

---------

Signed-off-by: GitHub <[email protected]>
  • Loading branch information
shenanigansd authored Aug 13, 2024
1 parent 13406aa commit cd4cf4c
Show file tree
Hide file tree
Showing 23 changed files with 580 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"image": "mcr.microsoft.com/devcontainers/universal:2",
"features": {
"ghcr.io/devcontainers/features/python:1": {
"version": "3.12",
"installTools": false
}
}
}
19 changes: 19 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
groups:
ci-dependencies:
patterns:
- "*"

- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "monthly"
groups:
python-dependencies:
patterns:
- "*"
20 changes: 20 additions & 0 deletions .github/workflows/dependency-review.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Dependency Review"

on:
pull_request:

permissions:
contents: read

jobs:
dependency-review:
runs-on: ubuntu-latest

steps:
- name: "Checkout Repository"
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: "Dependency Review"
uses: actions/dependency-review-action@5a2ce3f5b92ee19cbb1541a4984c76d921601d7c # v4.3.4
with:
config-file: darbiadev/.github/.github/dependency-review-config.yaml@main
38 changes: 38 additions & 0 deletions .github/workflows/python-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "Python CI"

on:
push:
branches:
- main
pull_request:

jobs:
pre-commit:
uses: darbiadev/.github/.github/workflows/generic-precommit.yaml@12e07d61ed37c908baa73f8d5550281b3ed9cddd # v13.1.2

lint:
needs: pre-commit
uses: darbiadev/.github/.github/workflows/python-lint.yaml@12e07d61ed37c908baa73f8d5550281b3ed9cddd # v13.1.2

test:
needs: lint
strategy:
matrix:
os: [ ubuntu-latest ]
python-version: [ "3.12" ]

uses: darbiadev/.github/.github/workflows/python-test.yaml@12e07d61ed37c908baa73f8d5550281b3ed9cddd # v13.1.2
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
secrets:
codecov-token: ${{ secrets.CODECOV_TOKEN }}

docs:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

uses: darbiadev/.github/.github/workflows/github-pages-python-sphinx.yaml@12e07d61ed37c908baa73f8d5550281b3ed9cddd # v13.1.2
63 changes: 63 additions & 0 deletions .github/workflows/python-publish-pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: "Publish Python 🐍 distributions 📦 to PyPI"

on:
release:
types: [published]

jobs:
build:
name: "Build distribution 📦"
runs-on: ubuntu-latest

steps:
- name: "Checkout repository"
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: "Set up Python 3.x"
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: "3.x"
cache: "pip"
cache-dependency-path: "pyproject.toml"

- name: "Install pypa/build"
run: >-
python -m
pip install
build
--user
- name: "Build a binary wheel and a source tarball"
run: >-
python -m
build
--outdir dist/
- name: "Upload packages"
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: "Publish Python 🐍 distribution 📦 to PyPI"
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/crazylibs/${{ github.ref_name }}
permissions:
id-token: write

steps:
- name: "Download dists"
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: python-package-distributions
path: dist/

- name: "Publish distribution 📦 to PyPI"
uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14
with:
verbose: true
print-hash: true
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# JetBrains
.idea

# Enviorment
venv

# Packaging
*.egg-info
dist
build

# Cache
__pycache__

# Docs
docs/build

# Test data
/*.xlsx
/*.csv
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-case-conflict
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: check-json
- id: trailing-whitespace
args: [ --markdown-linebreak-ext=md ]
- id: mixed-line-ending
args: [ --fix=lf ]
- id: end-of-file-fixer
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# crazylibs

A variation of the "Mad Libs" games
20 changes: 20 additions & 0 deletions docs/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 = source
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)
35 changes: 35 additions & 0 deletions docs/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=source
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
5 changes: 5 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Changelog
=========

- :release:`0.1.0 <13th August 2024>`
- :feature:`1` Initialize package
93 changes: 93 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
"""Configuration file for the Sphinx documentation builder.
For the full list of built-in configuration values, see the documentation:
https://www.sphinx-doc.org/en/master/usage/configuration.html
"""

from importlib.metadata import metadata

project_metadata = metadata("crazylibs")
project: str = project_metadata["Name"]
release: str = project_metadata["Version"]
REPO_LINK: str = project_metadata["Project-URL"].replace("repository, ", "")
copyright: str = "Let's build a ..." # noqa: A001
author: str = "Let's build a ... community"

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named "sphinx.ext.*") or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.linkcode",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
"autoapi.extension",
"releases",
]

autoapi_type: str = "python"
autoapi_dirs: list[str] = ["../../src"]

intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}

# Add any paths that contain templates here, relative to this directory.
templates_path: list[str] = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns: list[str] = ["_build", "Thumbs.db", ".DS_Store"]

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme: str = "furo"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path: list[str] = ["_static"]

releases_github_path = REPO_LINK.removeprefix("https://github.com/")
releases_release_uri = f"{REPO_LINK}/releases/tag/v%s"


def linkcode_resolve(domain: str, info: dict) -> str:
"""linkcode_resolve."""
if domain != "py":
return None
if not info["module"]:
return None

import importlib
import inspect
import types

mod = importlib.import_module(info["module"])

val = mod
for k in info["fullname"].split("."):
val = getattr(val, k, None)
if val is None:
break

filename = info["module"].replace(".", "/") + ".py"

if isinstance(
val,
types.ModuleType
| types.MethodType
| types.FunctionType
| types.TracebackType
| types.FrameType
| types.CodeType,
):
try:
lines, first = inspect.getsourcelines(val)
last = first + len(lines) - 1
filename += f"#L{first}-L{last}"
except (OSError, TypeError):
pass

return f"{REPO_LINK}/blob/main/src/{filename}"
25 changes: 25 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
crazylibs
=========

A variation of the "Mad Libs" games

Module Index
------------

.. toctree::
:maxdepth: 1

autoapi/index

.. toctree::
:caption: Other:
:hidden:

changelog

Extras
------

* :ref:`genindex`
* :ref:`search`
* :doc:`changelog`
Loading

0 comments on commit cd4cf4c

Please sign in to comment.