Skip to content

Commit 050853e

Browse files
authored
EN #4348 flatten new-lines in arg descriptions (#50)
* EN #4348 flatten new-lines in arg descriptions * EN #4348 bump version to 0.3.7.dev4
1 parent 93cff00 commit 050853e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

polyapi/utils.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,12 @@ def _maybe_add_fallback_schema_name(a: PropertySpecification):
222222
schema["title"] = a["name"].title()
223223

224224

225+
def _clean_description(text: str) -> str:
226+
"""Flatten new-lines and collapse excess whitespace."""
227+
text = text.replace("\\n", " ").replace("\n", " ")
228+
return re.sub(r"\s+", " ", text).strip()
229+
230+
225231
def parse_arguments(
226232
function_name: str, arguments: List[PropertySpecification]
227233
) -> Tuple[str, str]:
@@ -248,8 +254,8 @@ def parse_arguments(
248254
if not a.get("required", True):
249255
arg_string += " = None"
250256

251-
description = a.get("description", "")
252-
description = description.replace("\n", " ")
257+
description = _clean_description(a.get("description", ""))
258+
253259
if description:
254260
if idx == len(arguments) - 1:
255261
arg_string += f" # {description}\n"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools>=61.2", "wheel"]
33

44
[project]
55
name = "polyapi-python"
6-
version = "0.3.7.dev3"
6+
version = "0.3.7.dev4"
77
description = "The Python Client for PolyAPI, the IPaaS by Developers for Developers"
88
authors = [{ name = "Dan Fellin", email = "dan@polyapi.io" }]
99
dependencies = [

0 commit comments

Comments
 (0)