rolfedh-doc-utils 0.1.12__tar.gz → 0.1.13__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. {rolfedh_doc_utils-0.1.12/rolfedh_doc_utils.egg-info → rolfedh_doc_utils-0.1.13}/PKG-INFO +1 -1
  2. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/doc_utils/extract_link_attributes.py +24 -13
  3. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/pyproject.toml +1 -1
  4. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13/rolfedh_doc_utils.egg-info}/PKG-INFO +1 -1
  5. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/tests/test_extract_link_attributes.py +5 -2
  6. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/LICENSE +0 -0
  7. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/README.md +0 -0
  8. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/archive_unused_files.py +0 -0
  9. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/archive_unused_images.py +0 -0
  10. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/check_scannability.py +0 -0
  11. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/doc_utils/__init__.py +0 -0
  12. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/doc_utils/file_utils.py +0 -0
  13. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/doc_utils/format_asciidoc_spacing.py +0 -0
  14. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/doc_utils/replace_link_attributes.py +0 -0
  15. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/doc_utils/scannability.py +0 -0
  16. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/doc_utils/spinner.py +0 -0
  17. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/doc_utils/topic_map_parser.py +0 -0
  18. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/doc_utils/unused_adoc.py +0 -0
  19. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/doc_utils/unused_attributes.py +0 -0
  20. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/doc_utils/unused_images.py +0 -0
  21. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/doc_utils/validate_links.py +0 -0
  22. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/extract_link_attributes.py +0 -0
  23. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/find_unused_attributes.py +0 -0
  24. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/format_asciidoc_spacing.py +0 -0
  25. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/replace_link_attributes.py +0 -0
  26. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/rolfedh_doc_utils.egg-info/SOURCES.txt +0 -0
  27. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/rolfedh_doc_utils.egg-info/dependency_links.txt +0 -0
  28. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/rolfedh_doc_utils.egg-info/entry_points.txt +0 -0
  29. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/rolfedh_doc_utils.egg-info/requires.txt +0 -0
  30. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/rolfedh_doc_utils.egg-info/top_level.txt +0 -0
  31. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/setup.cfg +0 -0
  32. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/setup.py +0 -0
  33. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/tests/test_archive_unused_files.py +0 -0
  34. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/tests/test_archive_unused_images.py +0 -0
  35. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/tests/test_auto_discovery.py +0 -0
  36. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/tests/test_check_scannability.py +0 -0
  37. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/tests/test_cli_entry_points.py +0 -0
  38. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/tests/test_file_utils.py +0 -0
  39. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/tests/test_fixture_archive_unused_files.py +0 -0
  40. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/tests/test_fixture_archive_unused_images.py +0 -0
  41. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/tests/test_fixture_check_scannability.py +0 -0
  42. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/tests/test_parse_exclude_list.py +0 -0
  43. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/tests/test_symlink_handling.py +0 -0
  44. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/tests/test_topic_map_parser.py +0 -0
  45. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/tests/test_unused_attributes.py +0 -0
  46. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/tests/test_validate_links.py +0 -0
  47. {rolfedh_doc_utils-0.1.12 → rolfedh_doc_utils-0.1.13}/validate_links.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rolfedh-doc-utils
3
- Version: 0.1.12
3
+ Version: 0.1.13
4
4
  Summary: CLI tools for AsciiDoc documentation projects
5
5
  Author: Rolfe Dlugy-Hegwer
6
6
  License: MIT License
@@ -257,13 +257,14 @@ def collect_all_macros(scan_dirs: List[str] = None) -> List[Tuple[str, str, str,
257
257
 
258
258
  def create_attributes(url_groups: Dict[str, List[Tuple[str, str, str, int]]],
259
259
  existing_attrs: Dict[str, str],
260
- interactive: bool = True) -> Dict[str, str]:
260
+ interactive: bool = True) -> Tuple[Dict[str, str], Dict[str, str]]:
261
261
  """
262
- Create new attributes for each unique URL.
262
+ Create new attributes for each unique URL and track existing ones.
263
263
 
264
- Returns: Dict[attribute_name, attribute_value]
264
+ Returns: Tuple[new_attributes, existing_matching_attributes]
265
265
  """
266
266
  new_attributes = {}
267
+ existing_matching_attributes = {}
267
268
  existing_attr_names = set(existing_attrs.keys())
268
269
  counter = 1
269
270
 
@@ -273,6 +274,7 @@ def create_attributes(url_groups: Dict[str, List[Tuple[str, str, str, int]]],
273
274
  for attr_name, attr_value in existing_attrs.items():
274
275
  if url in attr_value:
275
276
  existing_attr = attr_name
277
+ existing_matching_attributes[attr_name] = attr_value
276
278
  break
277
279
 
278
280
  if existing_attr:
@@ -296,7 +298,7 @@ def create_attributes(url_groups: Dict[str, List[Tuple[str, str, str, int]]],
296
298
 
297
299
  print(f"Created attribute: :{attr_name}: {attr_value}")
298
300
 
299
- return new_attributes
301
+ return new_attributes, existing_matching_attributes
300
302
 
301
303
 
302
304
  def update_attribute_file(file_path: str, new_attributes: Dict[str, str], dry_run: bool = False):
@@ -505,15 +507,15 @@ def extract_link_attributes(attributes_file: str = None,
505
507
  url_groups = group_macros_by_url(all_macros)
506
508
  spinner.stop(f"Grouped into {len(url_groups)} unique URLs")
507
509
 
508
- # Create new attributes
509
- new_attributes = create_attributes(url_groups, existing_attrs, interactive)
510
+ # Create new attributes and track existing ones
511
+ new_attributes, existing_matching_attributes = create_attributes(url_groups, existing_attrs, interactive)
510
512
 
511
- if not new_attributes:
512
- print("No new attributes to create.")
513
+ if not new_attributes and not existing_matching_attributes:
514
+ print("No new attributes to create and no existing attributes match found URLs.")
513
515
  return True
514
516
 
515
517
  # Validate new attributes before writing if requested
516
- if validate_links and not dry_run:
518
+ if validate_links and not dry_run and new_attributes:
517
519
  print("\nValidating new link attributes...")
518
520
  spinner = Spinner("Validating new URLs")
519
521
  spinner.start()
@@ -543,10 +545,11 @@ def extract_link_attributes(attributes_file: str = None,
543
545
  print("\nStopping due to broken URLs in new attributes (--fail-on-broken)")
544
546
  return False
545
547
 
546
- # Update attribute file
547
- update_attribute_file(attributes_file, new_attributes, dry_run)
548
+ # Update attribute file (only if there are new attributes)
549
+ if new_attributes:
550
+ update_attribute_file(attributes_file, new_attributes, dry_run)
548
551
 
549
- # Prepare file updates
552
+ # Prepare file updates (include both new and existing matching attributes)
550
553
  all_attributes = {**existing_attrs, **new_attributes}
551
554
  file_updates = prepare_file_updates(url_groups, all_attributes)
552
555
 
@@ -560,6 +563,14 @@ def extract_link_attributes(attributes_file: str = None,
560
563
  if dry_run:
561
564
  print("\n[DRY RUN] No files were modified. Run without --dry-run to apply changes.")
562
565
  else:
563
- print(f"\nSuccessfully extracted {len(new_attributes)} link attributes")
566
+ total_processed = len(new_attributes) + len(existing_matching_attributes)
567
+ if new_attributes and existing_matching_attributes:
568
+ print(f"\nSuccessfully processed {total_processed} link attributes:")
569
+ print(f" - Created {len(new_attributes)} new attributes")
570
+ print(f" - Replaced macros using {len(existing_matching_attributes)} existing attributes")
571
+ elif new_attributes:
572
+ print(f"\nSuccessfully extracted {len(new_attributes)} link attributes")
573
+ elif existing_matching_attributes:
574
+ print(f"\nSuccessfully replaced macros using {len(existing_matching_attributes)} existing link attributes")
564
575
 
565
576
  return True
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "rolfedh-doc-utils"
7
- version = "0.1.12"
7
+ version = "0.1.13"
8
8
  description = "CLI tools for AsciiDoc documentation projects"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rolfedh-doc-utils
3
- Version: 0.1.12
3
+ Version: 0.1.13
4
4
  Summary: CLI tools for AsciiDoc documentation projects
5
5
  Author: Rolfe Dlugy-Hegwer
6
6
  License: MIT License
@@ -217,9 +217,10 @@ class TestCreateAttributes:
217
217
  }
218
218
  existing_attrs = {}
219
219
 
220
- new_attrs = create_attributes(url_groups, existing_attrs, interactive=False)
220
+ new_attrs, existing_matched = create_attributes(url_groups, existing_attrs, interactive=False)
221
221
 
222
222
  assert len(new_attrs) == 2
223
+ assert len(existing_matched) == 0
223
224
  # Check that attributes were created
224
225
  attr_values = list(new_attrs.values())
225
226
  assert any("link:https://example.com/{version}/guide.html[Guide]" in v for v in attr_values)
@@ -236,9 +237,11 @@ class TestCreateAttributes:
236
237
  "existing-link": "link:https://example.com/guide.html[Existing Guide]"
237
238
  }
238
239
 
239
- new_attrs = create_attributes(url_groups, existing_attrs, interactive=False)
240
+ new_attrs, existing_matched = create_attributes(url_groups, existing_attrs, interactive=False)
240
241
 
241
242
  assert len(new_attrs) == 0
243
+ assert len(existing_matched) == 1
244
+ assert "existing-link" in existing_matched
242
245
  captured = capsys.readouterr()
243
246
  assert "already has attribute" in captured.out
244
247