Skip to content

Instantly share code, notes, and snippets.

@MatthewRalston
Created April 18, 2018 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MatthewRalston/4f858bf8bfab9e244ae66faa6b6b3223 to your computer and use it in GitHub Desktop.
Save MatthewRalston/4f858bf8bfab9e244ae66faa6b6b3223 to your computer and use it in GitHub Desktop.
Python project Makefiles
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = modulename
SOURCEDIR = source
BUILDDIR = build
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
docs: Makefile
rm -rf build/*;
sphinx-apidoc --private --force -o source ../modulename;
sed -i '/\:members\:/a\
:private-members:' source/*.rst;
@$(SPHINXBUILD) -b html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O);
if [ -e "build/_static" ]; then mv build/_static build/static; fi;
if [ -e "build/_sources" ]; then mv build/_sources build/sources; fi;
sed -i 's/\_static/static/g' build/*.html;
sed -i 's/\_sources/sources/g' build/*.html;
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: test docs
install:
pip install -r reuqirements.txt;
docs: docs/Makefile
cd docs; $(MAKE) docs
test: test/Makefile
cd test; $(MAKE) test
#AWS_DATA_PATH="/path/to/.venv/lib/python2.7/site-packages/awscli/data/"
MAMBA=PYTHONPATH=".." mamba
test: *_spec.py
${MAMBA} --format documentation *_spec.py
if [ -e ../.coverage ]; then mv ../.coverage .; fi;
coverage report | grep modulename | grep -v config.py | ruby -e 'miss=0;stmt=0; while gets; line=$$_.split; stmt+=line[1].to_i; miss+=line[2].to_i; puts line.join("\t"); end; puts ["modulename", stmt, miss, ((1-miss/stmt.to_f)*100).to_s + "%"].join("\t")' > coverage.tsv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment