Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
8b0ccf76
Commit
8b0ccf76
authored
Jul 20, 2020
by
Henry Schreiner
Committed by
Henry Schreiner
Jul 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style: adding pre-commit check-style.sh
parent
b16347e5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
42 deletions
+22
-42
.pre-commit-config.yaml
+10
-1
.travis.yml
+2
-4
CONTRIBUTING.md
+4
-5
tools/check-style.sh
+6
-32
No files found.
.pre-commit-config.yaml
View file @
8b0ccf76
...
@@ -24,5 +24,14 @@ repos:
...
@@ -24,5 +24,14 @@ repos:
rev
:
3.8.2
rev
:
3.8.2
hooks
:
hooks
:
-
id
:
flake8
-
id
:
flake8
additional_dependencies
:
[
flake8-bugbear
]
additional_dependencies
:
[
flake8-bugbear
,
pep8-naming
]
exclude
:
^(docs/.*|tools/.*)$
exclude
:
^(docs/.*|tools/.*)$
-
repo
:
local
hooks
:
-
id
:
check-style
name
:
Classic check-style
language
:
system
types
:
-
c++
entry
:
./tools/check-style.sh
.travis.yml
View file @
8b0ccf76
...
@@ -9,7 +9,7 @@ matrix:
...
@@ -9,7 +9,7 @@ matrix:
# also tests the automatic discovery functions in CMake (Python version, C++ standard).
# also tests the automatic discovery functions in CMake (Python version, C++ standard).
-
os
:
linux
-
os
:
linux
dist
:
xenial
# Necessary to run doxygen 1.8.15
dist
:
xenial
# Necessary to run doxygen 1.8.15
name
:
Style, docs,
and pip
name
:
Docs
and pip
cache
:
false
cache
:
false
before_install
:
before_install
:
-
pyenv global $(pyenv whence 2to3)
# activate all python versions
-
pyenv global $(pyenv whence 2to3)
# activate all python versions
...
@@ -18,12 +18,10 @@ matrix:
...
@@ -18,12 +18,10 @@ matrix:
install
:
install
:
# breathe 4.14 doesn't work with bit fields. See https://github.com/michaeljones/breathe/issues/462
# breathe 4.14 doesn't work with bit fields. See https://github.com/michaeljones/breathe/issues/462
# Latest breathe + Sphinx causes warnings and errors out
# Latest breathe + Sphinx causes warnings and errors out
-
$PY_CMD -m pip install --user --upgrade "sphinx<3" sphinx_rtd_theme breathe==4.13.1
flake8 pep8-naming
pytest
-
$PY_CMD -m pip install --user --upgrade "sphinx<3" sphinx_rtd_theme breathe==4.13.1 pytest
-
curl -fsSL https://sourceforge.net/projects/doxygen/files/rel-1.8.15/doxygen-1.8.15.linux.bin.tar.gz/download | tar xz
-
curl -fsSL https://sourceforge.net/projects/doxygen/files/rel-1.8.15/doxygen-1.8.15.linux.bin.tar.gz/download | tar xz
-
export PATH="$PWD/doxygen-1.8.15/bin:$PATH"
-
export PATH="$PWD/doxygen-1.8.15/bin:$PATH"
script
:
script
:
-
tools/check-style.sh
-
flake8
-
$PY_CMD -m sphinx -W -b html docs docs/.build
-
$PY_CMD -m sphinx -W -b html docs docs/.build
-
|
-
|
# Make sure setup.py distributes and installs all the headers
# Make sure setup.py distributes and installs all the headers
...
...
CONTRIBUTING.md
View file @
8b0ccf76
...
@@ -27,11 +27,10 @@ adhere to the following rules to make the process as smooth as possible:
...
@@ -27,11 +27,10 @@ adhere to the following rules to make the process as smooth as possible:
do add value by themselves.
do add value by themselves.
*
Add tests for any new functionality and run the test suite (
``make pytest``
)
*
Add tests for any new functionality and run the test suite (
``make pytest``
)
to ensure that no existing features break.
to ensure that no existing features break.
*
Please run
[
``pre-commit``
][
pre-commit
]
and
``tools/check-style.sh``
to check
*
Please run
[
``pre-commit``
][
pre-commit
]
to check your code matches the
your code matches the project style. (Note that
``check-style.sh``
requires
project style. (Note that
``gawk``
is required.) Use
`pre-commit run
``gawk``
.) Use
`pre-commit run --all-files`
before committing (or use
--all-files`
before committing (or use installed-mode, check pre-commit docs)
installed-mode, check pre-commit docs) to verify your code passes before
to verify your code passes before pushing to save time.
pushing to save time.
*
This project has a strong focus on providing general solutions using a
*
This project has a strong focus on providing general solutions using a
minimal amount of code, thus small pull requests are greatly preferred.
minimal amount of code, thus small pull requests are greatly preferred.
...
...
tools/check-style.sh
View file @
8b0ccf76
...
@@ -4,45 +4,19 @@
...
@@ -4,45 +4,19 @@
#
#
# This script currently checks for
# This script currently checks for
#
#
# 1. use of tabs instead of spaces
# 1. missing space between keyword and parenthesis, e.g.: for(, if(, while(
# 2. MSDOS-style CRLF endings
# 2. Missing space between right parenthesis and brace, e.g. 'for (...){'
# 3. trailing spaces
# 3. opening brace on its own line. It should always be on the same line as the
# 4. missing space between keyword and parenthesis, e.g.: for(, if(, while(
# 5. Missing space between right parenthesis and brace, e.g. 'for (...){'
# 6. opening brace on its own line. It should always be on the same line as the
# if/while/for/do statement.
# if/while/for/do statement.
#
#
# Invoke as: tools/check-style.sh
# Invoke as: tools/check-style.sh
<filenames>
#
#
check_style_errors
=
0
check_style_errors
=
0
IFS
=
$'
\n
'
IFS
=
$'
\n
'
found
=
"
$(
GREP_COLORS
=
'mt=41'
GREP_COLOR
=
'41'
grep
$'
\t
'
include tests/
*
.
{
cpp,py,h
}
docs/
*
.rst
-rn
--color
=
always
)
"
if
[
-n
"
$found
"
]
;
then
# The mt=41 sets a red background for matched tabs:
echo
-e
'\033[31;01mError: found tab characters in the following files:\033[0m'
check_style_errors
=
1
echo
"
$found
"
| sed
-e
's/^/ /'
fi
found
=
"
$(
grep
-IUlr
$'
\r
'
include tests/
*
.
{
cpp,py,h
}
docs/
*
.rst
--color
=
always
)
"
if
[
-n
"
$found
"
]
;
then
echo
-e
'\033[31;01mError: found CRLF characters in the following files:\033[0m'
check_style_errors
=
1
echo
"
$found
"
| sed
-e
's/^/ /'
fi
found
=
"
$(
GREP_COLORS
=
'mt=41'
GREP_COLOR
=
'41'
grep
'[[:blank:]]\+$'
include tests/
*
.
{
cpp,py,h
}
docs/
*
.rst
-rn
--color
=
always
)
"
if
[
-n
"
$found
"
]
;
then
# The mt=41 sets a red background for matched trailing spaces
echo
-e
'\033[31;01mError: found trailing spaces in the following files:\033[0m'
check_style_errors
=
1
echo
"
$found
"
| sed
-e
's/^/ /'
fi
found
=
"
$(
grep
'\<\(if\|for\|while\|catch\)(\|){'
include tests/
*
.
{
cpp,h
}
-rn
--color
=
always
)
"
found
=
"
$(
grep
'\<\(if\|for\|while\|catch\)(\|){'
$@
-rn
--color
=
always
)
"
if
[
-n
"
$found
"
]
;
then
if
[
-n
"
$found
"
]
;
then
echo
-e
'\033[31;01mError: found the following coding style problems:\033[0m'
echo
-e
'\033[31;01mError: found the following coding style problems:\033[0m'
check_style_errors
=
1
check_style_errors
=
1
...
@@ -60,7 +34,7 @@ last && /^\s*{/ {
...
@@ -60,7 +34,7 @@ last && /^\s*{/ {
last=""
last=""
}
}
{ last = /(if|for|while|catch|switch)\s*\(.*\)\s*$/ ? $0 : "" }
{ last = /(if|for|while|catch|switch)\s*\(.*\)\s*$/ ? $0 : "" }
'
$(
find include
-type
f
)
tests/
*
.
{
cpp,h
}
docs/
*
.rst
)
"
'
$(
find include
-type
f
)
$@
)
"
if
[
-n
"
$found
"
]
;
then
if
[
-n
"
$found
"
]
;
then
check_style_errors
=
1
check_style_errors
=
1
echo
-e
'\033[31;01mError: braces should occur on the same line as the if/while/.. statement. Found issues in the following files:\033[0m'
echo
-e
'\033[31;01mError: braces should occur on the same line as the if/while/.. statement. Found issues in the following files:\033[0m'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment