From e2b55f6242fa85f4ad15b10c4b0e6f54ad1580bb Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Thu, 16 Oct 2025 16:11:15 -0400 Subject: [PATCH 1/3] test new bulelt point fix --- .../pygen/codegen/templates/macros.jinja2 | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/packages/http-client-python/generator/pygen/codegen/templates/macros.jinja2 b/packages/http-client-python/generator/pygen/codegen/templates/macros.jinja2 index 8370863ceb1..a348736d775 100644 --- a/packages/http-client-python/generator/pygen/codegen/templates/macros.jinja2 +++ b/packages/http-client-python/generator/pygen/codegen/templates/macros.jinja2 @@ -1,8 +1,38 @@ {% macro wrap_model_string(doc_string, wrap_string, suffix_string="") %} -{% set original_result = doc_string | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring=wrap_string) %} +{# Check if this is a sphinx documentation line that should not have extra prefix spacing #} +{%- set is_sphinx_doc = doc_string.strip().startswith(':ivar') or doc_string.strip().startswith(':vartype') or doc_string.strip().startswith(':param') or doc_string.strip().startswith(':type') -%} +{# Custom handling for bullet points - normalization is now done in preprocessing #} +{%- if '* ' in doc_string -%} + {%- set lines = doc_string.split('\n') -%} + {%- set result_lines = [] -%} + {%- for line in lines -%} + {%- if line.startswith('* ') -%} + {# Handle bullet points with proper continuation alignment #} + {%- set bullet_content = line[2:] -%} + {%- set base_indent = wrap_string.lstrip('\n') -%} + {%- set bullet_line = base_indent + ' * ' + bullet_content -%} + {%- set continuation_spaces = base_indent + ' ' -%} + {%- set wrapped = bullet_line | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n' + continuation_spaces) -%} + {%- set _ = result_lines.append(wrapped) -%} + {%- elif line.strip() -%} + {%- set wrapped = line.strip() | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring=wrap_string) -%} + {%- set _ = result_lines.append(wrapped) -%} + {%- else -%} + {%- set _ = result_lines.append('') -%} + {%- endif -%} + {%- endfor -%} + {%- set original_result = result_lines | join('\n') -%} +{%- else -%} + {# Regular text handling #} + {%- set original_result = doc_string | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring=wrap_string) -%} +{%- endif -%} {% set list_result = original_result.split('\n') %} {% for line in list_result %} - {% set prefix = "" if loop.index == 1 else " " %} + {%- if is_sphinx_doc -%} + {%- set prefix = "" -%} + {%- else -%} + {%- set prefix = "" if loop.index == 1 else " " -%} + {%- endif -%} {% set suffix = suffix_string if list_result | length == loop.index %} {{ prefix }}{{ line }}{{ suffix }} {% endfor %} From 40e1a6ced21f9ac76139619c9d6564fd4c98ef6f Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Thu, 16 Oct 2025 16:11:47 -0400 Subject: [PATCH 2/3] add changeset --- .chronus/changes/python-addBullet-2025-9-16-16-11-41.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .chronus/changes/python-addBullet-2025-9-16-16-11-41.md diff --git a/.chronus/changes/python-addBullet-2025-9-16-16-11-41.md b/.chronus/changes/python-addBullet-2025-9-16-16-11-41.md new file mode 100644 index 00000000000..b8ef587d651 --- /dev/null +++ b/.chronus/changes/python-addBullet-2025-9-16-16-11-41.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/http-client-python" +--- + +Additional fixes to documentation with bullet points \ No newline at end of file From c26a154971ab7876e6920630db21dfabb74ab02b Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Fri, 17 Oct 2025 01:44:12 +0000 Subject: [PATCH 3/3] fix --- .../generator/pygen/codegen/templates/macros.jinja2 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/http-client-python/generator/pygen/codegen/templates/macros.jinja2 b/packages/http-client-python/generator/pygen/codegen/templates/macros.jinja2 index a348736d775..1cc18a904ef 100644 --- a/packages/http-client-python/generator/pygen/codegen/templates/macros.jinja2 +++ b/packages/http-client-python/generator/pygen/codegen/templates/macros.jinja2 @@ -2,7 +2,8 @@ {# Check if this is a sphinx documentation line that should not have extra prefix spacing #} {%- set is_sphinx_doc = doc_string.strip().startswith(':ivar') or doc_string.strip().startswith(':vartype') or doc_string.strip().startswith(':param') or doc_string.strip().startswith(':type') -%} {# Custom handling for bullet points - normalization is now done in preprocessing #} -{%- if '* ' in doc_string -%} +{% set enable_custom_handling = "* " in doc_string %} +{%- if enable_custom_handling -%} {%- set lines = doc_string.split('\n') -%} {%- set result_lines = [] -%} {%- for line in lines -%} @@ -28,7 +29,7 @@ {%- endif -%} {% set list_result = original_result.split('\n') %} {% for line in list_result %} - {%- if is_sphinx_doc -%} + {%- if is_sphinx_doc and enable_custom_handling -%} {%- set prefix = "" -%} {%- else -%} {%- set prefix = "" if loop.index == 1 else " " -%}