tests.sphinx.test_sphinx_click_config moduleΒΆ

Tests for the click:config Sphinx directive.

class tests.sphinx.test_sphinx_click_config.BasketConfig(apples=3)[source]ΒΆ

Bases: object

Nested sub-table exercising the dotted-key expansion.

apples: int = 3ΒΆ

How many apples fit in the basket.

class tests.sphinx.test_sphinx_click_config.MarketConfig(city='Lisbon', stalls=<factory>, basket=BasketConfig())[source]ΒΆ

Bases: object

Toy schema reused across tests.

Defined at module level (not inside a click:source block) so inspect.getsource can recover the attribute docstrings.

city: str = 'Lisbon'ΒΆ

City where the market is held.

The market moves to the main square during summer, and to the covered hall the rest of the year.

stalls: list[str]ΒΆ

Stall types allowed on the premises.

basket: BasketConfigΒΆ

Parent table docstring, never rendered: only leaves get sections.

tests.sphinx.test_sphinx_click_config.MARKET_SEED = '```{click:source}\n:hide-source:\nfrom tests.sphinx.test_sphinx_click_config import market\n```\n'ΒΆ

Seed block importing the module-level CLI into the runner namespace.

class tests.sphinx.test_sphinx_click_config.PastryConfig(creme_brulee='vanilla|caramel', five_spice=5)[source]ΒΆ

Bases: object

Schema whose keys need slugging and whose default needs escaping.

creme_brulee: str = 'vanilla|caramel'ΒΆ

Flavors of the custard, separated by pipes.

five_spice: int = 5ΒΆ

How many spices go into the powder.

tests.sphinx.test_sphinx_click_config.PASTRY_CONFIG = '\n```{click:config} PastryConfig\nfrom tests.sphinx.test_sphinx_click_config import PastryConfig\n```\n'ΒΆ

Directive documenting PastryConfig.

tests.sphinx.test_sphinx_click_config.test_click_config_default_and_toml_literal(value, default, literal)[source]ΒΆ

A default renders in the table, and as the literal of its TOML example.

tests.sphinx.test_sphinx_click_config.test_click_config_renders_table_and_sections(sphinx_app_myst)[source]ΒΆ

The directive expands into a summary table + one section per option.

Each table link lands on the id docutils gives the option’s heading.

make_id writes the accented letters of crème-brûlée as their ASCII base, and drops the leading digit of 5-spice.

tests.sphinx.test_sphinx_click_config.test_click_config_keeps_a_piped_default_in_its_cell(sphinx_app_myst)[source]ΒΆ

A pipe in a default value stays text, rather than splitting its row.

tests.sphinx.test_sphinx_click_config.test_click_config_toml_examples(sphinx_app_myst)[source]ΒΆ

Each option gets a TOML example pinned to its default value.

The section header defaults to tool.{cli-name}, matching how click-extra and its downstream CLIs read their section from pyproject.toml.

tests.sphinx.test_sphinx_click_config.test_click_config_section_override_and_suppress(sphinx_app_myst)[source]ΒΆ

:section: overrides the example header; an empty value drops it.

tests.sphinx.test_sphinx_click_config.test_click_config_bare_schema_argument(sphinx_app_myst)[source]ΒΆ

A dataclass argument documents the schema without any CLI wired.

Without a CLI there is no name to derive the section header from, so the examples render bare assignments.

tests.sphinx.test_sphinx_click_config.test_click_config_no_table_and_no_examples(sphinx_app_myst)[source]ΒΆ

:no-table: and :no-examples: drop their blocks.

tests.sphinx.test_sphinx_click_config.test_click_config_exec_defined_schema_lacks_docstrings(sphinx_app_myst)[source]ΒΆ

A schema defined in an exec’d block renders without descriptions.

tests.sphinx.test_sphinx_click_config.test_click_config_errors_without_schema(sphinx_app_myst)[source]ΒΆ

A CLI with no config_schema raises a clear directive error.

tests.sphinx.test_sphinx_click_config.test_click_config_errors_on_non_schema(sphinx_app_myst)[source]ΒΆ

Resolving the argument to a non-dataclass raises a clear error.

tests.sphinx.test_sphinx_click_config.test_click_config_errors_on_unknown_name(sphinx_app_myst)[source]ΒΆ

An expression that can’t be evaluated raises a clear directive error.

tests.sphinx.test_sphinx_click_config.test_click_config_errors_in_rst(sphinx_app_rst)[source]ΒΆ

click:config raises a clear error when used in an rST document.

tests.sphinx.test_sphinx_click_config.test_click_config_heading_offset_adapts_to_surrounding_section(sphinx_app_myst)[source]ΒΆ

Nested inside an h2 section, option headings render at h3.

class tests.sphinx.test_sphinx_click_config.OrchardConfig(trees=12, rows=4, seasons=<factory>)[source]ΒΆ

Bases: object

Schema whose docstrings make Markdown headings, or look like they do.

trees: int = 12ΒΆ

How many trees grow in the orchard.

Pear and apple trees alternate along each row, so no row holds a single = kind of fruit.

rows: int = 4ΒΆ

How many rows the trees stand in.

# Pruning

Each row is pruned in winter.

seasons: list[str]ΒΆ

Harvest seasons.

# A comment in a code block
---
tests.sphinx.test_sphinx_click_config.test_click_config_warns_on_docstring_heading(sphinx_app_myst)[source]ΒΆ

Each heading in an option docstring is reported at its docstring line.

The lone = makes a setext heading of the paragraph above it, # Pruning is an ATX heading, and the lines of a code block are no heading at all.