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]>

* Delete __pycache__

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

* Ignore __pycache__

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

* Add first test

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

* Appease the linter

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

* Setup docs for namespace package

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

---------

Signed-off-by: GitHub <[email protected]>
  • Loading branch information
shenanigansd authored Oct 7, 2023
1 parent fe8e0ef commit 9de0d3c
Show file tree
Hide file tree
Showing 29 changed files with 957 additions and 10 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.11"
},
"ghcr.io/devcontainers/features/powershell:1": {}
}
}
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@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0

- name: "Dependency Review"
uses: actions/dependency-review-action@6c5ccdad469c9f8a2996bfecaec55a631a347034 # v3.1.0
with:
config-file: darbiadev/.github/.github/dependency-review-config.yaml@f85fb2104404526f99de918714364ad1d5449f5a # v1.1.3
36 changes: 36 additions & 0 deletions .github/workflows/python-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "Python CI"

on:
push:
branches:
- main
pull_request:

jobs:
pre-commit:
uses: darbiadev/.github/.github/workflows/generic-precommit.yaml@068870f051676db9e2651013f7c7196ffdaeadaa # v2.0.0

lint:
needs: pre-commit
uses: darbiadev/.github/.github/workflows/python-lint.yaml@068870f051676db9e2651013f7c7196ffdaeadaa # v2.0.0

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

uses: darbiadev/.github/.github/workflows/python-test.yaml@068870f051676db9e2651013f7c7196ffdaeadaa # v2.0.0
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}

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@068870f051676db9e2651013f7c7196ffdaeadaa # v2.0.0
49 changes: 49 additions & 0 deletions .github/workflows/python-publish-pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: "Publish Python 🐍 distributions 📦 to PyPI"

on:
release:
types: [published]

jobs:
build-publish:
name: "Build and publish Python 🐍 distributions 📦 to PyPI"
runs-on: ubuntu-latest
permissions:
id-token: write

steps:
- name: "Checkout repository"
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0

- name: "Set up Python 3.x"
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.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@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: packages
path: dist

- name: "Publish distribution 📦 to PyPI"
uses: pypa/gh-action-pypi-publish@b7f401de30cb6434a1e19f805ff006643653240e # v1.8.10
with:
skip-existing: true
verbose: true
print-hash: true
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
# JetBrains
.idea

# Packaging
*.egg-info
dist

# Cache
__pycache__

# Docs
docs/build
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.4.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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Bradley Reynolds
Copyright (c) 2022 Darbia

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
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 <7th October 2023>`
- :feature:`1` Initialize package
95 changes: 95 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
"""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("darbiadev-sands")
project: str = project_metadata["Name"]
release: str = project_metadata["Version"]
REPO_LINK: str = project_metadata["Project-URL"].replace("repository, ", "")
copyright: str = "Darbia, 2023" # noqa: A001
author: str = "Bradley Reynolds"

# 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_add_toctree_entry: bool = False
autoapi_python_use_implicit_namespaces: bool = True
autoapi_dirs: list[str] = ["../../src/darbia/"]

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 @@
darbiadev-sands
===============

A wrapper for S&S' API.

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

.. toctree::
:maxdepth: 1

autoapi/darbia/sns/index

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

changelog

Extras
------

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

0 comments on commit 9de0d3c

Please sign in to comment.