-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1038 from openfisca/fix-doc
- Loading branch information
Showing
27 changed files
with
466 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
.vscode/ | ||
build/ | ||
dist/ | ||
doc/ | ||
*.egg-info | ||
*.mo | ||
*.pyc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,120 @@ | ||
doc = sed -n "/^$1/ { x ; p ; } ; s/\#\#/[⚙]/ ; s/\./.../ ; x" ${MAKEFILE_LIST} | ||
help = sed -n "/^$1/ { x ; p ; } ; s/\#\#/[⚙]/ ; s/\./.../ ; x" ${MAKEFILE_LIST} | ||
repo = https://github.com/openfisca/openfisca-doc | ||
branch = $(shell git branch --show-current) | ||
|
||
## Same as `make test. | ||
## Same as `make test`. | ||
all: test | ||
|
||
## Install project dependencies. | ||
install: | ||
@$(call doc,$@:) | ||
@$(call help,$@:) | ||
@pip install --upgrade pip twine wheel | ||
@pip install --editable .[dev] --upgrade --use-deprecated=legacy-resolver | ||
|
||
## Install openfisca-core for deployment and publishing. | ||
build: setup.py | ||
@## This allows us to be sure tests are run against the packaged version | ||
@## of openfisca-core, the same we put in the hands of users and reusers. | ||
@$(call doc,$@:) | ||
@$(call help,$@:) | ||
@python $? bdist_wheel | ||
@find dist -name "*.whl" -exec pip install --force-reinstall {}[dev] \; | ||
|
||
## Uninstall project dependencies. | ||
uninstall: | ||
@$(call doc,$@:) | ||
@$(call help,$@:) | ||
@pip freeze | grep -v "^-e" | sed "s/@.*//" | xargs pip uninstall -y | ||
|
||
## Delete builds and compiled python files. | ||
clean: \ | ||
$(shell ls -d * | grep "build\|dist") \ | ||
$(shell find . -name "*.pyc") | ||
@$(call doc,$@:) | ||
@$(call help,$@:) | ||
@rm -rf $? | ||
|
||
## Compile python files to check for syntax errors. | ||
check-syntax-errors: . | ||
@$(call doc,$@:) | ||
@$(call help,$@:) | ||
@python -m compileall -q $? | ||
|
||
## Run linters to check for syntax and style errors. | ||
check-style: $(shell git ls-files "*.py") | ||
@$(call doc,$@:) | ||
@$(call help,$@:) | ||
@flake8 $? | ||
|
||
## Run code formatters to correct style errors. | ||
format-style: $(shell git ls-files "*.py") | ||
@$(call doc,$@:) | ||
@$(call help,$@:) | ||
@autopep8 $? | ||
|
||
## Run static type checkers for type errors. | ||
check-types: openfisca_core openfisca_web_api | ||
@$(call doc,$@:) | ||
@$(call help,$@:) | ||
@mypy $? | ||
|
||
## Run openfisca-core tests. | ||
test: clean check-syntax-errors check-style check-types | ||
@$(call doc,$@:) | ||
@$(call help,$@:) | ||
@env PYTEST_ADDOPTS="${PYTEST_ADDOPTS} --cov=openfisca_core" pytest | ||
|
||
## Check that the current changes do not break the doc. | ||
test-doc: | ||
@## Usage: | ||
@## | ||
@## make test-doc [branch=BRANCH] | ||
@## | ||
@## Examples: | ||
@## | ||
@## # Will check the current branch in openfisca-doc. | ||
@## make test-doc | ||
@## | ||
@## # Will check "test-doc" in openfisca-doc. | ||
@## make test-doc branch=test-doc | ||
@## | ||
@## # Will check "master" if "asdf1234" does not exist. | ||
@## make test-doc branch=asdf1234 | ||
@## | ||
@$(call help,$@:) | ||
@${MAKE} test-doc-checkout | ||
@${MAKE} test-doc-install | ||
@${MAKE} test-doc-build | ||
|
||
## Update the local copy of the doc. | ||
test-doc-checkout: | ||
@$(call help,$@:) | ||
@[ ! -d doc ] && git clone ${repo} doc || : | ||
@cd doc && { \ | ||
git reset --hard ; \ | ||
git fetch --all ; \ | ||
[ $$(git branch --show-current) != master ] && git checkout master || : ; \ | ||
[ ${branch} != "master" ] \ | ||
&& { \ | ||
{ \ | ||
git branch -D ${branch} 2> /dev/null ; \ | ||
git checkout ${branch} ; \ | ||
} \ | ||
&& git pull --ff-only origin ${branch} \ | ||
|| { \ | ||
>&2 echo "[!] The branch '${branch}' doesn't exist, checking out 'master' instead..." ; \ | ||
git pull --ff-only origin master ; \ | ||
} \ | ||
} \ | ||
|| git pull --ff-only origin master ; \ | ||
} 1> /dev/null | ||
|
||
## Install doc dependencies. | ||
test-doc-install: | ||
@$(call help,$@:) | ||
@pip install --requirement doc/requirements.txt 1> /dev/null | ||
@pip install --editable .[dev] --upgrade 1> /dev/null | ||
|
||
## Dry-build the doc. | ||
test-doc-build: | ||
@$(call help,$@:) | ||
@sphinx-build -M dummy doc/source doc/build -n -q -W | ||
|
||
## Serve the openfisca Web API. | ||
api: | ||
@$(call doc,$@:) | ||
@$(call help,$@:) | ||
@openfisca serve \ | ||
--country-package openfisca_country_template \ | ||
--extensions openfisca_extension_template |
Oops, something went wrong.