rolfedh-doc-utils 0.1.3__py3-none-any.whl → 0.1.5__py3-none-any.whl
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.
- archive_unused_files.py +9 -3
- doc_utils/topic_map_parser.py +10 -2
- doc_utils/unused_adoc.py +71 -1
- doc_utils/unused_images.py +3 -0
- {rolfedh_doc_utils-0.1.3.dist-info → rolfedh_doc_utils-0.1.5.dist-info}/METADATA +1 -1
- rolfedh_doc_utils-0.1.5.dist-info/RECORD +17 -0
- rolfedh_doc_utils-0.1.3.dist-info/RECORD +0 -17
- {rolfedh_doc_utils-0.1.3.dist-info → rolfedh_doc_utils-0.1.5.dist-info}/WHEEL +0 -0
- {rolfedh_doc_utils-0.1.3.dist-info → rolfedh_doc_utils-0.1.5.dist-info}/entry_points.txt +0 -0
- {rolfedh_doc_utils-0.1.3.dist-info → rolfedh_doc_utils-0.1.5.dist-info}/licenses/LICENSE +0 -0
- {rolfedh_doc_utils-0.1.3.dist-info → rolfedh_doc_utils-0.1.5.dist-info}/top_level.txt +0 -0
archive_unused_files.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Archive Unused AsciiDoc Files
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
Automatically discovers and scans 'modules' and 'assemblies' directories for AsciiDoc files
|
|
5
|
+
not referenced by any other AsciiDoc file in the project. Optionally archives and deletes them.
|
|
5
6
|
|
|
6
7
|
For full documentation and usage examples, see archive_unused_files.md in this directory.
|
|
7
8
|
"""
|
|
@@ -11,14 +12,19 @@ from doc_utils.unused_adoc import find_unused_adoc
|
|
|
11
12
|
from doc_utils.file_utils import parse_exclude_list_file
|
|
12
13
|
|
|
13
14
|
def main():
|
|
14
|
-
parser = argparse.ArgumentParser(
|
|
15
|
+
parser = argparse.ArgumentParser(
|
|
16
|
+
description='Archive unused AsciiDoc files.',
|
|
17
|
+
epilog='By default, automatically discovers all modules and assemblies directories in the repository.'
|
|
18
|
+
)
|
|
15
19
|
parser.add_argument('--archive', action='store_true', help='Move the files to a dated zip in the archive directory.')
|
|
20
|
+
parser.add_argument('--scan-dir', action='append', default=[], help='Specific directory to scan (can be used multiple times). If not specified, auto-discovers directories.')
|
|
16
21
|
parser.add_argument('--exclude-dir', action='append', default=[], help='Directory to exclude (can be used multiple times).')
|
|
17
22
|
parser.add_argument('--exclude-file', action='append', default=[], help='File to exclude (can be used multiple times).')
|
|
18
23
|
parser.add_argument('--exclude-list', type=str, help='Path to a file containing directories or files to exclude, one per line.')
|
|
19
24
|
args = parser.parse_args()
|
|
20
25
|
|
|
21
|
-
|
|
26
|
+
# Use provided scan directories or None for auto-discovery
|
|
27
|
+
scan_dirs = args.scan_dir if args.scan_dir else None
|
|
22
28
|
archive_dir = './archive'
|
|
23
29
|
|
|
24
30
|
exclude_dirs = list(args.exclude_dir)
|
doc_utils/topic_map_parser.py
CHANGED
|
@@ -22,8 +22,16 @@ def detect_repo_type(base_path='.'):
|
|
|
22
22
|
if yml_files:
|
|
23
23
|
return 'topic_map'
|
|
24
24
|
|
|
25
|
-
# Check for master.adoc files
|
|
26
|
-
master_files =
|
|
25
|
+
# Check for master.adoc files using os.walk to avoid symlink issues
|
|
26
|
+
master_files = []
|
|
27
|
+
for root, dirs, files in os.walk(base_path):
|
|
28
|
+
# Skip symbolic link directories to prevent infinite recursion
|
|
29
|
+
dirs[:] = [d for d in dirs if not os.path.islink(os.path.join(root, d))]
|
|
30
|
+
|
|
31
|
+
# Check for master.adoc in this directory
|
|
32
|
+
if 'master.adoc' in files:
|
|
33
|
+
master_files.append(os.path.join(root, 'master.adoc'))
|
|
34
|
+
|
|
27
35
|
if master_files:
|
|
28
36
|
return 'master_adoc'
|
|
29
37
|
|
doc_utils/unused_adoc.py
CHANGED
|
@@ -5,7 +5,77 @@ import re
|
|
|
5
5
|
from .file_utils import collect_files, write_manifest_and_archive
|
|
6
6
|
from .topic_map_parser import detect_repo_type, get_all_topic_map_references
|
|
7
7
|
|
|
8
|
-
def
|
|
8
|
+
def find_scan_directories(base_path='.', exclude_dirs=None):
|
|
9
|
+
"""
|
|
10
|
+
Automatically find all 'modules' and 'assemblies' directories in the repository.
|
|
11
|
+
|
|
12
|
+
Returns a list of paths to scan.
|
|
13
|
+
"""
|
|
14
|
+
scan_dirs = []
|
|
15
|
+
exclude_dirs = exclude_dirs or []
|
|
16
|
+
|
|
17
|
+
for root, dirs, files in os.walk(base_path):
|
|
18
|
+
# Skip symbolic links to prevent issues
|
|
19
|
+
dirs[:] = [d for d in dirs if not os.path.islink(os.path.join(root, d))]
|
|
20
|
+
|
|
21
|
+
# Skip excluded directories
|
|
22
|
+
for exclude_dir in exclude_dirs:
|
|
23
|
+
abs_exclude = os.path.abspath(exclude_dir)
|
|
24
|
+
if os.path.abspath(root).startswith(abs_exclude):
|
|
25
|
+
dirs[:] = [] # Don't descend into excluded directories
|
|
26
|
+
break
|
|
27
|
+
|
|
28
|
+
# Skip hidden directories and common non-content directories
|
|
29
|
+
dirs[:] = [d for d in dirs if not d.startswith('.') and d not in ['node_modules', 'build', 'dist', 'target']]
|
|
30
|
+
|
|
31
|
+
# Look for modules and assemblies directories
|
|
32
|
+
for d in dirs:
|
|
33
|
+
if d in ['modules', 'assemblies']:
|
|
34
|
+
dir_path = os.path.join(root, d)
|
|
35
|
+
# Check if this directory or any subdirectory contains .adoc files
|
|
36
|
+
has_adoc = False
|
|
37
|
+
for subroot, subdirs, subfiles in os.walk(dir_path):
|
|
38
|
+
# Skip symbolic links
|
|
39
|
+
subdirs[:] = [sd for sd in subdirs if not os.path.islink(os.path.join(subroot, sd))]
|
|
40
|
+
if any(f.endswith('.adoc') for f in subfiles):
|
|
41
|
+
has_adoc = True
|
|
42
|
+
break
|
|
43
|
+
if has_adoc:
|
|
44
|
+
scan_dirs.append(dir_path)
|
|
45
|
+
|
|
46
|
+
# Also check for modules/rn pattern if modules exists
|
|
47
|
+
modules_dirs = [d for d in scan_dirs if os.path.basename(d) == 'modules']
|
|
48
|
+
for modules_dir in modules_dirs:
|
|
49
|
+
rn_dir = os.path.join(modules_dir, 'rn')
|
|
50
|
+
if os.path.isdir(rn_dir):
|
|
51
|
+
# Check if rn directory or subdirectories contain .adoc files
|
|
52
|
+
has_adoc = False
|
|
53
|
+
for subroot, subdirs, subfiles in os.walk(rn_dir):
|
|
54
|
+
subdirs[:] = [sd for sd in subdirs if not os.path.islink(os.path.join(subroot, sd))]
|
|
55
|
+
if any(f.endswith('.adoc') for f in subfiles):
|
|
56
|
+
has_adoc = True
|
|
57
|
+
break
|
|
58
|
+
if has_adoc:
|
|
59
|
+
scan_dirs.append(rn_dir)
|
|
60
|
+
|
|
61
|
+
return scan_dirs
|
|
62
|
+
|
|
63
|
+
def find_unused_adoc(scan_dirs=None, archive_dir='./archive', archive=False, exclude_dirs=None, exclude_files=None):
|
|
64
|
+
# Print safety warning
|
|
65
|
+
print("\n⚠️ SAFETY: Work in a git branch! Run without --archive first to preview.\n")
|
|
66
|
+
|
|
67
|
+
# If no scan_dirs provided, auto-discover them
|
|
68
|
+
if not scan_dirs:
|
|
69
|
+
scan_dirs = find_scan_directories(exclude_dirs=exclude_dirs)
|
|
70
|
+
if scan_dirs:
|
|
71
|
+
print(f"Auto-discovered directories to scan:")
|
|
72
|
+
for dir_path in sorted(scan_dirs):
|
|
73
|
+
print(f" - {dir_path}")
|
|
74
|
+
else:
|
|
75
|
+
print("No 'modules' or 'assemblies' directories found containing .adoc files.")
|
|
76
|
+
print("Please run this tool from your documentation repository root.")
|
|
77
|
+
return
|
|
78
|
+
|
|
9
79
|
# Detect repository type
|
|
10
80
|
repo_type = detect_repo_type()
|
|
11
81
|
print(f"Detected repository type: {repo_type}")
|
doc_utils/unused_images.py
CHANGED
|
@@ -7,6 +7,9 @@ from .file_utils import collect_files, write_manifest_and_archive
|
|
|
7
7
|
IMAGE_EXTENSIONS = {'.png', '.jpg', '.jpeg', '.gif', '.svg'}
|
|
8
8
|
|
|
9
9
|
def find_unused_images(scan_dirs, archive_dir, archive=False, exclude_dirs=None, exclude_files=None):
|
|
10
|
+
# Print safety warning
|
|
11
|
+
print("\n⚠️ SAFETY: Work in a git branch! Run without --archive first to preview.\n")
|
|
12
|
+
|
|
10
13
|
image_files = collect_files(scan_dirs, IMAGE_EXTENSIONS, exclude_dirs, exclude_files)
|
|
11
14
|
adoc_files = collect_files(['.'], {'.adoc'}, exclude_dirs, exclude_files)
|
|
12
15
|
referenced_images = set()
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
archive_unused_files.py,sha256=KMC5a1WL3rZ5owoVnncvfpT1YeMKbVXq9giHvadDgbM,1936
|
|
2
|
+
archive_unused_images.py,sha256=PG2o3haovYckgfhoPhl6KRG_a9czyZuqlLkzkupKTCY,1526
|
|
3
|
+
check_scannability.py,sha256=gcM-vFXKHGP_yFBz7-V5xbXWhIMmtMzBYIGwP9CFbzI,5140
|
|
4
|
+
find_unused_attributes.py,sha256=fk-K32eoCVHxoj7RiBNgSmX1arBLuwYfdSAOMc-wIx0,1677
|
|
5
|
+
doc_utils/__init__.py,sha256=qqZR3lohzkP63soymrEZPBGzzk6-nFzi4_tSffjmu_0,74
|
|
6
|
+
doc_utils/file_utils.py,sha256=fpTh3xx759sF8sNocdn_arsP3KAv8XA6cTQTAVIZiZg,4247
|
|
7
|
+
doc_utils/scannability.py,sha256=XwlmHqDs69p_V36X7DLjPTy0DUoLszSGqYjJ9wE-3hg,982
|
|
8
|
+
doc_utils/topic_map_parser.py,sha256=tKcIO1m9r2K6dvPRGue58zqMr0O2zKU1gnZMzEE3U6o,4571
|
|
9
|
+
doc_utils/unused_adoc.py,sha256=2cbqcYr1os2EhETUU928BlPRlsZVSdI00qaMhqjSIqQ,5263
|
|
10
|
+
doc_utils/unused_attributes.py,sha256=HBgmHelqearfWl3TTC2bZGiJytjLADIgiGQUNKqXXPg,1847
|
|
11
|
+
doc_utils/unused_images.py,sha256=nqn36Bbrmon2KlGlcaruNjJJvTQ8_9H0WU9GvCW7rW8,1456
|
|
12
|
+
rolfedh_doc_utils-0.1.5.dist-info/licenses/LICENSE,sha256=vLxtwMVOJA_hEy8b77niTkdmQI9kNJskXHq0dBS36e0,1075
|
|
13
|
+
rolfedh_doc_utils-0.1.5.dist-info/METADATA,sha256=pSqhon_Hxstw72EnvJ-4UusaepxhdOvxUI0OqTF0toQ,8152
|
|
14
|
+
rolfedh_doc_utils-0.1.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
15
|
+
rolfedh_doc_utils-0.1.5.dist-info/entry_points.txt,sha256=i8LqEsp0KD4YyVI_7wQ1TMgCuag32D7gQes6bLufmtM,216
|
|
16
|
+
rolfedh_doc_utils-0.1.5.dist-info/top_level.txt,sha256=BkaYN3KbtNvLQjs-QGBKCJb5UAtjEbC_IqxSSIN9P-w,95
|
|
17
|
+
rolfedh_doc_utils-0.1.5.dist-info/RECORD,,
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
archive_unused_files.py,sha256=MFdAtE8CDthida5H5FhvtEHZWrQAZZoAB-DQkTOc6gs,1537
|
|
2
|
-
archive_unused_images.py,sha256=PG2o3haovYckgfhoPhl6KRG_a9czyZuqlLkzkupKTCY,1526
|
|
3
|
-
check_scannability.py,sha256=gcM-vFXKHGP_yFBz7-V5xbXWhIMmtMzBYIGwP9CFbzI,5140
|
|
4
|
-
find_unused_attributes.py,sha256=fk-K32eoCVHxoj7RiBNgSmX1arBLuwYfdSAOMc-wIx0,1677
|
|
5
|
-
doc_utils/__init__.py,sha256=qqZR3lohzkP63soymrEZPBGzzk6-nFzi4_tSffjmu_0,74
|
|
6
|
-
doc_utils/file_utils.py,sha256=fpTh3xx759sF8sNocdn_arsP3KAv8XA6cTQTAVIZiZg,4247
|
|
7
|
-
doc_utils/scannability.py,sha256=XwlmHqDs69p_V36X7DLjPTy0DUoLszSGqYjJ9wE-3hg,982
|
|
8
|
-
doc_utils/topic_map_parser.py,sha256=4vmOPInoKAFO54qOz4EuK24hHTngI4GXzrw0D_QZzSc,4224
|
|
9
|
-
doc_utils/unused_adoc.py,sha256=aPhq4KQG5VJGCg_cnqyhNWuADGEQA_dtjmvxtf7ylGA,2185
|
|
10
|
-
doc_utils/unused_attributes.py,sha256=HBgmHelqearfWl3TTC2bZGiJytjLADIgiGQUNKqXXPg,1847
|
|
11
|
-
doc_utils/unused_images.py,sha256=P9vcm00BidrLmxhjeczBtiFU-1wgfN5nCYdZjeCH1kM,1329
|
|
12
|
-
rolfedh_doc_utils-0.1.3.dist-info/licenses/LICENSE,sha256=vLxtwMVOJA_hEy8b77niTkdmQI9kNJskXHq0dBS36e0,1075
|
|
13
|
-
rolfedh_doc_utils-0.1.3.dist-info/METADATA,sha256=nTGGOIULiuqFcveMw4kGsHF-NVbe-YK3sbElusT9ku0,8152
|
|
14
|
-
rolfedh_doc_utils-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
15
|
-
rolfedh_doc_utils-0.1.3.dist-info/entry_points.txt,sha256=i8LqEsp0KD4YyVI_7wQ1TMgCuag32D7gQes6bLufmtM,216
|
|
16
|
-
rolfedh_doc_utils-0.1.3.dist-info/top_level.txt,sha256=BkaYN3KbtNvLQjs-QGBKCJb5UAtjEbC_IqxSSIN9P-w,95
|
|
17
|
-
rolfedh_doc_utils-0.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|