From 8054c8b23abf37d94f5355f14dd139346aa45d40 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Thu, 14 Mar 2024 15:53:32 +0100 Subject: [PATCH] #53: Updated Sphinx doc generation --- .gitignore | 3 ++- Makefile | 59 ++++++++++++++++++++++++++++++++++++++++++---------- docs/api.rst | 2 +- 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 5783e32d..7332cbaa 100644 --- a/.gitignore +++ b/.gitignore @@ -55,10 +55,11 @@ coverage.xml # Sphinx documentation docs/_build/ +docs/_api # PyBuilder target/ # IDEs .idea/ -.vscode/ \ No newline at end of file +.vscode/ diff --git a/Makefile b/Makefile index eebb1a36..f7fbf8de 100644 --- a/Makefile +++ b/Makefile @@ -41,24 +41,61 @@ clean-pyc: ## remove Python file artifacts clean-test: ## remove test and coverage artifacts rm -fr .tox/ + rm -f .coverage + rm -fr reports/ + +test: ## run tests quickly with the default Python + python setup.py test + +test-all: ## run tests on every Python version with tox + tox + +pylint: ## run style checks and static analysis with pylint + @-mkdir -p reports/ + @-pylint $(PYTHON_PACKAGE) -r n --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" > reports/pylint.txt + @echo "See reports/pylint.txt" + @-pylint $(PYTHON_PACKAGE) flake8: ## run style checks and static analysis with flake8 - @flake8 + @-mkdir -p reports/ + flake8 $(PYTHON_PACKAGE) $(TESTS_PACKAGE) --format='%(path)s:%(row)d: [%(code)s(%(code)s), ] %(text)s' --output-file=reports/flake8.txt --tee + +docstrings: ## check docstring presence and style conventions with pydocstyle + pydocstyle $(PYTHON_PACKAGE) + +lint: flake8 docstrings pylint + +coverage: ## check code coverage quickly with the default Python + py.test --cov-report html:reports/htmlcov --cov-report xml:reports/coverage.xml + @echo "See reports/htmlcov/index.html" + +metrics: ## print code metrics with radon + radon raw -s $(PYTHON_PACKAGE) $(TEST_PACKAGE) + radon cc -s $(PYTHON_PACKAGE) $(TEST_PACKAGE) + radon mi -s $(PYTHON_PACKAGE) $(TEST_PACKAGE) + +docs: ## generate Sphinx HTML documentation, including API docs + @if python -c 'import sys; sys.exit(sys.version_info[0]<3)'; then \ + rm -rf docs/_api; \ + sphinx-apidoc --no-toc -o docs/_api $(PYTHON_PACKAGE) "**/tests" "**/migrations" "**/south_migrations"; \ + $(MAKE) -C docs clean; \ + $(MAKE) -C docs html; \ + echo "See docs/_build/html/index.html"; \ + else \ + echo "Please build the docs using Python 3."; \ + fi + +docs-open: + $(BROWSER) docs/_build/html/index.html + +docs-all: docs docs-open release: clean ## package and upload a release - python setup.py sdist upload - python setup.py bdist_wheel upload + python setup.py release upload dist: clean ## builds source and wheel package - python setup.py sdist - python setup.py bdist_wheel + python setup.py release ls -l dist install: clean ## install the package to the active Python's site-packages python setup.py install - -test: - @pytest - -test-all: ## run tests on every Python version with tox - @tox diff --git a/docs/api.rst b/docs/api.rst index 4ac86b45..22f0faa6 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -4,4 +4,4 @@ API .. toctree:: :maxdepth: 4 - pganonymize + _api/pganonymize