-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix parameter names during docstring generation
- Loading branch information
Showing
5 changed files
with
98 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env python3 | ||
|
||
"""Fixes errors in Docstrings.hpp.""" | ||
|
||
import re | ||
import sys | ||
|
||
|
||
def main(): | ||
# sys.argv[1] should be the filepath of Docstrings.hpp | ||
filename = sys.argv[1] | ||
|
||
with open(filename) as f: | ||
content = f.read() | ||
|
||
# Convert parameter names from camel case to snake case | ||
new_content = "" | ||
extract_location = 0 | ||
for match in re.finditer(r"(?<=Parameter ``)(.*?)(?=``:)", content): | ||
new_content += content[extract_location : match.start()] | ||
param = match.group() | ||
for i in range(len(param)): | ||
# Replace uppercase letter preceded by lowercase letter with | ||
# underscore and lowercase version of letter | ||
if i > 0 and param[i - 1].islower() and param[i].isupper(): | ||
new_content += "_" + param[i].lower() | ||
else: | ||
new_content += param[i] | ||
extract_location = match.end() | ||
content = new_content + content[extract_location:] | ||
|
||
with open(filename, mode="w") as f: | ||
f.write(content) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.