diff --git a/docs/guide/users/checking.md b/docs/guide/users/checking.md index 32e5611d..0531baa3 100644 --- a/docs/guide/users/checking.md +++ b/docs/guide/users/checking.md @@ -672,7 +672,7 @@ $ griffe check griffe -ssrc -b0.46.0 -a0.45.0 --verbose [](){#format-markdown} ### Markdown -[:octicons-heart-fill-24:{ .pulse } Sponsors only](../../insiders/index.md){ .insiders } — [:octicons-tag-24: Insiders 1.0.0](../../insiders/changelog.md#1.0.0) +[:octicons-tag-24: Insiders 1.0.0](../../insiders/changelog.md#1.0.0) - **CLI**: `-f markdown` - **API**: `check(..., style="markdown")` / `check(..., style=ExplanationStyle.MARKDOWN)` @@ -705,7 +705,7 @@ The Markdown format is adapted for changelogs. It doesn't show the file and line [](){#format-github} ### GitHub -[:octicons-heart-fill-24:{ .pulse } Sponsors only](../../insiders/index.md){ .insiders } — [:octicons-tag-24: Insiders 1.0.0](../../insiders/changelog.md#1.0.0) +[:octicons-tag-24: Insiders 1.0.0](../../insiders/changelog.md#1.0.0) - **CLI**: `-f github` - **API**: `check(..., style="github")` / `check(..., style=ExplanationStyle.GITHUB)` diff --git a/src/_griffe/cli.py b/src/_griffe/cli.py index 4658ca25..8c819d1a 100644 --- a/src/_griffe/cli.py +++ b/src/_griffe/cli.py @@ -318,7 +318,7 @@ def add_subparser(command: str, text: str, **kwargs: Any) -> argparse.ArgumentPa help="Force disable colors in the output.", ) check_options.add_argument("-v", "--verbose", action="store_true", help="Verbose output.") - formats = ("oneline", "verbose") + formats = [fmt.value for fmt in ExplanationStyle] check_options.add_argument("-f", "--format", dest="style", choices=formats, default=None, help="Output format.") add_common_options(check_parser) diff --git a/src/_griffe/diff.py b/src/_griffe/diff.py index 9b33b172..0cf8fce2 100644 --- a/src/_griffe/diff.py +++ b/src/_griffe/diff.py @@ -193,10 +193,46 @@ def _explain_verbose(self) -> str: return "\n".join(lines) def _explain_markdown(self) -> str: - return self._explain_oneline() + explanation = f"- `{self._canonical_path}`: *{self.kind.value}*" + old = self._format_old_value() + if old != "unset": + old = f"`{old}`" + new = self._format_new_value() + if new != "unset": + new = f"`{new}`" + if old and new: + change = f"{old} -> {new}" + elif old: + change = old + elif new: + change = new + else: + change = "" + if change: + return f"{explanation}: {change}" + return explanation def _explain_github(self) -> str: - return self._explain_oneline() + location = f"file={self._location},line={self._lineno}" + title = f"title={self._format_title()}" + explanation = f"::warning {location},{title}::{self.kind.value}" + old = self._format_old_value() + if old != "unset": + old = f"`{old}`" + new = self._format_new_value() + if new != "unset": + new = f"`{new}`" + if old and new: + change = f"{old} -> {new}" + elif old: + change = old + elif new: + change = new + else: + change = "" + if change: + return f"{explanation}: {change}" + return explanation class ParameterMovedBreakage(Breakage):