Skip to content

Commit

Permalink
Python/indentation error long docs (#5764)
Browse files Browse the repository at this point in the history
fixes Azure/autorest.python#2916

---------

Co-authored-by: iscai-msft <[email protected]>
  • Loading branch information
iscai-msft and iscai-msft authored Jan 28, 2025
1 parent 8e7dd77 commit 34eb706
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@typespec/http-client-python"
---

Fix bug in indentation for wrapping a property description that includes a long url
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
{% set original_result = doc_string | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring=wrap_string) %}
{% set list_result = original_result.split('\n') %}
{% for line in list_result %}
{% set prefix = "" if loop.index == 1 else " " %}
{% set suffix = suffix_string if list_result | length == loop.index %}
{% if line | length > 120 %}
{{ line + " # pylint: disable=line-too-long" }}{{ suffix }}
{{ prefix }}{{ line + " # pylint: disable=line-too-long" }}{{ suffix }}
{% else %}
{{ line }}{{ suffix }}
{{ prefix }}{{ line }}{{ suffix }}
{% endif %}
{% endfor %}
{% endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
{% if model.properties != None %}
{% for p in model.properties %}
{% for line in serializer.variable_documentation_string(p) %}
{% for doc_string in line.replace('\n', '\n ').split('\n') %}
{{ macros.wrap_model_string(doc_string, '\n ') -}}
{% endfor %}
{{ macros.wrap_model_string(line, '\n ') -}}
{% endfor %}
{% endfor %}
{% endif %}
Expand All @@ -37,7 +35,7 @@
{{ serializer.declare_property(p) }}
{% set prop_description = p.description(is_operation_file=False).replace('"', '\\"') %}
{% if prop_description %}
"""{{ macros.wrap_model_string(prop_description, '\n ', '\"\"\"') -}}
"""{{ macros.wrap_model_string(prop_description, '\n ', '\"\"\"') -}}
{% endif %}
{% endfor %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
{% if model.properties != None %}
{% for p in model.properties %}
{% for line in serializer.variable_documentation_string(p) %}
{% for doc_string in line.replace('\n', '\n ').split('\n') %}
{{ macros.wrap_model_string(doc_string, '\n ') -}}
{% endfor %}
{{ macros.wrap_model_string(line, '\n ') -}}
{% endfor %}
{% endfor %}
{% endif %}
Expand Down Expand Up @@ -75,9 +73,7 @@
{% for p in model.properties %}
{% if p.is_input %}
{% for line in serializer.input_documentation_string(p) %}
{% for doc_string in line.replace('\n', '\n ').split('\n') %}
{{ macros.wrap_model_string(doc_string, '\n ') -}}
{% endfor %}
{{ macros.wrap_model_string(line, '\n ') -}}
{% endfor %}
{% endif %}
{% endfor %}
Expand Down

0 comments on commit 34eb706

Please sign in to comment.