|
| 1 | +# Implementation Tasks |
| 2 | + |
| 3 | +## 1. CLI Interface |
| 4 | + |
| 5 | +- [ ] 1.1 Add `--art` argument to argparse in `cli.py` |
| 6 | + - Accept string input (e.g., "4", "16bis", "3ter") |
| 7 | + - Add to help text with examples |
| 8 | + - Document interaction with URL-based `~artN` |
| 9 | + |
| 10 | +- [ ] 1.2 Update help examples in `cli.py` |
| 11 | + - Add example: `normattiva2md --art 4 input.xml output.md` |
| 12 | + - Add example: `normattiva2md --art 16bis "URL" output.md` |
| 13 | + - Add example: `normattiva2md --art 3 --with-urls "URL" output.md` |
| 14 | + |
| 15 | +- [ ] 1.3 Add validation for `--art` parameter |
| 16 | + - Check format matches pattern: `^\d+[a-z]*$` (number + optional extension) |
| 17 | + - Warn if invalid format but continue processing |
| 18 | + - Handle case-insensitive extensions |
| 19 | + |
| 20 | +## 2. Article Filtering Logic |
| 21 | + |
| 22 | +- [ ] 2.1 Create article eId construction function |
| 23 | + - Convert user input "4" → "art_4" |
| 24 | + - Convert user input "16bis" → "art_16bis" |
| 25 | + - Handle common extensions (bis through quadragies) |
| 26 | + - Place in `xml_parser.py` or create new `article_utils.py` |
| 27 | + |
| 28 | +- [ ] 2.2 Integrate filtering in conversion flow |
| 29 | + - In `cli.py`, pass `--art` value to conversion function |
| 30 | + - Call `filter_xml_to_article()` before markdown conversion |
| 31 | + - Handle None return (article not found) |
| 32 | + - Print warning to stderr when article not found |
| 33 | + |
| 34 | +- [ ] 2.3 Update `convert_akomantoso_to_markdown_improved()` |
| 35 | + - Accept optional `article_filter` parameter |
| 36 | + - Apply filtering after XML parsing, before conversion |
| 37 | + - Preserve metadata extraction from full document |
| 38 | + - Adjust title in output when filtered |
| 39 | + |
| 40 | +## 3. URL Handling |
| 41 | + |
| 42 | +- [ ] 3.1 Handle URL with existing `~artN` |
| 43 | + - When `--art` is provided, it overrides URL's `~artN` |
| 44 | + - Download full document (ignore URL article reference) |
| 45 | + - Apply filtering using `--art` value instead |
| 46 | + |
| 47 | +- [ ] 3.2 Ensure compatibility with `--completo` flag |
| 48 | + - If both `--completo` and `--art` provided, `--art` takes precedence |
| 49 | + - Document this behavior in help text |
| 50 | + |
| 51 | +## 4. Integration with Existing Features |
| 52 | + |
| 53 | +- [ ] 4.1 Test `--art` with `--with-urls` |
| 54 | + - Verify reference URLs are generated correctly |
| 55 | + - Ensure URLs point to proper articles in cited documents |
| 56 | + |
| 57 | +- [ ] 4.2 Test `--art` with `--with-references` |
| 58 | + - Main document should be filtered |
| 59 | + - Referenced documents should NOT be filtered (download full) |
| 60 | + |
| 61 | +- [ ] 4.3 Test `--art` with `--provvedimenti` |
| 62 | + - Both features should work independently |
| 63 | + - CSV export should work with filtered markdown |
| 64 | + |
| 65 | +## 5. Testing |
| 66 | + |
| 67 | +- [ ] 5.1 Unit tests for eId construction |
| 68 | + - Test numeric articles: "1", "4", "99" |
| 69 | + - Test extensions: "16bis", "3ter", "5quater" |
| 70 | + - Test edge cases: invalid formats |
| 71 | + |
| 72 | +- [ ] 5.2 Integration tests via Makefile |
| 73 | + - Test with local XML file |
| 74 | + - Test with normattiva.it URL |
| 75 | + - Test with URL containing `~artN` (override scenario) |
| 76 | + - Test with nonexistent article number |
| 77 | + |
| 78 | +- [ ] 5.3 Test article extension variations |
| 79 | + - Test all common extensions (bis through decies) |
| 80 | + - Test case insensitivity |
| 81 | + - Test less common extensions (vices, tricies, quadragies) |
| 82 | + |
| 83 | +## 6. Documentation |
| 84 | + |
| 85 | +- [ ] 6.1 Update README.md with `--art` examples |
| 86 | + - Add to CLI usage section |
| 87 | + - Show combination with other flags |
| 88 | + |
| 89 | +- [ ] 6.2 Update CLAUDE.md project instructions |
| 90 | + - Document new `--art` parameter |
| 91 | + - Explain filtering behavior |
| 92 | + |
| 93 | +- [ ] 6.3 Update URL_NORMATTIVA.md if needed |
| 94 | + - Cross-reference `--art` flag as alternative to `~artN` |
| 95 | + - Explain when to use each approach |
| 96 | + |
| 97 | +## 7. Validation |
| 98 | + |
| 99 | +- [ ] 7.1 Run `openspec validate add-article-filter-flag --strict` |
| 100 | + - Resolve any validation errors |
| 101 | + - Ensure all requirements have scenarios |
| 102 | + |
| 103 | +- [ ] 7.2 Test with real normattiva.it documents |
| 104 | + - Test Decreto Legge with multiple articles |
| 105 | + - Test document with articles containing extensions |
| 106 | + - Verify output markdown quality |
0 commit comments