Skip to content

Commit 9f4925b

Browse files
raifdmuellerclaude
andcommitted
fix: add blockquote to CLI valid_types (#270)
blockquote was listed in --help but rejected at runtime by the valid_types check. Add it to the set so it matches the model definition. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e3b3b9a commit 9f4925b

File tree

5 files changed

+68
-4
lines changed

5 files changed

+68
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "dacli"
3-
version = "0.4.30"
3+
version = "0.4.31"
44
description = "Documentation Access CLI - Navigate and query large documentation projects"
55
readme = "README.md"
66
license = { text = "MIT" }

src/dacli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
"""
66

77

8-
__version__ = "0.4.30"
8+
__version__ = "0.4.31"

src/dacli/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ def elements(ctx: CliContext, section_path: str | None, element_type: str | None
621621
recursive: bool, include_content: bool, content_limit: int | None):
622622
"""Get elements (code blocks, tables, images) from documentation."""
623623
# Issue #225: Validate element type and warn if invalid
624-
valid_types = {"code", "table", "image", "plantuml", "admonition", "list"}
624+
valid_types = {"code", "table", "image", "plantuml", "admonition", "list", "blockquote"}
625625
if element_type is not None and element_type not in valid_types:
626626
valid_list = ", ".join(sorted(valid_types))
627627
click.echo(f"Warning: Unknown element type '{element_type}'. Valid types are: {valid_list}")

tests/test_blockquote_type_270.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
"""Tests for blockquote element type consistency (Issue #270).
2+
3+
blockquote is listed in --help but rejected at runtime by valid_types check.
4+
"""
5+
6+
from click.testing import CliRunner
7+
8+
from dacli.cli import cli
9+
10+
11+
class TestBlockquoteElementType:
12+
"""blockquote must be accepted as a valid element type."""
13+
14+
def test_blockquote_no_warning(self, tmp_path):
15+
"""Passing --type blockquote must not produce an 'Unknown element type' warning."""
16+
doc = tmp_path / "test.md"
17+
doc.write_text("# Test\n\n> A blockquote\n")
18+
19+
runner = CliRunner()
20+
result = runner.invoke(cli, [
21+
"--docs-root", str(tmp_path),
22+
"--format", "json",
23+
"elements",
24+
"--type", "blockquote",
25+
])
26+
27+
assert "Unknown element type" not in result.output, (
28+
f"blockquote rejected as unknown: {result.output}"
29+
)
30+
31+
def test_valid_types_match_help_text(self):
32+
"""All types listed in --help must be in valid_types."""
33+
runner = CliRunner()
34+
result = runner.invoke(cli, ["elements", "--help"])
35+
36+
# Extract types from help text
37+
# Help says: "Element type: admonition, blockquote, code, image, list, plantuml, table"
38+
assert "blockquote" in result.output, "blockquote missing from --help"
39+
40+
def test_all_model_element_types_accepted(self, tmp_path):
41+
"""Every ElementType in the model should be accepted by CLI validation."""
42+
from dacli.models import Element
43+
44+
doc = tmp_path / "test.md"
45+
doc.write_text("# Test\n\nSome content.\n")
46+
47+
runner = CliRunner()
48+
# Get all valid types from the Element model's type field
49+
# The Literal type annotation lists all valid values
50+
import typing
51+
type_hints = typing.get_type_hints(Element)
52+
# Element.type is Literal["code", "table", ...]
53+
literal_args = typing.get_args(type_hints["type"])
54+
55+
for etype in literal_args:
56+
result = runner.invoke(cli, [
57+
"--docs-root", str(tmp_path),
58+
"--format", "json",
59+
"elements",
60+
"--type", etype,
61+
])
62+
assert "Unknown element type" not in result.output, (
63+
f"Element type '{etype}' rejected by CLI but defined in model"
64+
)

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)