Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .indent.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--blank-lines-after-declarations
--blank-lines-after-procedures
--braces-after-func-def-line
--braces-on-if-line
--braces-on-struct-decl-line
--break-after-boolean-operator
--comment-indentation25
--comment-line-length79
--continue-at-parentheses
--dont-cuddle-do-while
--dont-cuddle-else
--indent-level4
--line-length79
--no-space-after-casts
--no-space-after-function-call-names
--no-space-after-parentheses
--no-tabs
--procnames-start-lines
--space-after-for
--space-after-if
--space-after-while
--swallow-optional-blank-lines
-T PyCFunction
-T PyObject
-T PyMethodDef
-T LDAP
-T LDAPMod
-T LDAPMessage
-T LDAPControl
-T LDAPObject
-T sasl_interact_t
11 changes: 11 additions & 0 deletions Doc/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ Specify a different one using, for example::

Notable targets are:

``make autoformat``
Automatically re-formats C and Python code to conform to Python style
guides (`PEP 7`_ and `PEP 8`_).
Note that no backups are made – please commit any other changes before
using this target.

Requires the ``indent`` program and the ``autopep8`` Python module.

.. _PEP 7: https://www.python.org/dev/peps/pep-0007/
.. _PEP 8: https://www.python.org/dev/peps/pep-0008/

``make lcov lcov-open``
Generate and view test coverage for C code.
Requires LCOV_.
Expand Down
15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LCOV_REPORT_OPTIONS=--show-details -no-branch-coverage \
--title "python-ldap LCOV report"
SCAN_REPORT=build/scan_report
PYTHON_SUPP=/usr/share/doc/python3-devel/valgrind-python.supp
AUTOPEP8_OPTS=--aggressive

.NOTPARALLEL:

Expand All @@ -13,7 +14,7 @@ all:

.PHONY: clean
clean:
rm -rf build dist *.egg-info $(VENV) .tox MANIFEST
rm -rf build dist *.egg-info .tox MANIFEST
rm -f .coverage .coverage.*
find . \( -name '*.py[co]' -or -name '*.so*' -or -name '*.dylib' \) \
-delete
Expand Down Expand Up @@ -77,3 +78,15 @@ valgrind: build $(PYTHON_SUPP)
echo "Found definitive leak, see build/valgrind.log"; \
exit 1; \
fi

# Code autoformatter
.PHONY: autoformat indent autopep8
autoformat: indent autopep8

indent:
indent Modules/*.c Modules/*.h
rm -f Modules/*.c~ Modules/*.h~

autopep8:
$(PYTHON) -m autopep8 -r -i -j0 $(AUTOPEP8_OPTS) \
Demo Lib Tests setup.py