fix(http-client-python): keep Sphinx docstring annotations out of trailing code blocks#11013
Open
l0lawrence wants to merge 3 commits into
Open
fix(http-client-python): keep Sphinx docstring annotations out of trailing code blocks#11013l0lawrence wants to merge 3 commits into
l0lawrence wants to merge 3 commits into
Conversation
…iling code blocks Append annotations like Required. as their own paragraph after a trailing RST code block, and skip the sentence-ending period when a description ends with a code block so it no longer lands inside the rendered literal block. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
commit: |
Contributor
|
All changed packages have been documented.
Show changes
|
… inline marker mentions Require the .. code-block:: directive to start its own line so an inline mention in prose is not mistaken for a trailing code block. Add tests covering multiple code blocks and the inline-mention case. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
You can try these changes here
|
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Why
Follow-up to #10955. That change kept the broken
]. Required.from rendering, but two related issues remained for docstrings whose description ends with an RST code block (e.g.ToolChoiceAllowed.toolsinazure-ai-projects):Required.was inserted into the prose right before the code block, so it landed on the lead-in sentence:...might look like: Required.followed by the block. That reads wrong.preprocess.update_descriptionstill appended a sentence-ending.to the description, which landed on the code block's last content line (]->].), corrupting the rendered literal block.What
description_ends_with_code_blockhelper (inpygen/utils.py) that detects when a code block is the trailing content of a description.add_to_description: when the description ends with a code block, append the annotation (Required., default value, etc.) as its own paragraph after the block instead of inline. Chained annotations group onto that trailing paragraph. Behavior is unchanged when there is no trailing code block, or when prose follows the block.update_description: skip the trailing-period append when the description ends with a code block, so no.is injected into the block.Result
For
ToolChoiceAllowed.tools:`
:ivar tools: A list of tool definitions ... might look like:
.. code-block:: json
Required.
`
No
].inside the block, andRequired.sits cleanly on its own line.Covered by unit tests in
tests/unit/test_add_to_description.py(10 tests, including the fullupdate_description->add_to_descriptionpipeline).