# Copyright (C) 2010  Michał Masłowski  <mtjm@mtjm.eu>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


DOCS = README.html NEWS.html

SRCS := $(shell find getmediumurl -name '*.py')
TESTS := $(shell find tests_getmediumurl -name '*.py')

# Support both Debian's modified docutils script names and the
# upstream ones.
ifdef RST2HTML
else ifeq ($(shell which rst2html 2>/dev/null),)
RST2HTML=rst2html.py
else
RST2HTML=rst2html
endif

all: ${DOCS} Makefile

check: ${SRCS} ${TESTS} check.sh Makefile
	./check.sh

pyflakes: ${SRCS} Makefile
	@pyflakes getmediumurl

# Fails.  Some code is not understood by pylint, so many potentially
# useful messages are disabled.
pylint-srcs: ${SRCS} Makefile
	@-pylint \
	    --disable=W0404 \
	    --disable=R0904 \
	    --enable=W0704 \
	    --generated-members=scheme,path \
	    --output-format=colorized \
	    --include-ids=y \
	    --max-args=6 \
	    --report=n \
	    getmediumurl

pylint-tests: ${TESTS} Makefile
	@pylint \
	    --disable=W0201 \
	    --disable=R0904 \
	    --disable=W0401 \
	    --disable=W0404 \
	    --disable=W0406 \
	    --disable=R0903 \
	    --disable=W0622 \
	    --disable=W0603 \
	    --enable=W0704 \
	    --good-names=setUp,tearDown \
	    --generated-members=skipTest,resource_filename \
	    --output-format=colorized \
	    --include-ids=y \
	    --report=n \
	    tests_getmediumurl

pep8: ${SRCS} Makefile
	@pep8 getmediumurl tests_getmediumurl

style: pyflakes pylint-srcs pylint-tests pep8 Makefile

%.html: %.txt Makefile
	${RST2HTML} $< $@

.PHONY: all pep8 style check pyflakes
