sphinx-cmd 0.4.2__tar.gz → 0.4.3__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.
- {sphinx_cmd-0.4.2/sphinx_cmd.egg-info → sphinx_cmd-0.4.3}/PKG-INFO +1 -1
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/sphinx_cmd/__init__.py +1 -1
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/sphinx_cmd/commands/mv.py +4 -2
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/sphinx_cmd/commands/rm.py +38 -9
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3/sphinx_cmd.egg-info}/PKG-INFO +1 -1
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/LICENSE +0 -0
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/MANIFEST.in +0 -0
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/README.md +0 -0
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/pyproject.toml +0 -0
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/setup.cfg +0 -0
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/sphinx_cmd/cli.py +0 -0
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/sphinx_cmd/commands/__init__.py +0 -0
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/sphinx_cmd/config.py +0 -0
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/sphinx_cmd/py.typed +0 -0
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/sphinx_cmd.egg-info/SOURCES.txt +0 -0
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/sphinx_cmd.egg-info/dependency_links.txt +0 -0
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/sphinx_cmd.egg-info/entry_points.txt +0 -0
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/sphinx_cmd.egg-info/requires.txt +0 -0
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/sphinx_cmd.egg-info/top_level.txt +0 -0
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/tests/test_cli.py +0 -0
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/tests/test_config.py +0 -0
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/tests/test_custom_directives.py +0 -0
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/tests/test_integration.py +0 -0
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/tests/test_mv.py +0 -0
- {sphinx_cmd-0.4.2 → sphinx_cmd-0.4.3}/tests/test_rm.py +0 -0
|
@@ -86,7 +86,8 @@ def extract_references(
|
|
|
86
86
|
|
|
87
87
|
if verbose:
|
|
88
88
|
print(f"Found {ref_type} reference: {ref_path}")
|
|
89
|
-
# For references that could be image files or other assets,
|
|
89
|
+
# For references that could be image files or other assets,
|
|
90
|
+
# show absolute path
|
|
90
91
|
if ref_type in ["image", "figure", "include"]:
|
|
91
92
|
ref_full_path = Path(file_path).parent / ref_path
|
|
92
93
|
ref_abs_path = ref_full_path.resolve()
|
|
@@ -139,7 +140,8 @@ def find_files_referencing(
|
|
|
139
140
|
referencing_files.append((file_path, ref_type))
|
|
140
141
|
if verbose:
|
|
141
142
|
print(f"Found reference in {file_path} ({ref_type}): {ref}")
|
|
142
|
-
# For references that could be image files or other assets,
|
|
143
|
+
# For references that could be image files or other assets,
|
|
144
|
+
# show absolute path
|
|
143
145
|
if ref_type in ["image", "figure", "include"]:
|
|
144
146
|
ref_full_path = Path(file_path).parent / ref
|
|
145
147
|
ref_abs_path = ref_full_path.resolve()
|
|
@@ -22,12 +22,21 @@ def find_rst_files(path):
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
def extract_assets(
|
|
25
|
-
file_path,
|
|
25
|
+
file_path,
|
|
26
|
+
visited=None,
|
|
27
|
+
cli_directives=None,
|
|
28
|
+
context_path=None,
|
|
29
|
+
verbose=False,
|
|
30
|
+
base_dir=None,
|
|
26
31
|
):
|
|
27
32
|
"""Extract asset references from an .rst file, recursively parsing includes."""
|
|
28
33
|
if visited is None:
|
|
29
34
|
visited = set()
|
|
30
35
|
|
|
36
|
+
# Use the directory of the original file as base for relative path resolution
|
|
37
|
+
if base_dir is None:
|
|
38
|
+
base_dir = os.path.dirname(file_path)
|
|
39
|
+
|
|
31
40
|
# Avoid circular includes
|
|
32
41
|
abs_path = os.path.abspath(file_path)
|
|
33
42
|
if abs_path in visited:
|
|
@@ -52,9 +61,16 @@ def extract_assets(
|
|
|
52
61
|
for directive, pattern in directive_patterns.items():
|
|
53
62
|
for match in pattern.findall(content):
|
|
54
63
|
asset_path = match.strip()
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
if directive == "include":
|
|
65
|
+
# Include paths are resolved relative to the current file
|
|
66
|
+
asset_full_path = os.path.normpath(
|
|
67
|
+
os.path.join(os.path.dirname(file_path), asset_path)
|
|
68
|
+
)
|
|
69
|
+
else:
|
|
70
|
+
# Non-include assets are resolved relative to the base directory
|
|
71
|
+
asset_full_path = os.path.normpath(
|
|
72
|
+
os.path.join(base_dir, asset_path)
|
|
73
|
+
)
|
|
58
74
|
asset_abs_path = os.path.abspath(asset_full_path)
|
|
59
75
|
|
|
60
76
|
if verbose:
|
|
@@ -64,13 +80,15 @@ def extract_assets(
|
|
|
64
80
|
if directive == "include":
|
|
65
81
|
if verbose:
|
|
66
82
|
print(f"Parsing include: {asset_full_path}")
|
|
67
|
-
# Recursively extract assets from included files
|
|
83
|
+
# Recursively extract assets from included files,
|
|
84
|
+
# preserving base_dir
|
|
68
85
|
included_assets = extract_assets(
|
|
69
86
|
asset_full_path,
|
|
70
|
-
visited
|
|
87
|
+
visited,
|
|
71
88
|
cli_directives,
|
|
72
89
|
context_path,
|
|
73
90
|
verbose,
|
|
91
|
+
base_dir,
|
|
74
92
|
)
|
|
75
93
|
asset_directives.update(included_assets)
|
|
76
94
|
|
|
@@ -109,12 +127,21 @@ def build_asset_index(rst_files, cli_directives=None, context_path=None, verbose
|
|
|
109
127
|
|
|
110
128
|
|
|
111
129
|
def get_transitive_includes(
|
|
112
|
-
file_path,
|
|
130
|
+
file_path,
|
|
131
|
+
visited=None,
|
|
132
|
+
cli_directives=None,
|
|
133
|
+
context_path=None,
|
|
134
|
+
verbose=False,
|
|
135
|
+
base_dir=None,
|
|
113
136
|
):
|
|
114
137
|
"""Get all files included transitively from a file."""
|
|
115
138
|
if visited is None:
|
|
116
139
|
visited = set()
|
|
117
140
|
|
|
141
|
+
# Use the directory of the original file as base for relative path resolution
|
|
142
|
+
if base_dir is None:
|
|
143
|
+
base_dir = os.path.dirname(file_path)
|
|
144
|
+
|
|
118
145
|
# Avoid circular includes
|
|
119
146
|
abs_path = os.path.abspath(file_path)
|
|
120
147
|
if abs_path in visited:
|
|
@@ -148,14 +175,16 @@ def get_transitive_includes(
|
|
|
148
175
|
if verbose:
|
|
149
176
|
print(f"Found include: {include_path}")
|
|
150
177
|
|
|
151
|
-
# Recursively get includes from the included file
|
|
178
|
+
# Recursively get includes from the included file,
|
|
179
|
+
# preserving base_dir
|
|
152
180
|
includes.update(
|
|
153
181
|
get_transitive_includes(
|
|
154
182
|
include_full_path,
|
|
155
|
-
visited
|
|
183
|
+
visited,
|
|
156
184
|
cli_directives,
|
|
157
185
|
context_path,
|
|
158
186
|
verbose,
|
|
187
|
+
base_dir,
|
|
159
188
|
)
|
|
160
189
|
)
|
|
161
190
|
except Exception as e:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|