Skip to content

Commit

Permalink
Fix doc strings that are too long and generate error on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
SamFlt committed Feb 2, 2024
1 parent e628909 commit 31e0650
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions modules/python/generator/visp_python_bindgen/doc_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,18 @@ def to_cstring(s: str) -> str:
s = re.sub('\n\n\n+', '\n\n', s)
s = re.sub('\\\\ +', '\\\\', s)

return f'''R"doc(
{s}
)doc"'''
# On Windows, strings have a maximum length.
per_string_limit = 8192
current_char = 0
result = ''
while current_char < len(s):
result += f'''R"doc(
{s[current_char: min((current_char + per_string_limit), len(s))]})doc"
'''
current_char += per_string_limit
return result


@dataclass
class MethodDocSignature:
Expand Down

0 comments on commit 31e0650

Please sign in to comment.