Skip to content
Merged
Show file tree
Hide file tree
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
84 changes: 52 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
python -m venv env
source env/bin/activate
pip install --upgrade pip
pip install .
pip install ".[test]"

# Run a basic command to check installation
- name: Check installation
Expand All @@ -55,42 +55,62 @@ jobs:
pytest .
env:
CI: true

# Linting job
lint:
runs-on: ubuntu-latest

- name: Test docs build
run: |
pip install ".[docs]"
sphinx-apidoc -o docs src/app
cd docs
make clean
make html
cd ..
ls docs/_build/html/index.html

# Static analysis
static-analysis:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
- name: Checkout the code
uses: actions/checkout@v4

# Set up Python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Download and run cloc
run: |
curl -s https://raw.githubusercontent.com/AlDanial/cloc/master/cloc > cloc
chmod +x cloc
./cloc --version
./cloc $(git ls-files)

# Cache pip dependencies
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Code formatting with black
run: |
pip install black
pip install "black[jupyter]"
black --check src/

# Install linting tools
- name: Install linting tools
- name: Code formatting with isort
run: |
python -m venv env
source env/bin/activate
pip install --upgrade pip
pip install black isort
pip install isort
isort --check src/

# Code formatting check with black and isort
- name: Run linters
- name: Code formatting with prospector
continue-on-error: true
run: |
source env/bin/activate
black --check src/
isort --check src/
pip install mypy
mypy src/

- name: Code formatting with prospector
continue-on-error: true
run: |
pip install prospector
prospector src/

- name: Code formatting with ruff
continue-on-error: true
run: |
pip install ruff
ruff check src/

- name: Code formatting with pylint
continue-on-error: true
run: |
pip install pylint
pylint src/
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 = .
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)
54 changes: 54 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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
import os
import sys

# sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath("../src/app"))


# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "python-template"
copyright = "2025, Max"
author = "Max"

# The full version, including alpha/beta/rc tags
release = "1.0.0"


# -- General configuration ---------------------------------------------------

# 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.viewcode",
"sphinx.ext.napoleon",
# 'myst_parser',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_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 = ["_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 = "sphinx_rtd_theme"

# 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 = ["_static"]
17 changes: 17 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.. python-template documentation master file, created by
sphinx-quickstart on Sun Apr 20 11:40:45 2025.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

python-template documentation
=============================

Add your content using ``reStructuredText`` syntax. See the
`reStructuredText <https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html>`_
documentation for details.


.. toctree::
:maxdepth: 2
:caption: Contents:

7 changes: 7 additions & 0 deletions docs/main.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
main module
===========

.. automodule:: main
:members:
:show-inheritance:
:undoc-members:
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=.
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
7 changes: 7 additions & 0 deletions docs/modules.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
app
===

.. toctree::
:maxdepth: 4

main
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ dev = [
"black",
"isort",
"ruff",
"pytest",
]
# https://medium.com/@pratikdomadiya123/build-project-documentation-quickly-with-the-sphinx-python-2a9732b66594
docs = [
"sphinx",
"sphinx_rtd_theme",
]

[project.urls]
Expand Down
6 changes: 6 additions & 0 deletions src/app/main.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
"""
Main module of the python package.
"""


def main():
"""Main method called from from the command line."""
print("Hello, world")