Skip to content

Commit fd2cfd8

Browse files
committed
DOC: Add regular Python docstrings
1 parent 48838ee commit fd2cfd8

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

codespell.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
from comment_parser import comment_parser
1515

1616

17-
# Split a camel case string into individual words.
1817
def splitCamelCase(word):
18+
"""Split a camel case string into individual words."""
1919

2020
result = []
2121

@@ -34,8 +34,8 @@ def splitCamelCase(word):
3434
return result
3535

3636

37-
# Map file suffix to file type.
3837
def getMimeType(filepath):
38+
"""Map `filepath`` extension to file type."""
3939

4040
suffix2mime = { '.h': 'text/x-c++',
4141
'.cxx': 'text/x-c++',
@@ -56,11 +56,11 @@ def getMimeType(filepath):
5656
return 'text/plain'
5757

5858

59-
#
60-
# For a regular text file, we don't need to parse it for comments. We
61-
# just pass every line to the spell checked
62-
#
6359
def load_text_file(filename):
60+
"""
61+
For a regular text file, we don't need to parse it for comments. We
62+
just pass every line to the spell checked.
63+
"""
6464

6565
output = []
6666
lc = 0
@@ -73,10 +73,9 @@ def load_text_file(filename):
7373
return output
7474

7575

76-
# The main spell checking procedure
77-
#
7876
def spell_check_file(filename, spell_checker, mime_type='',
7977
output_lvl=1, prefixes=[]):
78+
"""Check spelling in ``filename``."""
8079

8180
if len(mime_type) == 0:
8281
mime_type = getMimeType(filename)
@@ -175,9 +174,9 @@ def spell_check_file(filename, spell_checker, mime_type='',
175174
return bad_words
176175

177176

178-
# Does the file match any pattern in the exclude_list? Then exclude it.
179-
#
180177
def exclude_check(name, exclude_list):
178+
"""Return True if ``name`` matches any of the regular expressions listed in
179+
``exclude_list``."""
181180
if exclude_list is None:
182181
return False
183182
for pattern in exclude_list:
@@ -228,9 +227,9 @@ def parse_args():
228227
return args
229228

230229

231-
# Add the words from a dictionary file into our spell checking dictionary.
232-
#
233230
def add_dict(enchant_dict, filename):
231+
"""Update ``enchant_dict`` spell checking dictionary with the words listed
232+
in ``filename`` (one word per line)."""
234233
with open(filename) as f:
235234
lines = f.read().splitlines()
236235

0 commit comments

Comments
 (0)