From e4859217cb768abed39b772446749801cb7387fa Mon Sep 17 00:00:00 2001 From: Javed Habib Date: Tue, 9 Jul 2024 17:57:17 +0530 Subject: [PATCH] fix docs --- .cruft.json | 2 +- .github/workflows/docs.yaml | 11 +++--- Makefile | 44 +++++++++++++++--------- README.md | 12 +++++++ docs/{ => source}/pages/modules.rst | 2 +- docs/source/pages/tus_storagehandler.rst | 21 +++++++++++ pyproject.toml | 3 ++ 7 files changed, 72 insertions(+), 23 deletions(-) rename docs/{ => source}/pages/modules.rst (78%) create mode 100644 docs/source/pages/tus_storagehandler.rst diff --git a/.cruft.json b/.cruft.json index 1c488ff..e179cc3 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,6 +1,6 @@ { "template": "https://github.com/elixir-cloud-aai/cookiecutter-python", - "commit": "82a9aebbdff819758c94e7607c052a3fa5ba3b18", + "commit": "c9d14eea5af812f12c3e19e1bbdc8affe8759eda", "checkout": null, "context": { "cookiecutter": { diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 9481c13..a0f28a1 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -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 diff --git a/Makefile b/Makefile index bb3d0e5..428044c 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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." @@ -61,7 +64,7 @@ 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 @@ -69,7 +72,7 @@ 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 @@ -78,7 +81,7 @@ 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 @@ -86,8 +89,8 @@ 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 @@ -95,7 +98,7 @@ s: security .PHONY: test test: @echo "\nRunning tests using pytest ++++++++++++++++++++++++++++++++++++++++++++++++++++\n" - @pytest tests/ + @poetry run pytest tests/ .PHONY: t t: test @@ -103,11 +106,20 @@ 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" diff --git a/README.md b/README.md index a41b9ff..1a3d15c 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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. diff --git a/docs/pages/modules.rst b/docs/source/pages/modules.rst similarity index 78% rename from docs/pages/modules.rst rename to docs/source/pages/modules.rst index cb090d8..66ab2b8 100644 --- a/docs/pages/modules.rst +++ b/docs/source/pages/modules.rst @@ -1,5 +1,5 @@ tus_storagehandler -=================== +================== .. toctree:: :maxdepth: 4 diff --git a/docs/source/pages/tus_storagehandler.rst b/docs/source/pages/tus_storagehandler.rst new file mode 100644 index 0000000..50d75ff --- /dev/null +++ b/docs/source/pages/tus_storagehandler.rst @@ -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: diff --git a/pyproject.toml b/pyproject.toml index b167ac0..f85f11e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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