Skip to content

Commit 0afcd09

Browse files
authored
Merge pull request #18 from dawnbeen/master
merge upstream
2 parents 134a64d + 4865f98 commit 0afcd09

File tree

9 files changed

+50
-7
lines changed

9 files changed

+50
-7
lines changed

.github/workflows/python-package-develop.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ jobs:
2323
fail-fast: false
2424
matrix:
2525
os: [ubuntu-latest]
26-
python-version: ["3.7", "3.8", "3.9", "3.10"]
26+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
27+
2728

2829
steps:
2930
- uses: actions/checkout@v2

.github/workflows/python-package.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ jobs:
2828
fail-fast: false
2929
matrix:
3030
os: [ubuntu-latest, macos-11]
31-
python-version: ["3.7", "3.8", "3.9", "3.10"]
31+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
32+
3233

3334
steps:
3435
- uses: actions/checkout@v2

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ docs/build/
99
/.venv
1010
/debug
1111
/.vimspector.json
12+
13+
.vscode

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<p align="center">
22
<a style="text-decoration:none" href="https://badge.fury.io/py/c-formatter-42"><img src="https://badge.fury.io/py/c-formatter-42.svg" alt="PyPI version" height="20"></a>
3-
<a style="text-decoration:none" href="https://github.com/cacharle/c_formatter_42/actions"><img src="https://github.com/cacharle/c_formatter_42/actions/workflows/python-package.yml/badge.svg" height="20"></a>
4-
<a style="text-decoration:none" href="https://github.com/cacharle/c_formatter_42/actions"><img src="https://github.com/cacharle/c_formatter_42/actions/workflows/python-publish.yml/badge.svg" height="20"></a>
3+
<a style="text-decoration:none" href="https://github.com/dawnbeen/c_formatter_42/actions"><img src="https://github.com/cacharle/c_formatter_42/actions/workflows/python-package.yml/badge.svg" height="20"></a>
4+
<a style="text-decoration:none" href="https://github.com/dawnbeen/c_formatter_42/actions"><img src="https://github.com/cacharle/c_formatter_42/actions/workflows/python-publish.yml/badge.svg" height="20"></a>
55
<a style="text-decoration:none" href="https://pypi.org/project/c-formatter-42/"><img src="https://img.shields.io/pypi/pyversions/c-formatter-42" height="20"></a>
66
</p>
77

@@ -19,7 +19,7 @@ It's just for convenience.
1919

2020
## Installation
2121

22-
Requires Python 3.7+ (3.7, 3.8, 3.9, 3.10)
22+
Requires Python3.7+ (3.8, 3.9, 3.10, 3.11)
2323

2424
### From PyPI
2525

c_formatter_42/formatters/preprocessor_directive.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,13 @@ def preprocessor_directive(content: str) -> str:
3333
indent += 1
3434
if directive_name == "endif":
3535
indent -= 1
36+
37+
# if newline doesn't follows preprocessor part, insert one
38+
try:
39+
lastline_index = idented[-1][0]
40+
if lines[lastline_index + 1] != "":
41+
lines.insert(lastline_index + 1, "")
42+
except IndexError:
43+
pass
44+
3645
return "\n".join(lines)

setup.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = c_formatter_42
3-
version = 0.1.6
3+
version = 0.2.1
44
description = formatting tool complient with 42 school's norm
55
long_description = file: README.md
66
long_description_content_type = text/markdown
@@ -12,6 +12,7 @@ classifiers =
1212
Programming Language :: Python :: 3.8
1313
Programming Language :: Python :: 3.9
1414
Programming Language :: Python :: 3.10
15+
Programming Language :: Python :: 3.11
1516
Programming Language :: C
1617
Intended Audience :: Developers
1718
Environment :: Console

tests/formatters/test_preprocessor_directive.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,17 @@ def test_preprocessor_directive_nested_10():
217217
#endif
218218
"""
219219
assert output == preprocessor_directive(input)
220+
221+
222+
def test_preprocessor_1():
223+
input = """
224+
#include "libft.h"
225+
void *ft_function(char c)
226+
"""
227+
output = """
228+
#include "libft.h"
229+
230+
void *ft_function(char c)
231+
"""
232+
assert output == preprocessor_directive(input)
233+
assert output == preprocessor_directive(preprocessor_directive(input))

tests/test_run.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,18 @@ def test_run_align_break_column_max():
5353

5454
def test_run_func_decl_single_tab_and_global_aligned():
5555
pass
56+
57+
58+
def test_basic():
59+
input = """
60+
int main(int argc, char*argv[]){
61+
return 0;
62+
}
63+
"""
64+
output = """
65+
int\tmain(int argc, char *argv[])
66+
{
67+
return (0);
68+
}
69+
"""
70+
assert output == run_all(input)

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = python3.7,python3.8,python3.9,python3.10
2+
envlist = python3.7,python3.8,python3.9,python3.10,python3.11
33
distshare = {env:XDG_CACHE_HOME}/tox/distshare
44

55
[testenv]

0 commit comments

Comments
 (0)