Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JaeAeich committed Jul 9, 2024
1 parent e1270a1 commit e485921
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/elixir-cloud-aai/cookiecutter-python",
"commit": "82a9aebbdff819758c94e7607c052a3fa5ba3b18",
"commit": "c9d14eea5af812f12c3e19e1bbdc8affe8759eda",
"checkout": null,
"context": {
"cookiecutter": {
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ jobs:

- name: Generate API docs
run: |
poetry run sphinx-apidoc -o /tmp/docs tus_storagehandler/
poetry run sphinx-apidoc -o /tmp/docs/source/pages tus_storagehandler/
- name: Compare docs with main branch
id: check_docs_diff
run: |
shasum /tmp/docs/* > /tmp/docs.sha
rm -f docs/pages/.gitkeep # Remove placeholder file
shasum docs/pages/* > docs/project_doc.sha
diff=$(diff /tmp/docs.sha docs/project_doc.sha) || true
shasum /tmp/docs/source/pages/* > /tmp/docs.sha
shasum docs/source/pages/* > docs/project_doc.sha
awk '{print $1}' /tmp/docs.sha > /tmp/docs_hashes.sha
awk '{print $1}' docs/project_doc.sha > docs/project_doc_hashes.sha
diff=$(diff /tmp/docs_hashes.sha docs/project_doc_hashes.sha) || true
if [[ -n "$diff" ]]; then
echo "::error::API documentation is out of date."
exit 1
Expand Down
44 changes: 28 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,26 @@ help:
@echo "\nUsage: make [target] ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
@echo "Available targets:\n"

@echo "Environment Management --------------------------------------------------------"
@echo " \033[1m\033[35mclean-venv\033[0m \033[37m(cv)\033[0m: \033[36mRemove virtual environment.\033[0m"
@echo " \033[1m\033[35minstall\033[0m \033[37m(i)\033[0m: \033[36mInstall dependencies and tus_storagehandler.\033[0m"
@echo " \033[1m\033[35mvenv\033[0m \033[37m(v)\033[0m: \033[36mCreate virtual environment.\033[0m\n"

@echo "Code Quality ------------------------------------------------------------------"
@echo " \033[1m\033[35mformat-lint\033[0m \033[37m(fl)\033[0m: \033[36mRun linter, formatter, spellcheck.\033[0m"
@echo " \033[1m\033[35mprecommit-check\033[0m \033[37m(pc)\033[0m: \033[36mRun all pre-commit checks.\033[0m"
@echo " \033[1m\033[35msecurity\033[0m \033[37m(s)\033[0m: \033[36mRun security scans.\033[0m"
@echo " \033[1m\033[35mtype-check\033[0m \033[37m(tc)\033[0m: \033[36mPerform type checking.\033[0m\n"

@echo "Testing -----------------------------------------------------------------------"
@echo " \033[1m\033[35mtest\033[0m \033[37m(t)\033[0m: \033[36mRun all tests.\033[0m\n"

@echo "Documentation -----------------------------------------------------------------"
@echo " \033[1m\033[35mdocs\033[0m \033[37m(d)\033[0m: \033[36mGenerate project documentation.\033[0m\n"

@echo "Environment Management --------------------------------------------------------"
@echo " \033[1m\033[35mclean-venv\033[0m \033[37m(cv)\033[0m: \033[36mRemove virtual environment.\033[0m"
@echo " \033[1m\033[35minstall\033[0m \033[37m(i)\033[0m: \033[36mInstall dependencies and tus_storagehandler.\033[0m"
@echo " \033[1m\033[35mvenv\033[0m \033[37m(v)\033[0m: \033[36mCreate virtual environment.\033[0m\n"

@echo "Miscellaneous -----------------------------------------------------------------"
@echo " \033[1m\033[35mupdate\033[0m \033[37m(u)\033[0m: \033[36mUpdate the template.\033[0m\n"

@echo "Testing -----------------------------------------------------------------------"
@echo " \033[1m\033[35mtest\033[0m \033[37m(t)\033[0m: \033[36mRun all tests.\033[0m\n"

## Autogenerated Targets ######################################################
# NOTE: Keep all the targets in alphabetical order for better readability.
# NOTE: Do not modify the autogenerated targets, unless necessary, write custom
Expand All @@ -47,7 +50,7 @@ cv: clean-venv
.PHONY: docs
docs:
@echo "\nGenerating project documentation ++++++++++++++++++++++++++++++++++++++++++++++\n"
@sphinx-apidoc -f -o docs/source/pages tus_storagehandler
@poetry run sphinx-apidoc -f -o docs/source/pages tus_storagehandler
@cd docs && make html
@echo "\nSummary ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
@echo "Documentation generated successfully."
Expand All @@ -61,15 +64,15 @@ d: docs
.PHONY: format-lint
format-lint:
@echo "\nRunning linter and formatter using ruff and typos +++++++++++++++++++++++++++++\n"
@ruff format && ruff check --fix
@poetry run ruff format && poetry run ruff check --fix
@typos .

.PHONY: fl
fl: format-lint

.PHONY: install
install:
@echo "\nInstalling all dependencies and with this package +++++++++++++++++++++++++++++++++\n"
@echo "\nInstalling dependencies and with this package +++++++++++++++++++++++++++++++++\n"
@poetry install --with=code_quality,docs,misc,test,types,vulnerability

.PHONY: i
Expand All @@ -78,36 +81,45 @@ i: install
.PHONY: precommit-check
precommit-check:
@echo "\nRunning pre-commit checks +++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
@pre-commit run --all-files
@poetry run pre-commit run --all-files

.PHONY: pc
pc: precommit-check

.PHONY: security
security:
@echo "\nRunning security scans using bandit and safety ++++++++++++++++++++++++++++++++\n"
@safety check --full-report
@bandit -c pyproject.toml -r tus_storagehandler
@poetry run safety check --full-report
@poetry run bandit -c pyproject.toml -r tus_storagehandler

.PHONY: s
s: security

.PHONY: test
test:
@echo "\nRunning tests using pytest ++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
@pytest tests/
@poetry run pytest tests/

.PHONY: t
t: test

.PHONY: type-check
type-check:
@echo "\nPerforming type checking with mypy ++++++++++++++++++++++++++++++++++++++++++++\n"
@mypy tus_storagehandler
@poetry run mypy tus_storagehandler

.PHONY: tc
tc: type-check

.PHONY: update
update:
@echo "\nUpdating the template +++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
@echo "Using latest version from remote: https://github.com/elixir-cloud-aai/cookiecutter-python."
@poetry run cruff update -y

.PHONY: u
u: update

.PHONY: venv
venv:
@echo "\nCreating a virtual environment ++++++++++++++++++++++++++++++++++++++++++++++++\n"
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ make i
>
> This ensures that the type checker functions correctly.
> **Note**: Since the dependencies are segregated into groups, if you add a new
> group make sure to add it in `make install` command in [Makefile](Makefile).
- Running tests
```sh
Expand All @@ -90,6 +93,9 @@ make fl
make d
```
> **Note**: If you make changes to the code, make sure to generate and push the
> documentation using above command, else the documentation check CI will fail.
- Running type checker
```sh
Expand All @@ -102,6 +108,12 @@ make tc
make pc
```
- Update the cookiecutter template
```sh
make u
```
> **Note**: This is not the complete list of commands, run `make` to find out if
> more have been added.
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/modules.rst → docs/source/pages/modules.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tus_storagehandler
===================
==================

.. toctree::
:maxdepth: 4
Expand Down
21 changes: 21 additions & 0 deletions docs/source/pages/tus_storagehandler.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
tus\_storagehandler package
===========================

Submodules
----------

tus\_storagehandler.main module
-------------------------------

.. automodule:: tus_storagehandler.main
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: tus_storagehandler
:members:
:undoc-members:
:show-inheritance:
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ optional = true
bandit = ">=1.7.8,<2.0.0"
safety = ">=3.2.0,<4.0.0"

[tool.poetry.scripts]
tus_storagehandler = "tus_storagehandler.main:main"

[tool.ruff]
indent-width = 4

Expand Down

0 comments on commit e485921

Please sign in to comment.