mkdocs-include-markdown-plugin 6.0.5__tar.gz → 6.0.6__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.
- {mkdocs_include_markdown_plugin-6.0.5 → mkdocs_include_markdown_plugin-6.0.6}/PKG-INFO +1 -1
- {mkdocs_include_markdown_plugin-6.0.5 → mkdocs_include_markdown_plugin-6.0.6}/pyproject.toml +3 -2
- {mkdocs_include_markdown_plugin-6.0.5 → mkdocs_include_markdown_plugin-6.0.6}/src/mkdocs_include_markdown_plugin/directive.py +24 -11
- {mkdocs_include_markdown_plugin-6.0.5 → mkdocs_include_markdown_plugin-6.0.6}/src/mkdocs_include_markdown_plugin/event.py +68 -42
- {mkdocs_include_markdown_plugin-6.0.5 → mkdocs_include_markdown_plugin-6.0.6}/.gitignore +0 -0
- {mkdocs_include_markdown_plugin-6.0.5 → mkdocs_include_markdown_plugin-6.0.6}/LICENSE +0 -0
- {mkdocs_include_markdown_plugin-6.0.5 → mkdocs_include_markdown_plugin-6.0.6}/README.md +0 -0
- {mkdocs_include_markdown_plugin-6.0.5 → mkdocs_include_markdown_plugin-6.0.6}/src/mkdocs_include_markdown_plugin/__init__.py +0 -0
- {mkdocs_include_markdown_plugin-6.0.5 → mkdocs_include_markdown_plugin-6.0.6}/src/mkdocs_include_markdown_plugin/cache.py +0 -0
- {mkdocs_include_markdown_plugin-6.0.5 → mkdocs_include_markdown_plugin-6.0.6}/src/mkdocs_include_markdown_plugin/config.py +0 -0
- {mkdocs_include_markdown_plugin-6.0.5 → mkdocs_include_markdown_plugin-6.0.6}/src/mkdocs_include_markdown_plugin/files_watcher.py +0 -0
- {mkdocs_include_markdown_plugin-6.0.5 → mkdocs_include_markdown_plugin-6.0.6}/src/mkdocs_include_markdown_plugin/plugin.py +0 -0
- {mkdocs_include_markdown_plugin-6.0.5 → mkdocs_include_markdown_plugin-6.0.6}/src/mkdocs_include_markdown_plugin/process.py +0 -0
- {mkdocs_include_markdown_plugin-6.0.5 → mkdocs_include_markdown_plugin-6.0.6}/src/mkdocs_include_markdown_plugin/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: mkdocs-include-markdown-plugin
|
|
3
|
-
Version: 6.0.
|
|
3
|
+
Version: 6.0.6
|
|
4
4
|
Summary: Mkdocs Markdown includer plugin.
|
|
5
5
|
Project-URL: Source, https://github.com/mondeja/mkdocs-include-markdown-plugin
|
|
6
6
|
Project-URL: Documentation, https://github.com/mondeja/mkdocs-include-markdown-plugin#documentation
|
{mkdocs_include_markdown_plugin-6.0.5 → mkdocs_include_markdown_plugin-6.0.6}/pyproject.toml
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mkdocs-include-markdown-plugin"
|
|
3
|
-
version = "6.0.
|
|
3
|
+
version = "6.0.6"
|
|
4
4
|
description = "Mkdocs Markdown includer plugin."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "Apache-2.0"
|
|
@@ -74,7 +74,7 @@ dependencies = ["pytest~=7.0", "coverage~=6.4", "covdefaults"]
|
|
|
74
74
|
|
|
75
75
|
[[tool.hatch.envs.tests.matrix]]
|
|
76
76
|
python = ["py38", "py39", "py310", "py311", "py312"]
|
|
77
|
-
mkdocs = ["1.4.0", "1.4.3", "1.5.0", "1.5.3"]
|
|
77
|
+
mkdocs = ["1.4.0", "1.4.3", "1.5.0", "1.5.3", "1.6.0"]
|
|
78
78
|
cache = ["yes", "no"]
|
|
79
79
|
|
|
80
80
|
[tool.hatch.envs.tests.overrides]
|
|
@@ -83,6 +83,7 @@ matrix.mkdocs.dependencies = [
|
|
|
83
83
|
{ value = "mkdocs==1.4.3", if = ["1.4.3"] },
|
|
84
84
|
{ value = "mkdocs==1.5.0", if = ["1.5.0"] },
|
|
85
85
|
{ value = "mkdocs==1.5.3", if = ["1.5.3"] },
|
|
86
|
+
{ value = "mkdocs==1.6.0", if = ["1.6.0"] },
|
|
86
87
|
]
|
|
87
88
|
matrix.cache.dependencies = [{ value = "platformdirs", if = ["yes"] }]
|
|
88
89
|
|
|
@@ -8,6 +8,7 @@ import string
|
|
|
8
8
|
from dataclasses import dataclass
|
|
9
9
|
from typing import TYPE_CHECKING
|
|
10
10
|
|
|
11
|
+
from mkdocs.exceptions import PluginError
|
|
11
12
|
from wcmatch import glob
|
|
12
13
|
|
|
13
14
|
from mkdocs_include_markdown_plugin import process
|
|
@@ -174,19 +175,19 @@ def parse_bool_options(
|
|
|
174
175
|
|
|
175
176
|
|
|
176
177
|
def resolve_file_paths_to_include(
|
|
177
|
-
|
|
178
|
-
includer_page_src_path: str,
|
|
178
|
+
include_string: str,
|
|
179
|
+
includer_page_src_path: str | None,
|
|
179
180
|
docs_dir: str,
|
|
180
181
|
ignore_paths: list[str],
|
|
181
182
|
) -> tuple[list[str], bool]:
|
|
182
183
|
"""Resolve the file paths to include for a directive."""
|
|
183
|
-
if process.is_url(
|
|
184
|
-
return [
|
|
184
|
+
if process.is_url(include_string):
|
|
185
|
+
return [include_string], True
|
|
185
186
|
|
|
186
|
-
if process.is_absolute_path(
|
|
187
|
+
if process.is_absolute_path(include_string):
|
|
187
188
|
if os.name == 'nt': # pragma: nt cover
|
|
188
189
|
# Windows
|
|
189
|
-
fpath = os.path.normpath(
|
|
190
|
+
fpath = os.path.normpath(include_string)
|
|
190
191
|
if not os.path.isfile(fpath):
|
|
191
192
|
return [], False
|
|
192
193
|
|
|
@@ -195,13 +196,19 @@ def resolve_file_paths_to_include(
|
|
|
195
196
|
), False
|
|
196
197
|
return process.filter_paths(
|
|
197
198
|
glob.iglob(
|
|
198
|
-
os.path.normpath(
|
|
199
|
+
os.path.normpath(include_string),
|
|
199
200
|
flags=GLOB_FLAGS,
|
|
200
201
|
),
|
|
201
202
|
ignore_paths,
|
|
202
203
|
), False
|
|
203
204
|
|
|
204
|
-
if process.is_relative_path(
|
|
205
|
+
if process.is_relative_path(include_string):
|
|
206
|
+
if includer_page_src_path is None: # pragma: no cover
|
|
207
|
+
raise PluginError(
|
|
208
|
+
'Relative paths are not allowed when the includer page'
|
|
209
|
+
' source path is not provided. The include string'
|
|
210
|
+
f" '{include_string}' is located inside a generated page.",
|
|
211
|
+
)
|
|
205
212
|
root_dir = os.path.abspath(
|
|
206
213
|
os.path.dirname(includer_page_src_path),
|
|
207
214
|
)
|
|
@@ -209,7 +216,7 @@ def resolve_file_paths_to_include(
|
|
|
209
216
|
(
|
|
210
217
|
os.path.normpath(os.path.join(root_dir, fp))
|
|
211
218
|
for fp in glob.iglob(
|
|
212
|
-
|
|
219
|
+
include_string,
|
|
213
220
|
flags=GLOB_FLAGS,
|
|
214
221
|
root_dir=root_dir,
|
|
215
222
|
)
|
|
@@ -221,7 +228,7 @@ def resolve_file_paths_to_include(
|
|
|
221
228
|
(
|
|
222
229
|
os.path.normpath(os.path.join(docs_dir, fp))
|
|
223
230
|
for fp in glob.iglob(
|
|
224
|
-
|
|
231
|
+
include_string,
|
|
225
232
|
flags=GLOB_FLAGS,
|
|
226
233
|
root_dir=docs_dir,
|
|
227
234
|
)
|
|
@@ -232,7 +239,7 @@ def resolve_file_paths_to_include(
|
|
|
232
239
|
|
|
233
240
|
def resolve_file_paths_to_exclude(
|
|
234
241
|
exclude_string: str,
|
|
235
|
-
includer_page_src_path: str,
|
|
242
|
+
includer_page_src_path: str | None,
|
|
236
243
|
docs_dir: str,
|
|
237
244
|
) -> list[str]:
|
|
238
245
|
"""Resolve the file paths to exclude for a directive."""
|
|
@@ -241,6 +248,12 @@ def resolve_file_paths_to_exclude(
|
|
|
241
248
|
return glob.glob(exclude_string, flags=GLOB_FLAGS)
|
|
242
249
|
|
|
243
250
|
if process.is_relative_path(exclude_string):
|
|
251
|
+
if includer_page_src_path is None: # pragma: no cover
|
|
252
|
+
raise PluginError(
|
|
253
|
+
'Relative paths are not allowed when the includer page'
|
|
254
|
+
' source path is not provided. The exclude string'
|
|
255
|
+
f" '{exclude_string}' is located inside a generated page.",
|
|
256
|
+
)
|
|
244
257
|
root_dir = os.path.abspath(
|
|
245
258
|
os.path.dirname(includer_page_src_path),
|
|
246
259
|
)
|
|
@@ -58,9 +58,26 @@ def lineno_from_content_start(content: str, start: int) -> int:
|
|
|
58
58
|
return content[:start].count('\n') + 1
|
|
59
59
|
|
|
60
60
|
|
|
61
|
+
def file_lineno_message(
|
|
62
|
+
page_src_path: str | None,
|
|
63
|
+
docs_dir: str,
|
|
64
|
+
lineno: int,
|
|
65
|
+
) -> str:
|
|
66
|
+
"""Return a message with the file path and line number."""
|
|
67
|
+
if page_src_path is None: # pragma: no cover
|
|
68
|
+
return f'generated page content (line {lineno})'
|
|
69
|
+
return (
|
|
70
|
+
f'{os.path.relpath(page_src_path, docs_dir)}'
|
|
71
|
+
f':{lineno}'
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
61
75
|
def get_file_content( # noqa: PLR0913, PLR0915
|
|
62
76
|
markdown: str,
|
|
63
|
-
|
|
77
|
+
# Generated pages return `None` for `file.abs_src_path` because
|
|
78
|
+
# they are not read from a file. In this case, page_src_path is
|
|
79
|
+
# set to `None`.
|
|
80
|
+
page_src_path: str | None,
|
|
64
81
|
docs_dir: str,
|
|
65
82
|
tags: IncludeTags,
|
|
66
83
|
defaults: DefaultValues,
|
|
@@ -85,8 +102,8 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
85
102
|
)
|
|
86
103
|
raise PluginError(
|
|
87
104
|
"Found no path passed including with 'include'"
|
|
88
|
-
|
|
89
|
-
f'
|
|
105
|
+
' directive at'
|
|
106
|
+
f' {file_lineno_message(page_src_path, docs_dir, lineno)}',
|
|
90
107
|
)
|
|
91
108
|
|
|
92
109
|
arguments_string = match['arguments']
|
|
@@ -114,9 +131,10 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
114
131
|
)
|
|
115
132
|
raise PluginError(
|
|
116
133
|
"Invalid empty 'exclude' argument in 'include'"
|
|
117
|
-
|
|
118
|
-
f'
|
|
134
|
+
' directive at'
|
|
135
|
+
f' {file_lineno_message(page_src_path, docs_dir, lineno)}',
|
|
119
136
|
)
|
|
137
|
+
|
|
120
138
|
ignore_paths.extend(
|
|
121
139
|
resolve_file_paths_to_exclude(
|
|
122
140
|
exclude_string,
|
|
@@ -139,9 +157,8 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
139
157
|
directive_match_start,
|
|
140
158
|
)
|
|
141
159
|
raise PluginError(
|
|
142
|
-
f"No files found including '{raw_filename}'"
|
|
143
|
-
f'
|
|
144
|
-
f':{lineno}',
|
|
160
|
+
f"No files found including '{raw_filename}' at"
|
|
161
|
+
f' {file_lineno_message(page_src_path, docs_dir, lineno)}',
|
|
145
162
|
)
|
|
146
163
|
|
|
147
164
|
if files_watcher is not None and not is_url:
|
|
@@ -160,8 +177,8 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
160
177
|
raise PluginError(
|
|
161
178
|
f"Invalid value for '{invalid_bool_args[0]}' argument of"
|
|
162
179
|
" 'include' directive at"
|
|
163
|
-
f' {
|
|
164
|
-
f'
|
|
180
|
+
f' {file_lineno_message(page_src_path, docs_dir, lineno)}.'
|
|
181
|
+
f' Possible values are true or false.',
|
|
165
182
|
)
|
|
166
183
|
|
|
167
184
|
start_match = ARGUMENT_REGEXES['start'].search(arguments_string)
|
|
@@ -173,8 +190,8 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
173
190
|
directive_match_start,
|
|
174
191
|
)
|
|
175
192
|
raise PluginError(
|
|
176
|
-
"Invalid empty 'start' argument in 'include' directive at
|
|
177
|
-
f'{
|
|
193
|
+
"Invalid empty 'start' argument in 'include' directive at"
|
|
194
|
+
f' {file_lineno_message(page_src_path, docs_dir, lineno)}',
|
|
178
195
|
)
|
|
179
196
|
else:
|
|
180
197
|
start = defaults['start']
|
|
@@ -188,8 +205,8 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
188
205
|
directive_match_start,
|
|
189
206
|
)
|
|
190
207
|
raise PluginError(
|
|
191
|
-
"Invalid empty 'end' argument in 'include' directive at
|
|
192
|
-
f'{
|
|
208
|
+
"Invalid empty 'end' argument in 'include' directive at"
|
|
209
|
+
f' {file_lineno_message(page_src_path, docs_dir, lineno)}',
|
|
193
210
|
)
|
|
194
211
|
else:
|
|
195
212
|
end = defaults['end']
|
|
@@ -204,8 +221,8 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
204
221
|
)
|
|
205
222
|
raise PluginError(
|
|
206
223
|
"Invalid empty 'encoding' argument in 'include'"
|
|
207
|
-
' directive at
|
|
208
|
-
f'{
|
|
224
|
+
' directive at'
|
|
225
|
+
f' {file_lineno_message(page_src_path, docs_dir, lineno)}',
|
|
209
226
|
)
|
|
210
227
|
else:
|
|
211
228
|
encoding = defaults['encoding']
|
|
@@ -278,12 +295,14 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
278
295
|
markdown,
|
|
279
296
|
directive_match_start,
|
|
280
297
|
)
|
|
281
|
-
|
|
298
|
+
file_lineno = file_lineno_message(
|
|
299
|
+
page_src_path, docs_dir, lineno,
|
|
300
|
+
)
|
|
282
301
|
logger.warning(
|
|
283
302
|
(
|
|
284
303
|
f"Delimiter {delimiter_name} '{delimiter_value}'"
|
|
285
304
|
" of 'include' directive at"
|
|
286
|
-
f' {
|
|
305
|
+
f' {file_lineno}'
|
|
287
306
|
f' not detected in the file{plural_suffix}'
|
|
288
307
|
f' {readable_files_to_include}'
|
|
289
308
|
),
|
|
@@ -307,8 +326,8 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
307
326
|
)
|
|
308
327
|
raise PluginError(
|
|
309
328
|
"Found no path passed including with 'include-markdown'"
|
|
310
|
-
f' directive at
|
|
311
|
-
f'
|
|
329
|
+
f' directive at'
|
|
330
|
+
f' {file_lineno_message(page_src_path, docs_dir, lineno)}',
|
|
312
331
|
)
|
|
313
332
|
|
|
314
333
|
arguments_string = match['arguments']
|
|
@@ -336,8 +355,8 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
336
355
|
)
|
|
337
356
|
raise PluginError(
|
|
338
357
|
"Invalid empty 'exclude' argument in 'include-markdown'"
|
|
339
|
-
f' directive at
|
|
340
|
-
f'
|
|
358
|
+
f' directive at'
|
|
359
|
+
f' {file_lineno_message(page_src_path, docs_dir, lineno)}',
|
|
341
360
|
)
|
|
342
361
|
ignore_paths.extend(
|
|
343
362
|
resolve_file_paths_to_exclude(
|
|
@@ -362,8 +381,7 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
362
381
|
)
|
|
363
382
|
raise PluginError(
|
|
364
383
|
f"No files found including '{raw_filename}' at"
|
|
365
|
-
f' {
|
|
366
|
-
f':{lineno}',
|
|
384
|
+
f' {file_lineno_message(page_src_path, docs_dir, lineno)}',
|
|
367
385
|
)
|
|
368
386
|
|
|
369
387
|
if files_watcher is not None and not is_url:
|
|
@@ -386,8 +404,8 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
386
404
|
raise PluginError(
|
|
387
405
|
f"Invalid value for '{invalid_bool_args[0]}' argument of"
|
|
388
406
|
" 'include-markdown' directive at"
|
|
389
|
-
f' {
|
|
390
|
-
f'
|
|
407
|
+
f' {file_lineno_message(page_src_path, docs_dir, lineno)}.'
|
|
408
|
+
f' Possible values are true or false.',
|
|
391
409
|
)
|
|
392
410
|
|
|
393
411
|
# start and end arguments
|
|
@@ -401,8 +419,8 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
401
419
|
)
|
|
402
420
|
raise PluginError(
|
|
403
421
|
"Invalid empty 'start' argument in 'include-markdown'"
|
|
404
|
-
f' directive at
|
|
405
|
-
f'
|
|
422
|
+
f' directive at'
|
|
423
|
+
f' {file_lineno_message(page_src_path, docs_dir, lineno)}',
|
|
406
424
|
)
|
|
407
425
|
else:
|
|
408
426
|
start = defaults['start']
|
|
@@ -417,8 +435,8 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
417
435
|
)
|
|
418
436
|
raise PluginError(
|
|
419
437
|
"Invalid empty 'end' argument in 'include-markdown'"
|
|
420
|
-
f' directive at
|
|
421
|
-
f'
|
|
438
|
+
f' directive at'
|
|
439
|
+
f' {file_lineno_message(page_src_path, docs_dir, lineno)}',
|
|
422
440
|
)
|
|
423
441
|
else:
|
|
424
442
|
end = defaults['end']
|
|
@@ -433,8 +451,8 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
433
451
|
)
|
|
434
452
|
raise PluginError(
|
|
435
453
|
"Invalid empty 'encoding' argument in 'include-markdown'"
|
|
436
|
-
' directive at
|
|
437
|
-
f'{
|
|
454
|
+
' directive at'
|
|
455
|
+
f' {file_lineno_message(page_src_path, docs_dir, lineno)}',
|
|
438
456
|
)
|
|
439
457
|
else:
|
|
440
458
|
encoding = defaults['encoding']
|
|
@@ -453,7 +471,7 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
453
471
|
raise PluginError(
|
|
454
472
|
"Invalid empty 'heading-offset' argument in"
|
|
455
473
|
" 'include-markdown' directive at"
|
|
456
|
-
f' {
|
|
474
|
+
f' {file_lineno_message(page_src_path, docs_dir, lineno)}',
|
|
457
475
|
)
|
|
458
476
|
try:
|
|
459
477
|
offset = int(offset_raw_value)
|
|
@@ -464,8 +482,8 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
464
482
|
)
|
|
465
483
|
raise PluginError(
|
|
466
484
|
f"Invalid 'heading-offset' argument \"{offset_raw_value}\""
|
|
467
|
-
" in 'include-markdown' directive at
|
|
468
|
-
f'{
|
|
485
|
+
" in 'include-markdown' directive at"
|
|
486
|
+
f' {file_lineno_message(page_src_path, docs_dir, lineno)}',
|
|
469
487
|
) from None
|
|
470
488
|
else:
|
|
471
489
|
offset = defaults['heading-offset']
|
|
@@ -523,11 +541,17 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
523
541
|
|
|
524
542
|
# relative URLs rewriting
|
|
525
543
|
if bool_options['rewrite-relative-urls'].value:
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
544
|
+
if page_src_path is None: # pragma: no cover
|
|
545
|
+
logger.warning(
|
|
546
|
+
'Relative URLs rewriting is not supported in'
|
|
547
|
+
' generated pages.',
|
|
548
|
+
)
|
|
549
|
+
else:
|
|
550
|
+
new_text_to_include = process.rewrite_relative_urls(
|
|
551
|
+
new_text_to_include,
|
|
552
|
+
source_path=file_path,
|
|
553
|
+
destination_path=page_src_path,
|
|
554
|
+
)
|
|
531
555
|
|
|
532
556
|
# comments
|
|
533
557
|
if bool_options['comments'].value:
|
|
@@ -577,12 +601,14 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
577
601
|
markdown,
|
|
578
602
|
directive_match_start,
|
|
579
603
|
)
|
|
580
|
-
|
|
604
|
+
file_lineno = file_lineno_message(
|
|
605
|
+
page_src_path, docs_dir, lineno,
|
|
606
|
+
)
|
|
581
607
|
logger.warning(
|
|
582
608
|
(
|
|
583
609
|
f"Delimiter {delimiter_name} '{delimiter_value}' of"
|
|
584
610
|
" 'include-markdown' directive at"
|
|
585
|
-
f' {
|
|
611
|
+
f' {file_lineno}'
|
|
586
612
|
f' not detected in the file{plural_suffix}'
|
|
587
613
|
f' {readable_files_to_include}'
|
|
588
614
|
),
|
|
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
|