mkdocs-include-markdown-plugin 6.0.4__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.4 → mkdocs_include_markdown_plugin-6.0.6}/LICENSE +1 -1
- {mkdocs_include_markdown_plugin-6.0.4 → mkdocs_include_markdown_plugin-6.0.6}/PKG-INFO +57 -46
- {mkdocs_include_markdown_plugin-6.0.4 → mkdocs_include_markdown_plugin-6.0.6}/README.md +55 -44
- {mkdocs_include_markdown_plugin-6.0.4 → mkdocs_include_markdown_plugin-6.0.6}/pyproject.toml +13 -10
- {mkdocs_include_markdown_plugin-6.0.4 → mkdocs_include_markdown_plugin-6.0.6}/src/mkdocs_include_markdown_plugin/directive.py +24 -11
- {mkdocs_include_markdown_plugin-6.0.4 → mkdocs_include_markdown_plugin-6.0.6}/src/mkdocs_include_markdown_plugin/event.py +73 -47
- {mkdocs_include_markdown_plugin-6.0.4 → mkdocs_include_markdown_plugin-6.0.6}/.gitignore +0 -0
- {mkdocs_include_markdown_plugin-6.0.4 → mkdocs_include_markdown_plugin-6.0.6}/src/mkdocs_include_markdown_plugin/__init__.py +0 -0
- {mkdocs_include_markdown_plugin-6.0.4 → mkdocs_include_markdown_plugin-6.0.6}/src/mkdocs_include_markdown_plugin/cache.py +0 -0
- {mkdocs_include_markdown_plugin-6.0.4 → mkdocs_include_markdown_plugin-6.0.6}/src/mkdocs_include_markdown_plugin/config.py +0 -0
- {mkdocs_include_markdown_plugin-6.0.4 → mkdocs_include_markdown_plugin-6.0.6}/src/mkdocs_include_markdown_plugin/files_watcher.py +0 -0
- {mkdocs_include_markdown_plugin-6.0.4 → mkdocs_include_markdown_plugin-6.0.6}/src/mkdocs_include_markdown_plugin/plugin.py +0 -0
- {mkdocs_include_markdown_plugin-6.0.4 → mkdocs_include_markdown_plugin-6.0.6}/src/mkdocs_include_markdown_plugin/process.py +0 -0
- {mkdocs_include_markdown_plugin-6.0.4 → mkdocs_include_markdown_plugin-6.0.6}/src/mkdocs_include_markdown_plugin/py.typed +0 -0
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
same "printed page" as the copyright notice for easier
|
|
188
188
|
identification within third-party archives.
|
|
189
189
|
|
|
190
|
-
Copyright 2017-
|
|
190
|
+
Copyright 2017-2024 Joe Rickerby and contributors
|
|
191
191
|
|
|
192
192
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
193
|
you may not use this file except in compliance with the License.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
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
|
|
@@ -96,46 +96,51 @@ plugins:
|
|
|
96
96
|
end: <!--end-->
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
99
|
+
#### `opening_tag` and `closing_tag`
|
|
100
|
+
|
|
101
|
+
Default opening and closing tags. When not specified they are `{%` and `%}`.
|
|
102
|
+
|
|
103
|
+
```yaml
|
|
104
|
+
plugins:
|
|
105
|
+
- include-markdown:
|
|
106
|
+
opening_tag: "{!"
|
|
107
|
+
closing_tag: "!}"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
<!-- mdpo-disable-next-line -->
|
|
111
|
+
|
|
112
|
+
#### `exclude`
|
|
113
|
+
|
|
114
|
+
Global exclusion wildcard patterns. Relative paths defined here will be
|
|
115
|
+
relative to the [`docs_dir`] directory.
|
|
116
|
+
|
|
117
|
+
```yaml
|
|
118
|
+
plugins:
|
|
119
|
+
- include-markdown:
|
|
120
|
+
exclude:
|
|
121
|
+
- LICENSE.md
|
|
122
|
+
- api/**
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
<!-- mdpo-disable-next-line -->
|
|
126
|
+
|
|
127
|
+
#### `cache`
|
|
128
|
+
|
|
129
|
+
Expiration time in seconds for cached HTTP requests when including from URLs.
|
|
130
|
+
|
|
131
|
+
```yaml
|
|
132
|
+
plugins:
|
|
133
|
+
- include-markdown:
|
|
134
|
+
cache: 600
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
In order to use this feature, the dependency [platformdirs] must be installed.
|
|
138
|
+
You can include it in the installation of the plugin adding the `cache` extra:
|
|
139
|
+
|
|
140
|
+
```txt
|
|
141
|
+
# requirements.txt
|
|
142
|
+
mkdocs-include-markdown-plugin[cache]
|
|
143
|
+
```
|
|
139
144
|
|
|
140
145
|
### Reference
|
|
141
146
|
|
|
@@ -148,7 +153,9 @@ Paths of included files can be either:
|
|
|
148
153
|
- Local files:
|
|
149
154
|
- Absolute paths (starting with a path separator).
|
|
150
155
|
- Relative from the file that includes them (starting with `./` or `../`).
|
|
151
|
-
- Relative
|
|
156
|
+
- Relative to the [`docs_dir`] directory. For instance if your `docs_dir` is
|
|
157
|
+
_./docs/_, then `includes/header.md` will match the file
|
|
158
|
+
_./docs/includes/header.md_.
|
|
152
159
|
- [Bash wildcard globs] matching multiple local files.
|
|
153
160
|
|
|
154
161
|
File paths to include and string arguments can be wrapped by double `"` or
|
|
@@ -212,7 +219,7 @@ content to include.
|
|
|
212
219
|
|
|
213
220
|
```jinja
|
|
214
221
|
{%
|
|
215
|
-
include-markdown '
|
|
222
|
+
include-markdown 'includes/header.md'
|
|
216
223
|
start='<!--\n\ttable-start\n-->'
|
|
217
224
|
end='<!--\n\ttable-end\n-->'
|
|
218
225
|
rewrite-relative-urls=false
|
|
@@ -222,7 +229,7 @@ content to include.
|
|
|
222
229
|
|
|
223
230
|
```jinja
|
|
224
231
|
{%
|
|
225
|
-
include-markdown "
|
|
232
|
+
include-markdown "includes/header.md"
|
|
226
233
|
heading-offset=1
|
|
227
234
|
%}
|
|
228
235
|
```
|
|
@@ -303,6 +310,10 @@ Includes the content of a file or a group of files.
|
|
|
303
310
|
[giving me the permissions][cibuildwheel-470] to separate this plugin from the
|
|
304
311
|
documentation of [cibuildwheel][cibuildwheel-repo-link].
|
|
305
312
|
|
|
313
|
+
[Bash wildcard globs]: https://facelessuser.github.io/wcmatch/glob/#syntax
|
|
314
|
+
|
|
315
|
+
<!-- mdpo-disable -->
|
|
316
|
+
|
|
306
317
|
[pypi-link]: https://pypi.org/project/mkdocs-include-markdown-plugin
|
|
307
318
|
[pypi-version-badge-link]: https://img.shields.io/pypi/v/mkdocs-include-markdown-plugin?logo=pypi&logoColor=white
|
|
308
319
|
[tests-image]: https://img.shields.io/github/actions/workflow/status/mondeja/mkdocs-include-markdown-plugin/ci.yml?logo=github&label=tests&branch=master
|
|
@@ -316,4 +327,4 @@ Includes the content of a file or a group of files.
|
|
|
316
327
|
[cibuildwheel-repo-link]: https://github.com/pypa/cibuildwheel
|
|
317
328
|
[es-readme-link]: https://github.com/mondeja/mkdocs-include-markdown-plugin/blob/master/locale/es/README.md
|
|
318
329
|
[fr-readme-link]: https://github.com/mondeja/mkdocs-include-markdown-plugin/blob/master/locale/fr/README.md
|
|
319
|
-
[
|
|
330
|
+
[`docs_dir`]: https://www.mkdocs.org/user-guide/configuration/#docs_dir
|
|
@@ -61,46 +61,51 @@ plugins:
|
|
|
61
61
|
end: <!--end-->
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
64
|
+
#### `opening_tag` and `closing_tag`
|
|
65
|
+
|
|
66
|
+
Default opening and closing tags. When not specified they are `{%` and `%}`.
|
|
67
|
+
|
|
68
|
+
```yaml
|
|
69
|
+
plugins:
|
|
70
|
+
- include-markdown:
|
|
71
|
+
opening_tag: "{!"
|
|
72
|
+
closing_tag: "!}"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
<!-- mdpo-disable-next-line -->
|
|
76
|
+
|
|
77
|
+
#### `exclude`
|
|
78
|
+
|
|
79
|
+
Global exclusion wildcard patterns. Relative paths defined here will be
|
|
80
|
+
relative to the [`docs_dir`] directory.
|
|
81
|
+
|
|
82
|
+
```yaml
|
|
83
|
+
plugins:
|
|
84
|
+
- include-markdown:
|
|
85
|
+
exclude:
|
|
86
|
+
- LICENSE.md
|
|
87
|
+
- api/**
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
<!-- mdpo-disable-next-line -->
|
|
91
|
+
|
|
92
|
+
#### `cache`
|
|
93
|
+
|
|
94
|
+
Expiration time in seconds for cached HTTP requests when including from URLs.
|
|
95
|
+
|
|
96
|
+
```yaml
|
|
97
|
+
plugins:
|
|
98
|
+
- include-markdown:
|
|
99
|
+
cache: 600
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
In order to use this feature, the dependency [platformdirs] must be installed.
|
|
103
|
+
You can include it in the installation of the plugin adding the `cache` extra:
|
|
104
|
+
|
|
105
|
+
```txt
|
|
106
|
+
# requirements.txt
|
|
107
|
+
mkdocs-include-markdown-plugin[cache]
|
|
108
|
+
```
|
|
104
109
|
|
|
105
110
|
### Reference
|
|
106
111
|
|
|
@@ -113,7 +118,9 @@ Paths of included files can be either:
|
|
|
113
118
|
- Local files:
|
|
114
119
|
- Absolute paths (starting with a path separator).
|
|
115
120
|
- Relative from the file that includes them (starting with `./` or `../`).
|
|
116
|
-
- Relative
|
|
121
|
+
- Relative to the [`docs_dir`] directory. For instance if your `docs_dir` is
|
|
122
|
+
_./docs/_, then `includes/header.md` will match the file
|
|
123
|
+
_./docs/includes/header.md_.
|
|
117
124
|
- [Bash wildcard globs] matching multiple local files.
|
|
118
125
|
|
|
119
126
|
File paths to include and string arguments can be wrapped by double `"` or
|
|
@@ -177,7 +184,7 @@ content to include.
|
|
|
177
184
|
|
|
178
185
|
```jinja
|
|
179
186
|
{%
|
|
180
|
-
include-markdown '
|
|
187
|
+
include-markdown 'includes/header.md'
|
|
181
188
|
start='<!--\n\ttable-start\n-->'
|
|
182
189
|
end='<!--\n\ttable-end\n-->'
|
|
183
190
|
rewrite-relative-urls=false
|
|
@@ -187,7 +194,7 @@ content to include.
|
|
|
187
194
|
|
|
188
195
|
```jinja
|
|
189
196
|
{%
|
|
190
|
-
include-markdown "
|
|
197
|
+
include-markdown "includes/header.md"
|
|
191
198
|
heading-offset=1
|
|
192
199
|
%}
|
|
193
200
|
```
|
|
@@ -268,6 +275,10 @@ Includes the content of a file or a group of files.
|
|
|
268
275
|
[giving me the permissions][cibuildwheel-470] to separate this plugin from the
|
|
269
276
|
documentation of [cibuildwheel][cibuildwheel-repo-link].
|
|
270
277
|
|
|
278
|
+
[Bash wildcard globs]: https://facelessuser.github.io/wcmatch/glob/#syntax
|
|
279
|
+
|
|
280
|
+
<!-- mdpo-disable -->
|
|
281
|
+
|
|
271
282
|
[pypi-link]: https://pypi.org/project/mkdocs-include-markdown-plugin
|
|
272
283
|
[pypi-version-badge-link]: https://img.shields.io/pypi/v/mkdocs-include-markdown-plugin?logo=pypi&logoColor=white
|
|
273
284
|
[tests-image]: https://img.shields.io/github/actions/workflow/status/mondeja/mkdocs-include-markdown-plugin/ci.yml?logo=github&label=tests&branch=master
|
|
@@ -281,4 +292,4 @@ Includes the content of a file or a group of files.
|
|
|
281
292
|
[cibuildwheel-repo-link]: https://github.com/pypa/cibuildwheel
|
|
282
293
|
[es-readme-link]: https://github.com/mondeja/mkdocs-include-markdown-plugin/blob/master/locale/es/README.md
|
|
283
294
|
[fr-readme-link]: https://github.com/mondeja/mkdocs-include-markdown-plugin/blob/master/locale/fr/README.md
|
|
284
|
-
[
|
|
295
|
+
[`docs_dir`]: https://www.mkdocs.org/user-guide/configuration/#docs_dir
|
{mkdocs_include_markdown_plugin-6.0.4 → 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
|
|
|
@@ -103,9 +104,9 @@ targets = [{ file = "pyproject.toml" }]
|
|
|
103
104
|
[tool.project-config]
|
|
104
105
|
cache = "2 days"
|
|
105
106
|
style = [
|
|
106
|
-
"gh://mondeja/project-config-styles@v5.1/base/pre-commit/md2po2md.json5",
|
|
107
|
-
"gh://mondeja/project-config-styles@v5.1/python/base.json5",
|
|
108
|
-
"gh://mondeja/project-config-styles@v5.1/python/mypy.json5",
|
|
107
|
+
"gh://mondeja/project-config-styles@v5.2.1/base/pre-commit/md2po2md.json5",
|
|
108
|
+
"gh://mondeja/project-config-styles@v5.2.1/python/base.json5",
|
|
109
|
+
"gh://mondeja/project-config-styles@v5.2.1/python/mypy.json5",
|
|
109
110
|
]
|
|
110
111
|
|
|
111
112
|
[tool.coverage.run]
|
|
@@ -121,6 +122,8 @@ fail_under = 1
|
|
|
121
122
|
[tool.ruff]
|
|
122
123
|
line-length = 80
|
|
123
124
|
target-version = "py38"
|
|
125
|
+
|
|
126
|
+
[tool.ruff.lint]
|
|
124
127
|
select = [
|
|
125
128
|
"W",
|
|
126
129
|
"B",
|
|
@@ -150,19 +153,19 @@ select = [
|
|
|
150
153
|
]
|
|
151
154
|
ignore = ["G004"]
|
|
152
155
|
|
|
153
|
-
[tool.ruff.pydocstyle]
|
|
156
|
+
[tool.ruff.lint.pydocstyle]
|
|
154
157
|
convention = "google"
|
|
155
158
|
|
|
156
|
-
[tool.ruff.flake8-quotes]
|
|
159
|
+
[tool.ruff.lint.flake8-quotes]
|
|
157
160
|
inline-quotes = "single"
|
|
158
161
|
multiline-quotes = "single"
|
|
159
162
|
|
|
160
|
-
[tool.ruff.flake8-pytest-style]
|
|
163
|
+
[tool.ruff.lint.flake8-pytest-style]
|
|
161
164
|
fixture-parentheses = false
|
|
162
165
|
parametrize-values-type = "tuple"
|
|
163
166
|
parametrize-values-row-type = "tuple"
|
|
164
167
|
|
|
165
|
-
[tool.ruff.isort]
|
|
168
|
+
[tool.ruff.lint.isort]
|
|
166
169
|
lines-after-imports = 2
|
|
167
170
|
combine-as-imports = true
|
|
168
171
|
force-wrap-aliases = true
|
|
@@ -176,7 +179,7 @@ extra-standard-library = [
|
|
|
176
179
|
"wsgiref.types"
|
|
177
180
|
]
|
|
178
181
|
|
|
179
|
-
[tool.ruff.per-file-ignores]
|
|
182
|
+
[tool.ruff.lint.per-file-ignores]
|
|
180
183
|
"tests/**" = [
|
|
181
184
|
"I002",
|
|
182
185
|
"D100",
|
|
@@ -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']
|
|
@@ -444,8 +462,8 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
444
462
|
arguments_string,
|
|
445
463
|
)
|
|
446
464
|
if offset_match:
|
|
447
|
-
|
|
448
|
-
if
|
|
465
|
+
offset_raw_value = offset_match[1]
|
|
466
|
+
if offset_raw_value == '':
|
|
449
467
|
lineno = lineno_from_content_start(
|
|
450
468
|
markdown,
|
|
451
469
|
directive_match_start,
|
|
@@ -453,19 +471,19 @@ 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
|
-
offset = int(
|
|
477
|
+
offset = int(offset_raw_value)
|
|
460
478
|
except ValueError:
|
|
461
479
|
lineno = lineno_from_content_start(
|
|
462
480
|
markdown,
|
|
463
481
|
directive_match_start,
|
|
464
482
|
)
|
|
465
483
|
raise PluginError(
|
|
466
|
-
f"Invalid 'heading-offset' argument \"{
|
|
467
|
-
" 'include-markdown' directive at
|
|
468
|
-
f'{
|
|
484
|
+
f"Invalid 'heading-offset' argument \"{offset_raw_value}\""
|
|
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:
|
|
@@ -556,7 +580,7 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
556
580
|
)
|
|
557
581
|
)
|
|
558
582
|
|
|
559
|
-
if
|
|
583
|
+
if offset:
|
|
560
584
|
new_text_to_include = process.increase_headings_offset(
|
|
561
585
|
new_text_to_include,
|
|
562
586
|
offset=offset + cumulative_heading_offset,
|
|
@@ -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
|