Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 92a1067

Browse filesBrowse files
charrispganssle
andcommitted
ENH: Add a clang-format file.
Clang-format can be used to reformat C/C++ code for codestyle fixups. The `.clang-format` file here implements the NumPy codestyle document as much as possible. Co-authored-by: Paul Ganssle <paul@ganssle.io>
1 parent 516355f commit 92a1067
Copy full SHA for 92a1067

File tree

2 files changed

+44
-0
lines changed
Filter options

2 files changed

+44
-0
lines changed

‎.clang-format

Copy file name to clipboard
+37Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# A clang-format style that approximates Python's PEP 7
2+
# Useful for IDE integration
3+
#
4+
# Based on Paul Ganssle's version at
5+
# https://gist.github.com/pganssle/0e3a5f828b4d07d79447f6ced8e7e4db
6+
# and modified for NumPy
7+
BasedOnStyle: Google
8+
AlignAfterOpenBracket: Align
9+
AllowShortEnumsOnASingleLine: false
10+
AllowShortIfStatementsOnASingleLine: false
11+
AlwaysBreakAfterReturnType: TopLevel
12+
BreakBeforeBraces: Stroustrup
13+
ColumnLimit: 79
14+
ContinuationIndentWidth: 8
15+
DerivePointerAlignment: false
16+
IndentWidth: 4
17+
IncludeBlocks: Regroup
18+
IncludeCategories:
19+
- Regex: '^[<"](Python|structmember)'
20+
Priority: -3
21+
CaseSensitive: true
22+
- Regex: '^"numpy/'
23+
Priority: -2
24+
- Regex: '^"(npy_pycompat|npy_config)'
25+
Priority: -1
26+
- Regex: '^"[[:alnum:]_.]+"'
27+
Priority: 1
28+
- Regex: '^<[[:alnum:]_.]+"'
29+
Priority: 2
30+
Language: Cpp
31+
PointerAlignment: Right
32+
ReflowComments: true
33+
SpaceBeforeParens: ControlStatements
34+
SpacesInParentheses: false
35+
StatementMacros: [PyObject_HEAD, PyObject_VAR_HEAD, PyObject_HEAD_EXTRA]
36+
TabWidth: 4
37+
UseTab: Never
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
A ``.clang-format`` file has been added
2+
---------------------------------------
3+
Clang-format is a C/C++ code formatter, together with the added
4+
``.clang-format`` file, it produces code close enough to the NumPy
5+
C_STYLE_GUIDE for general use. Clang-format version 12+ is required
6+
due to the use of several new features, it is available in
7+
Fedora 34 and Ubuntu Focal among other distributions.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.