Skip to content

Commit 9d75339

Browse files
committed
implemented the --show-all and --export-files options for the aditi check command
1 parent 2c21a47 commit 9d75339

File tree

5 files changed

+203
-14
lines changed

5 files changed

+203
-14
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
layout: post
3+
title: "Improved File List Handling in aditi check Command"
4+
date: 2025-08-29 14:25:00 -0400
5+
author: Aditi Development Team
6+
tags: [features, ui, usability]
7+
summary: "New options for complete file list visibility in check command output"
8+
---
9+
10+
## Better Visibility for Large-Scale DITA Migration Projects
11+
12+
When working with large documentation repositories, the `aditi check` command helps identify DITA compatibility issues across hundreds or even thousands of AsciiDoc files. Previously, when a rule violation affected many files, the output would truncate the file list after 10 entries, showing "... and X more" to keep the terminal output manageable.
13+
14+
While this truncation keeps the output clean, users often need to see the complete list of affected files for planning and tracking purposes. Today's update introduces two new options that give you full control over how file lists are displayed.
15+
16+
## New Options
17+
18+
### `--show-all` Flag
19+
20+
The `--show-all` flag displays all affected files directly in the terminal without truncation:
21+
22+
```bash
23+
aditi check --rule ContentType --show-all
24+
```
25+
26+
This is particularly useful when you need to quickly see all affected files for a specific rule violation without exporting to a file.
27+
28+
### `--export-files` Option
29+
30+
For more permanent records or when dealing with very large file lists, the `--export-files` option saves the complete list to a file:
31+
32+
```bash
33+
aditi check --export-files violations-report.txt
34+
```
35+
36+
The exported file includes:
37+
- Generation timestamp
38+
- Total files processed and issues found
39+
- Files grouped by rule name
40+
- Sorted file paths for easy navigation
41+
42+
Example export format:
43+
```
44+
# Aditi Check Results - Files with Issues
45+
# Generated: 2025-08-29T14:25:22.565988
46+
# Total files: 150
47+
# Total issues: 342
48+
49+
## ContentType (45 files)
50+
- modules/getting-started.adoc
51+
- modules/installation-guide.adoc
52+
- modules/troubleshooting.adoc
53+
...
54+
55+
## EntityReference (23 files)
56+
- assemblies/product-overview.adoc
57+
- assemblies/quick-start.adoc
58+
...
59+
```
60+
61+
## Using Both Options Together
62+
63+
You can combine both options for maximum flexibility:
64+
65+
```bash
66+
aditi check --show-all --export-files full-report.txt --rule BlockTitle
67+
```
68+
69+
This displays all files in the terminal while also creating a permanent record.
70+
71+
## Consistent Experience Across Commands
72+
73+
The same file list display logic is now used in both the `check` command and the `journey` command, ensuring a consistent user experience throughout the tool.
74+
75+
## Implementation Details
76+
77+
The implementation adds a reusable `_display_file_list()` helper method to the processor module, which handles:
78+
- Truncation logic (show 10 files by default)
79+
- Full display when requested
80+
- Consistent formatting across different commands
81+
82+
This approach maintains backward compatibility while providing the flexibility needed for large-scale documentation projects.
83+
84+
## Next Steps
85+
86+
These improvements make it easier to track and manage DITA migration progress across large documentation sets. Combined with the journey workflow, teams can now better plan and execute their migration strategies with full visibility into the scope of work required.
87+
88+
Try out the new options with:
89+
```bash
90+
aditi check --help
91+
```
92+
93+
Happy migrating!

src/aditi/cli.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,24 @@ def check(
156156
help="Check only specific rule (e.g., EntityReference)",
157157
),
158158
verbose: bool = verbose_option,
159+
show_all: bool = typer.Option(
160+
False,
161+
"--show-all",
162+
help="Show all affected files without truncation",
163+
),
164+
export_files: Optional[Path] = typer.Option(
165+
None,
166+
"--export-files",
167+
help="Export full list of affected files to specified file",
168+
),
159169
) -> None:
160170
"""Check AsciiDoc files for DITA compatibility issues.
161171
162172
Runs Vale with AsciiDocDITA rules to identify issues that need
163173
to be addressed before migration to DITA.
164174
"""
165175
setup_logging(verbose)
166-
check_command(paths, rule, verbose)
176+
check_command(paths, rule, verbose, show_all, export_files)
167177

168178

169179
@app.command()

src/aditi/commands/check.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ def check_command(
3636
"-v",
3737
help="Show detailed violation information",
3838
),
39+
show_all: bool = typer.Option(
40+
False,
41+
"--show-all",
42+
help="Show all affected files without truncation",
43+
),
44+
export_files: Optional[Path] = typer.Option(
45+
None,
46+
"--export-files",
47+
help="Export full list of affected files to specified file",
48+
),
3949
) -> None:
4050
"""Check AsciiDoc files for DITA compatibility issues.
4151
@@ -184,10 +194,10 @@ def check_command(
184194

185195
# Display detailed results if verbose
186196
if verbose:
187-
_display_verbose_results(result, processor)
197+
_display_verbose_results(result, processor, show_all, export_files)
188198
else:
189-
# Display summary
190-
processor.display_summary(result)
199+
# Display summary with new options
200+
processor.display_summary(result, show_all=show_all, export_files=export_files)
191201

192202
except Exception as e:
193203
console.print(f"[red]Error during check:[/red] {e}")
@@ -198,7 +208,7 @@ def check_command(
198208
vale_container.cleanup()
199209

200210

201-
def _display_verbose_results(result, processor):
211+
def _display_verbose_results(result, processor, show_all=False, export_files=None):
202212
"""Display verbose results with detailed violation information."""
203213
console.print("\n📊 Detailed Analysis Results\n")
204214

src/aditi/commands/journey.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -942,11 +942,16 @@ def process_single_rule(rule, issues, description, processor, config_manager) ->
942942
# Show affected files
943943
files_affected = list(set(v.file_path for v in issues))
944944
console.print("These files have this issue:")
945-
for i, file_path in enumerate(files_affected[:10]):
946-
rel_path = file_path.relative_to(Path.cwd())
947-
console.print(f" • {rel_path}")
948-
if len(files_affected) > 10:
949-
console.print(f" ... and {len(files_affected) - 10} more")
945+
# Use the processor's file list display helper if available
946+
if hasattr(processor, '_display_file_list'):
947+
processor._display_file_list(files_affected, rule.name, show_all=False, max_display=10)
948+
else:
949+
# Fallback to inline display
950+
for i, file_path in enumerate(files_affected[:10]):
951+
rel_path = file_path.relative_to(Path.cwd())
952+
console.print(f" • {rel_path}")
953+
if len(files_affected) > 10:
954+
console.print(f" ... and {len(files_affected) - 10} more")
950955

951956
console.print()
952957

@@ -1157,8 +1162,15 @@ def recheck_rule_violations(rule_name: str, files_affected: List[Path], processo
11571162
# Show affected files in the same format as process_single_rule
11581163
files_with_issues = list(set(v.file_path for v in rule_issues))
11591164
console.print("These files have this issue:")
1160-
for file_path in files_with_issues:
1161-
console.print(f" • {file_path}")
1165+
# Use the processor's file list display helper if available
1166+
if hasattr(processor, '_display_file_list'):
1167+
processor._display_file_list(files_with_issues, rule_name, show_all=False, max_display=10)
1168+
else:
1169+
# Fallback to inline display
1170+
for file_path in files_with_issues[:10]:
1171+
console.print(f" • {file_path}")
1172+
if len(files_with_issues) > 10:
1173+
console.print(f" ... and {len(files_with_issues) - 10} more")
11621174

11631175
except Exception as e:
11641176
console.print(f"[red]Error during recheck: {e}[/red]")

src/aditi/processor.py

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,14 +466,40 @@ def _backup_file(self, file_path: Path) -> bool:
466466
console.print(f"[yellow]Warning: Failed to backup {file_path}:[/yellow] {e}")
467467
return False
468468

469-
def display_summary(self, result: ProcessingResult):
469+
def _display_file_list(self, files: List[Path], rule_name: str, show_all: bool = False, max_display: int = 10) -> None:
470+
"""Display a list of files with optional truncation.
471+
472+
Args:
473+
files: List of file paths
474+
rule_name: Name of the rule for context
475+
show_all: If True, show all files without truncation
476+
max_display: Maximum number of files to show when not showing all
477+
"""
478+
if show_all or len(files) <= max_display:
479+
# Show all files
480+
for file_path in files:
481+
rel_path = file_path.relative_to(Path.cwd())
482+
console.print(f" • {rel_path}")
483+
else:
484+
# Show truncated list
485+
for file_path in files[:max_display]:
486+
rel_path = file_path.relative_to(Path.cwd())
487+
console.print(f" • {rel_path}")
488+
console.print(f" ... and {len(files) - max_display} more")
489+
490+
def display_summary(self, result: ProcessingResult, show_all: bool = False, export_files: Optional[Path] = None):
470491
"""Display a summary of the processing results.
471492
472493
Args:
473494
result: The processing result to display
495+
show_all: If True, show all affected files without truncation
496+
export_files: If provided, export full file list to this path
474497
"""
475498
console.print("\n📊 Analysis Results\n")
476499

500+
# Prepare export data if needed
501+
export_data = {} if export_files else None
502+
477503
# Violations by rule
478504
rule_counts = result.get_violations_by_rule()
479505
if rule_counts:
@@ -497,6 +523,22 @@ def display_summary(self, result: ProcessingResult):
497523
for rule_name in rules_of_type:
498524
count = rule_counts[rule_name]
499525
console.print(f" {rule_name} ({count} {'issue' if count == 1 else 'issues'})")
526+
527+
# Get affected files for this rule
528+
affected_files = list(set(
529+
v.file_path for v in result.violations_found
530+
if v.rule_name == rule_name
531+
))
532+
533+
# Store in export data if needed
534+
if export_data is not None:
535+
export_data[rule_name] = [str(f.relative_to(Path.cwd())) for f in affected_files]
536+
537+
# Display files if show_all or in verbose mode
538+
if show_all and affected_files:
539+
console.print(" Files affected:")
540+
self._display_file_list(affected_files, rule_name, show_all=True)
541+
500542
console.print() # Blank line after each section
501543

502544
# Show unimplemented rules
@@ -533,5 +575,27 @@ def display_summary(self, result: ProcessingResult):
533575
if result.total_violations > 0 and auto_fixable > 0:
534576
auto_fix_percentage = (auto_fixable / result.total_violations) * 100
535577
console.print(f"\n✨ Good news! {auto_fix_percentage:.0f}% of issues can be fixed automatically.")
536-
578+
579+
# Export file list if requested
580+
if export_files and export_data:
581+
try:
582+
with open(export_files, 'w') as f:
583+
# Write header
584+
f.write(f"# Aditi Check Results - Files with Issues\n")
585+
f.write(f"# Generated: {datetime.now().isoformat()}\n")
586+
f.write(f"# Total files: {len(result.files_processed)}\n")
587+
f.write(f"# Total issues: {result.total_violations}\n\n")
588+
589+
# Write files by rule
590+
for rule_name in sorted(export_data.keys()):
591+
files = export_data[rule_name]
592+
f.write(f"## {rule_name} ({len(files)} files)\n")
593+
for file_path in sorted(files):
594+
f.write(f" - {file_path}\n")
595+
f.write("\n")
596+
597+
console.print(f"\n✓ Full file list exported to: {export_files}")
598+
except Exception as e:
599+
console.print(f"\n[red]Error exporting file list:[/red] {e}")
600+
537601
console.print("\nNext step: Run 'aditi journey' for guided workflow")

0 commit comments

Comments
 (0)