Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .chronus/changes/python-fix-docstring-2025-11-10-10-23-28.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@typespec/http-client-python"
---

Fix bad indent
6 changes: 5 additions & 1 deletion packages/http-client-python/eng/scripts/ci/regenerate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const argv = parseArgs({
});

// Add this near the top with other constants
const SKIP_SPECS = ["type/union/discriminated", "documentation"];
const SKIP_SPECS = ["type/union/discriminated"];

// Get the directory of the current file
const PLUGIN_DIR = argv.values.pluginDir
Expand Down Expand Up @@ -272,6 +272,10 @@ const EMITTER_OPTIONS: Record<string, Record<string, string> | Record<string, st
"package-name": "typetest-union",
namespace: "typetest.union",
},
documentation: {
"package-name": "specs-documentation",
namespace: "specs.documentation",
},
};

function toPosix(dir: string): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,28 @@
{% set enable_custom_handling = "\n* " in doc_string or doc_string.startswith("* ") %}
{%- if enable_custom_handling -%}
{%- set lines = doc_string.split('\n') -%}
{%- set base_indent = wrap_string.lstrip('\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) -%}
{%- set line_indent = '' if line.strip().startswith(':') or loop.index == 1 else (base_indent + ' ') -%}
{%- set wrapped = (line_indent + line) | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring=wrap_string) -%}
{%- for line in wrapped.split('\n') -%}
{%- set prefix = "" if loop.index == 1 else " " -%}
{%- set _ = result_lines.append(prefix + line) -%}
{%- endfor -%}
{%- else -%}
{%- set _ = result_lines.append('') -%}
{# Do not add continuous blank lines #}
{%- if (result_lines and result_lines[-1] != '') or not result_lines -%}
{%- set _ = result_lines.append('') -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- set original_result = result_lines | join('\n') -%}
Expand All @@ -37,4 +44,4 @@
{% set suffix = suffix_string if list_result | length == loop.index %}
{{ prefix }}{{ line }}{{ suffix }}
{% endfor %}
{% endmacro %}
{% endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ azure-mgmt-core==1.6.0
-e ./generated/authentication-oauth2
-e ./generated/authentication-union
-e ./generated/setuppy-authentication-union
-e ./generated/specs-documentation
-e ./generated/encode-duration
-e ./generated/encode-numeric
-e ./generated/encode-array
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------

import pytest
from specs.documentation.aio import DocumentationClient
from specs.documentation import models


@pytest.fixture
async def client():
async with DocumentationClient(endpoint="http://localhost:3000") as client:
yield client


class TestLists:
@pytest.mark.asyncio
async def test_bullet_points_op(self, client: DocumentationClient):
# GET /documentation/lists/bullet-points/op
# Expected: 204 No Content
await client.lists.bullet_points_op()

@pytest.mark.skip(reason="https://github.com/microsoft/typespec/issues/9173")
@pytest.mark.asyncio
async def test_bullet_points_model(self, client: DocumentationClient):
# POST /documentation/lists/bullet-points/model
# Expected request body: {"prop": "Simple"}
# Expected: 200 OK
await client.lists.bullet_points_model(input=models.BulletPointsModel(prop="Simple"))

# Also test with JSON
await client.lists.bullet_points_model(body={"input": {"prop": "Simple"}})

@pytest.mark.asyncio
async def test_numbered(self, client: DocumentationClient):
# GET /documentation/lists/numbered
# Expected: 204 No Content
await client.lists.numbered()


class TestTextFormatting:
@pytest.mark.asyncio
async def test_bold_text(self, client: DocumentationClient):
# GET /documentation/text-formatting/bold
# Expected: 204 No Content
await client.text_formatting.bold_text()

@pytest.mark.asyncio
async def test_italic_text(self, client: DocumentationClient):
# GET /documentation/text-formatting/italic
# Expected: 204 No Content
await client.text_formatting.italic_text()

@pytest.mark.asyncio
async def test_combined_formatting(self, client: DocumentationClient):
# GET /documentation/text-formatting/combined
# Expected: 204 No Content
await client.text_formatting.combined_formatting()
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------

import pytest
from specs.documentation import DocumentationClient, models


@pytest.fixture
def client():
with DocumentationClient(endpoint="http://localhost:3000") as client:
yield client


class TestLists:
def test_bullet_points_op(self, client: DocumentationClient):
# GET /documentation/lists/bullet-points/op
# Expected: 204 No Content
client.lists.bullet_points_op()

@pytest.mark.skip(reason="https://github.com/microsoft/typespec/issues/9173")
def test_bullet_points_model(self, client: DocumentationClient):
# POST /documentation/lists/bullet-points/model
# Expected: 200 OK
client.lists.bullet_points_model(input=models.BulletPointsModel(prop="Simple"))

# Also test with JSON
client.lists.bullet_points_model(body={"input": {"prop": "Simple"}})

def test_numbered(self, client: DocumentationClient):
# GET /documentation/lists/numbered
# Expected: 204 No Content
client.lists.numbered()


class TestTextFormatting:
def test_bold_text(self, client: DocumentationClient):
# GET /documentation/text-formatting/bold
# Expected: 204 No Content
client.text_formatting.bold_text()

def test_italic_text(self, client: DocumentationClient):
# GET /documentation/text-formatting/italic
# Expected: 204 No Content
client.text_formatting.italic_text()

def test_combined_formatting(self, client: DocumentationClient):
# GET /documentation/text-formatting/combined
# Expected: 204 No Content
client.text_formatting.combined_formatting()
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
-e ./generated/authentication-oauth2
-e ./generated/authentication-union
-e ./generated/setuppy-authentication-union
-e ./generated/specs-documentation
-e ./generated/encode-duration
-e ./generated/encode-numeric
-e ./generated/encode-array
Expand Down
Loading