Skip to content

Commit

Permalink
Add mypy and test coverage reports for docs. (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
huxuan authored Aug 8, 2023
1 parent e3ea837 commit 4494f8a
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Upload pages artifact
uses: actions/upload-pages-artifact@v2
with:
path: public
path: public/html
- id: deployment
name: Deploy to GitHub Pages
uses: actions/deploy-pages@v2
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ package:
pages:
artifacts:
paths:
- public
- public/html
except:
refs:
- schedules
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ package:
pages:
artifacts:
paths:
- public
- public/html
except:
refs:
- schedules
Expand Down
10 changes: 4 additions & 6 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ build:
os: ubuntu-22.04
tools:
python: '3'
python:
install:
- extra_requirements:
- docs
method: pip
path: .
commands:
- pip install --upgrade pip
- make dev-docs
- make docs
version: 2
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Construct pipenv run command with or without site-packages flag when not in CI environment and pipenv command exists.
SITE_PACKAGES_FLAG = $(shell [ "${SS_SITE_PACKAGES}" = "true" ] && echo --site-packages)
PIPRUN := $(shell [ "${CI}" != "true" ] && command -v pipenv > /dev/null 2>&1 && echo pipenv ${SITE_PACKAGES_FLAG} run)
PUBLIC_DIR := $(or $(READTHEDOCS_OUTPUT),public)

# Remove common intermediate files.
clean:
Expand All @@ -15,7 +16,7 @@ clean:
Pipfile* \
coverage.xml \
dist \
public
$(PUBLIC_DIR)
find . -name '*.egg-info' -print0 | xargs -0 rm -rf
find . -name '*.pyc' -print0 | xargs -0 rm -f
find . -name '*.swp' -print0 | xargs -0 rm -f
Expand Down Expand Up @@ -72,7 +73,9 @@ upload:
${PIPRUN} python -m twine upload dist/*

docs:
${PIPRUN} python -m sphinx.cmd.build docs public
${PIPRUN} python -m sphinx.cmd.build docs ${PUBLIC_DIR}/html
${PIPRUN} python -m mypy tests src --html-report ${PUBLIC_DIR}/html/reports/mypy
${PIPRUN} python -m pytest --cov-report html:${PUBLIC_DIR}/html/reports/coverage .

docs-autobuild:
${PIPRUN} python -m sphinx_autobuild docs public --watch src
${PIPRUN} python -m sphinx_autobuild docs ${PUBLIC_DIR}/html --watch src
9 changes: 6 additions & 3 deletions Makefile.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Construct pipenv run command with or without site-packages flag when not in CI environment and pipenv command exists.
SITE_PACKAGES_FLAG = $(shell [ "${SS_SITE_PACKAGES}" = "true" ] && echo --site-packages)
PIPRUN := $(shell [ "${CI}" != "true" ] && command -v pipenv > /dev/null 2>&1 && echo pipenv ${SITE_PACKAGES_FLAG} run)
PUBLIC_DIR := $(or $(READTHEDOCS_OUTPUT),public)

# Remove common intermediate files.
clean:
Expand All @@ -17,7 +18,7 @@ clean:
Pipfile* \
coverage.xml \
dist \
public
$(PUBLIC_DIR)
find . -name '*.egg-info' -print0 | xargs -0 rm -rf
find . -name '*.pyc' -print0 | xargs -0 rm -f
find . -name '*.swp' -print0 | xargs -0 rm -f
Expand Down Expand Up @@ -74,7 +75,9 @@ upload:
${PIPRUN} python -m twine upload dist/*

docs:
${PIPRUN} python -m sphinx.cmd.build docs public
${PIPRUN} python -m sphinx.cmd.build docs ${PUBLIC_DIR}/html
${PIPRUN} python -m mypy tests src --html-report ${PUBLIC_DIR}/html/reports/mypy
${PIPRUN} python -m pytest --cov-report html:${PUBLIC_DIR}/html/reports/coverage .

docs-autobuild:
${PIPRUN} python -m sphinx_autobuild docs public --watch src
${PIPRUN} python -m sphinx_autobuild docs ${PUBLIC_DIR}/html --watch src
1 change: 0 additions & 1 deletion copier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ _exclude:
- __pycache__
- copier.yaml
- copier.yml
- docs/modules/serious_scaffold.settings.rst
- includes
- src/serious_scaffold
- ~*
Expand Down
4 changes: 2 additions & 2 deletions docs/cli/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Command Line Interface
======================
CLI Reference
=============

.. click:: serious_scaffold.cli:typer_click_object
:prog: serious-scaffold-cli
Expand Down
4 changes: 2 additions & 2 deletions docs/cli/index.rst.jinja
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Command Line Interface
======================
CLI Reference
=============

.. click:: {{ module_name }}.cli:typer_click_object
:prog: {{ package_name }}-cli
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Welcome to Serious Scaffold Python's documentation!

cli/index
api/index
reports/index

Indices and tables
==================
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Welcome to {{ project_name }}'s documentation!

cli/index
api/index
reports/index

Indices and tables
==================
Expand Down
4 changes: 4 additions & 0 deletions docs/reports/coverage/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Coverage Reports
================

This is a placeholder for coverage reports which supposed to be overridden.
8 changes: 8 additions & 0 deletions docs/reports/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Code Quality Reports
====================

.. toctree::
:maxdepth: 2

mypy/index
coverage/index
4 changes: 4 additions & 0 deletions docs/reports/mypy/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MyPy Reports
============

This is a placeholder for mypy reports which supposed to be overridden.
3 changes: 3 additions & 0 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Requirements for docs.
autodoc-pydantic
furo
mypy[reports]
pytest
pytest-cov
Sphinx
sphinx-autobuild
sphinx-click
4 changes: 0 additions & 4 deletions src/serious_scaffold/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,3 @@ def main() -> None:
# NOTE(huxuan): click object is used for document generation.
# Reference: https://github.com/tiangolo/typer/issues/200#issuecomment-796485787
typer_click_object = typer.main.get_command(app)


if __name__ == "__main__":
app() # pragma: no cover
4 changes: 0 additions & 4 deletions src/{{ module_name }}/cli.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,3 @@ def main() -> None:
# NOTE(huxuan): click object is used for document generation.
# Reference: https://github.com/tiangolo/typer/issues/200#issuecomment-796485787
typer_click_object = typer.main.get_command(app)


if __name__ == "__main__":
app() # pragma: no cover

0 comments on commit 4494f8a

Please sign in to comment.