tests.sphinx.test_sphinx_myst_docstrings moduleΒΆ
Tests for the MyST-to-reST docstring conversion hook.
- tests.sphinx.test_sphinx_myst_docstrings.test_colon_fence_conversion(myst, expected_fragments)[source]ΒΆ
- tests.sphinx.test_sphinx_myst_docstrings.test_colon_fence_blank_line_before_body()[source]ΒΆ
Converted directive inserts blank line between header and body.
- tests.sphinx.test_sphinx_myst_docstrings.test_backtick_fence_conversion(myst, expected_fragments)[source]ΒΆ
- tests.sphinx.test_sphinx_myst_docstrings.test_mixed_colon_outer_backtick_inner()[source]ΒΆ
Colon fence wrapping a backtick-fenced code block.
- tests.sphinx.test_sphinx_myst_docstrings.test_plain_code_fence_conversion(myst, expected_fragments)[source]ΒΆ
- tests.sphinx.test_sphinx_myst_docstrings.test_plain_code_fence_blank_line_before_body()[source]ΒΆ
Converted plain code fence inserts blank line between header and body.
- tests.sphinx.test_sphinx_myst_docstrings.test_plain_code_fence_not_directive()[source]ΒΆ
Plain code fences must not be confused with directive fences.
- tests.sphinx.test_sphinx_myst_docstrings.test_plain_code_fence_idempotent()[source]ΒΆ
Already-converted code-block directive passes through unchanged.
- tests.sphinx.test_sphinx_myst_docstrings.test_directive_options_follow_the_header(myst, expected)[source]ΒΆ
reST reads options on the lines right under the header, never after a blank line: a blank line there turns them into content.
- tests.sphinx.test_sphinx_myst_docstrings.test_role_opening_a_body_is_not_an_option()[source]ΒΆ
A body opening on a role keeps it as content: an option needs a space after its colon-wrapped name.
- tests.sphinx.test_sphinx_myst_docstrings.test_code_block_content_is_verbatim(myst, expected)[source]ΒΆ
Code is not prose: no backtick, role, link or footnote in it converts.
- tests.sphinx.test_sphinx_myst_docstrings.test_closing_fence_does_not_open_a_code_block()[source]ΒΆ
The bare line closing a directive fence pairs with that fence.
Read as the opener of a plain code fence instead, it would hold everything up to the next bare fence as code, the directive after it included.
- tests.sphinx.test_sphinx_myst_docstrings.test_footnote_reference_conversion(myst, expected)[source]ΒΆ
- tests.sphinx.test_sphinx_myst_docstrings.test_footnote_definition_conversion(myst, expected)[source]ΒΆ
- tests.sphinx.test_sphinx_myst_docstrings.test_footnote_ref_and_def_combined()[source]ΒΆ
Footnote reference and definition in the same docstring.
- tests.sphinx.test_sphinx_myst_docstrings.test_footnote_def_not_matched_as_ref()[source]ΒΆ
Footnote definition must not also produce a spurious reference.
- tests.sphinx.test_sphinx_myst_docstrings.test_link_strips_backticks_from_label(myst, expected)[source]ΒΆ
reST has no nested markup, so backticks are stripped from link labels.
- tests.sphinx.test_sphinx_myst_docstrings.test_double_backtick_span_keeps_its_backticks(myst, expected)[source]ΒΆ
A double-backtick span keeps its single backticks single.
Doubled, they would end the reST literal early: the conversion must parse into whole literals, with no warning.
- tests.sphinx.test_sphinx_myst_docstrings.test_inline_code_no_cross_contamination_with_xref(myst, expected)[source]ΒΆ
Closing backtick of a cross-ref must not pair with inline code.
- tests.sphinx.test_sphinx_myst_docstrings.test_leading_underscore_span_not_a_hyperlink_ref(myst, expected)[source]ΒΆ
A backtick span starting with
_must not be read as a hyperlink ref.The reST hyperlink-reference pattern
` `label`_ `would otherwise let the protection regex span the gap between two inline-code spans (consuming the first spanβs closing backtick and the second spanβs leading underscore), corrupting both. A hyperlink refβs opening backtick is anchored at a non-word boundary, but that alone is not enough: when the first spanβs content ends in a non-word character (`<stdout>`,`f()`), its closing backtick also clears that lookbehind. The refβs trailing marker (_/__) not being glued to an identifier is what rejects the false match while still matching real` `label`_ `references.
- tests.sphinx.test_sphinx_myst_docstrings.test_rst_literals_are_opaque(text)[source]ΒΆ
Double-backtick reST literals pass through every step verbatim.
- tests.sphinx.test_sphinx_myst_docstrings.test_nested_protected_spans_are_restored(text)[source]ΒΆ
A reST literal inside a span protected later comes back whole.
Both are stashed behind placeholders: restored in the wrong order, the inner one would leave its NUL-delimited placeholder in the output.
- tests.sphinx.test_sphinx_myst_docstrings.test_role_shaped_code_span_not_protected_as_role(myst, expected)[source]ΒΆ
Role-shaped text inside a code span is code, wherever the span holds it.
- tests.sphinx.test_sphinx_myst_docstrings.test_idempotent_already_converted()[source]ΒΆ
Running the converter twice produces the same result.
- tests.sphinx.test_sphinx_myst_docstrings.test_idempotent_full_rst_docstring()[source]ΒΆ
A complete reST docstring passes through unchanged.
- tests.sphinx.test_sphinx_myst_docstrings.test_mixed_myst_attribute_then_rst_metadata()[source]ΒΆ
Simulates generate_docstring() output: MyST attribute docstring concatenated with reST metadata lines.
- tests.sphinx.test_sphinx_myst_docstrings.test_all_conversions_combined()[source]ΒΆ
A docstring exercising every conversion step in one pass.
- tests.sphinx.test_sphinx_myst_docstrings.test_myst_inside_field_lists(myst, expected)[source]ΒΆ
MyST inline constructs inside field list entries are converted.
- tests.sphinx.test_sphinx_myst_docstrings.test_full_docstring_with_myst_field_lists()[source]ΒΆ
Realistic docstring with MyST in both prose and field list entries.
- tests.sphinx.test_sphinx_myst_docstrings.test_unsupported_constructs_pass_through(myst, description)[source]ΒΆ
Unsupported MyST constructs pass through unchanged.
- tests.sphinx.test_sphinx_myst_docstrings.test_curly_braces_in_inline_code()[source]ΒΆ
Inline code containing
{and}characters.A standalone
:word:in single backticks is safe: it gets doubled to{word}because the xref regex needs the:word:``targetpattern (two backtick-delimited spans). Double-backtick input also passes through.The dangerous case is
:word:``textwhere the braces plus adjacent backtick-delimited span mimics the xref pattern. Theconvert-to-mystcommand intentionally keeps these as double backticks to avoid this.
- tests.sphinx.test_sphinx_myst_docstrings.test_plain_code_fence_empty_body()[source]ΒΆ
Plain code fence with an empty body.
- tests.sphinx.test_sphinx_myst_docstrings.test_longer_fence_holds_a_shorter_one(myst, expected)[source]ΒΆ
A fence closes on a run of its own length, as in any MyST document.
- tests.sphinx.test_sphinx_myst_docstrings.test_blank_line_opening_a_body_goes_with_the_header()[source]ΒΆ
MyST drops the blank line opening a directive body, options or not.
- tests.sphinx.test_sphinx_myst_docstrings.test_nested_same_type_fences_not_supported()[source]ΒΆ
Nested fences of the same length are not reliably converted.
A colon fence inside a colon fence, or a backtick fence inside a backtick fence, may not parse correctly: a fence closes on the first bare run of its character at least as long as its opener.
- tests.sphinx.test_sphinx_myst_docstrings.test_directive_inside_field_list_not_supported()[source]ΒΆ
Fenced directives inside field list entries do not render correctly.
Field list entries in Sphinx are paragraph-level constructs. Block-level MyST content (admonitions, code blocks) inside them is converted by the regex but wonβt render correctly in Sphinx.
- tests.sphinx.test_sphinx_myst_docstrings.test_link_with_parentheses_in_url()[source]ΒΆ
A URL holding a balanced pair of parentheses is kept whole.
- tests.sphinx.test_sphinx_myst_docstrings.test_consecutive_field_list_entries_all_converted()[source]ΒΆ
Multiple consecutive field list entries each get their content converted.
- tests.sphinx.test_sphinx_myst_docstrings.test_empty_field_list_content()[source]ΒΆ
Field list entries with empty or whitespace-only content.
- tests.sphinx.test_sphinx_myst_docstrings.test_xref_adjacent_to_field_list_colon()[source]ΒΆ
Cross-reference immediately after the field list colon.
- tests.sphinx.test_sphinx_myst_docstrings.test_multiple_xrefs_in_single_field_entry()[source]ΒΆ
Multiple cross-references in one field list entry.
- tests.sphinx.test_sphinx_myst_docstrings.test_link_with_backtick_label_in_field_list()[source]ΒΆ
Markdown link with backtick-wrapped label inside a field list entry.