Skip to content

Commit 0ba4d85

Browse files
alkasmofek
andauthored
pass command.context_settings to new context (#79)
* pass through context_settings to new context * Update CHANGELOG.md * fix --------- Co-authored-by: Ofek Lev <[email protected]>
1 parent 2dcbb2d commit 0ba4d85

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1414

1515
- Remove explicit reference to `click.BaseCommand` and `click.MultiCommand` objects in anticipation of their deprecation. (Pull #82)
1616
- Properly ensure whitespace is trimmed from the usage string. (Pull #83)
17+
- Propagate `context_settings` to `click.Context`-like objects. (Pull #79)
1718

1819
## 0.8.1 - 2023-09-18
1920

mkdocs_click/_docs.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,12 @@ def _recursively_make_command_docs(
9292
def _build_command_context(
9393
prog_name: str, command: click.Command, parent: click.Context | None
9494
) -> click.Context:
95-
return _get_context_class(command)(
96-
cast(click.Command, command), info_name=prog_name, parent=parent
95+
# https://github.com/pallets/click/blob/8.1.8/src/click/core.py#L859-L862
96+
return command.context_class(
97+
cast(click.Command, command),
98+
info_name=prog_name,
99+
parent=parent,
100+
**command.context_settings,
97101
)
98102

99103

@@ -368,11 +372,6 @@ def _make_subcommands_links(
368372
yield ""
369373

370374

371-
def _get_context_class(command: click.Command) -> type[click.Context]:
372-
# https://github.com/pallets/click/blob/8.1.8/src/click/core.py#L859-L862
373-
return command.context_class
374-
375-
376375
def _is_command_group(command: click.Command) -> bool:
377376
# https://github.com/pallets/click/blob/8.1.8/src/click/core.py#L1806-L1811
378377
return isinstance(command, click.Group) or hasattr(command, "command_class")

0 commit comments

Comments
 (0)