Skip to content

Commit 7b51467

Browse files
fix(docs): align DeadCode copy and verify its command syntax
1 parent c15b563 commit 7b51467

5 files changed

Lines changed: 37 additions & 2 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,14 @@ jobs:
6565
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
6666
with:
6767
python-version: '3.12'
68-
- name: Install the four documented CLI tools
68+
- name: Install the documented CLI tools
6969
run: >-
7070
pip install pytest pyyaml
7171
git+https://github.com/Coding-Dev-Tools/api-contract-guardian.git
7272
git+https://github.com/Coding-Dev-Tools/json2sql.git
7373
git+https://github.com/Coding-Dev-Tools/deploydiff.git
7474
git+https://github.com/Coding-Dev-Tools/configdrift.git
75+
git+https://github.com/Coding-Dev-Tools/deadcode.git
7576
- name: Exercise rendered CI examples with dummy data
7677
env:
7778
DEVFORGE_UPSTREAM_SMOKE: '1'

‎alternatives.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ <h2>DeadCode <span class="vs">vs</span> knip</h2>
504504
<tbody>
505505
<tr>
506506
<td>Unused export detection</td>
507-
<td class="yes">Yes — compiler API</td>
507+
<td class="yes">Yes — regex-based scanning</td>
508508
<td class="yes">Yes — AST analysis</td>
509509
</tr>
510510
<tr>

‎quickstart.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ <h2>Run your first check</h2>
240240

241241
<div class="code-block">
242242
<div class="header"><span>DeadCode</span></div>
243+
<p>Set the global <code>--project</code> option before the <code>scan</code> subcommand.</p>
243244
<pre><code><span class="comment"># Scan for unused exports in a TypeScript project</span>
244245
<span class="cmd">deadcode</span> <span class="flag">--project</span> /path/to/ts-project <span class="cmd">scan</span></code></pre>
245246
</div>

‎tests/test_ci_examples.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,19 @@ def test_deploy_requires_all_validation_jobs():
8080
root = Path(__file__).resolve().parents[1]
8181
ci = yaml.safe_load((root / ".github/workflows/ci.yml").read_text())
8282
assert {"test", "linkcheck", "html-validate", "pages-artifact", "cli-example-smoke"} <= set(ci["jobs"]["deploy"]["needs"])
83+
84+
85+
@pytest.mark.skipif(os.environ.get("DEVFORGE_UPSTREAM_SMOKE") != "1", reason="run in the CLI Example Smoke job")
86+
def test_rendered_deadcode_quickstart_scans_a_dummy_project(tmp_path):
87+
import shlex
88+
89+
assert shutil.which("deadcode"), "Smoke job must install DeadCode"
90+
project = tmp_path / "typescript-project"
91+
project.mkdir()
92+
(project / "index.ts").write_text("export const unusedDummy = 1;\n")
93+
block = next(block for block in code_blocks("quickstart.html") if "deadcode " in block and "pip install" not in block)
94+
line = next(line.strip() for line in block.splitlines() if line.strip().startswith("deadcode "))
95+
args = [str(project) if arg == "/path/to/ts-project" else arg for arg in shlex.split(line)]
96+
result = subprocess.run(args, cwd=tmp_path, capture_output=True, text=True)
97+
assert result.returncode == 0, result.stdout + result.stderr
98+
assert "No such option" not in result.stderr

‎tests/test_install_copy.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,20 @@ def test_schemaforge_public_copy_matches_supported_formats_and_limits():
144144
if page.name == "schemaforge-v1-7-0-vscode-extension.html":
145145
for unsupported in ["Protobuf", "Avro", "OpenAPI"]:
146146
assert unsupported not in copy, page
147+
148+
149+
def test_deadcode_comparison_describes_the_regex_scanner():
150+
text = (ROOT / "alternatives.html").read_text(encoding="utf-8")
151+
comparison = text.split('id="deadcode-vs-knip"', 1)[1]
152+
cell = re.search(r"<td>Unused export detection</td>\s*<td[^>]*>(.*?)</td>", comparison)
153+
assert cell is not None
154+
assert "regex-based scanning" in cell.group(1)
155+
assert "compiler API" not in cell.group(1)
156+
157+
158+
def test_deadcode_quickstart_uses_the_top_level_project_option():
159+
# The published console entry point is deadcode.cli:cli. Its --project
160+
# option is declared on the Click group, not on the scan subcommand.
161+
command = next(block for block in code_blocks("quickstart.html") if "deadcode " in block and "pip install" not in block)
162+
line = next(line.strip() for line in command.splitlines() if line.strip().startswith("deadcode "))
163+
assert shlex.split(line) == ["deadcode", "--project", "/path/to/ts-project", "scan"]

0 commit comments

Comments
 (0)