mkdocs-include-markdown-plugin 7.2.1__tar.gz → 7.3.0__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 (16) hide show
  1. {mkdocs_include_markdown_plugin-7.2.1 → mkdocs_include_markdown_plugin-7.3.0}/PKG-INFO +14 -1
  2. {mkdocs_include_markdown_plugin-7.2.1 → mkdocs_include_markdown_plugin-7.3.0}/README.md +13 -0
  3. {mkdocs_include_markdown_plugin-7.2.1 → mkdocs_include_markdown_plugin-7.3.0}/pyproject.toml +1 -1
  4. {mkdocs_include_markdown_plugin-7.2.1 → mkdocs_include_markdown_plugin-7.3.0}/src/mkdocs_include_markdown_plugin/config.py +1 -0
  5. {mkdocs_include_markdown_plugin-7.2.1 → mkdocs_include_markdown_plugin-7.3.0}/src/mkdocs_include_markdown_plugin/event.py +40 -16
  6. {mkdocs_include_markdown_plugin-7.2.1 → mkdocs_include_markdown_plugin-7.3.0}/src/mkdocs_include_markdown_plugin/process.py +5 -2
  7. {mkdocs_include_markdown_plugin-7.2.1 → mkdocs_include_markdown_plugin-7.3.0}/.gitignore +0 -0
  8. {mkdocs_include_markdown_plugin-7.2.1 → mkdocs_include_markdown_plugin-7.3.0}/LICENSE +0 -0
  9. {mkdocs_include_markdown_plugin-7.2.1 → mkdocs_include_markdown_plugin-7.3.0}/src/mkdocs_include_markdown_plugin/__init__.py +0 -0
  10. {mkdocs_include_markdown_plugin-7.2.1 → mkdocs_include_markdown_plugin-7.3.0}/src/mkdocs_include_markdown_plugin/cache.py +0 -0
  11. {mkdocs_include_markdown_plugin-7.2.1 → mkdocs_include_markdown_plugin-7.3.0}/src/mkdocs_include_markdown_plugin/directive.py +0 -0
  12. {mkdocs_include_markdown_plugin-7.2.1 → mkdocs_include_markdown_plugin-7.3.0}/src/mkdocs_include_markdown_plugin/files_watcher.py +0 -0
  13. {mkdocs_include_markdown_plugin-7.2.1 → mkdocs_include_markdown_plugin-7.3.0}/src/mkdocs_include_markdown_plugin/logger.py +0 -0
  14. {mkdocs_include_markdown_plugin-7.2.1 → mkdocs_include_markdown_plugin-7.3.0}/src/mkdocs_include_markdown_plugin/placeholders.py +0 -0
  15. {mkdocs_include_markdown_plugin-7.2.1 → mkdocs_include_markdown_plugin-7.3.0}/src/mkdocs_include_markdown_plugin/plugin.py +0 -0
  16. {mkdocs_include_markdown_plugin-7.2.1 → mkdocs_include_markdown_plugin-7.3.0}/src/mkdocs_include_markdown_plugin/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocs-include-markdown-plugin
3
- Version: 7.2.1
3
+ Version: 7.3.0
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,6 +96,7 @@ plugins:
96
96
  start: <!--start-->
97
97
  end: <!--end-->
98
98
  recursive: true
99
+ order: alpha-path
99
100
  ```
100
101
 
101
102
  #### `opening_tag` and `closing_tag`
@@ -176,6 +177,18 @@ plugins:
176
177
  include: replace
177
178
  ```
178
179
 
180
+ <!-- mdpo-disable-next-line -->
181
+
182
+ #### `include_from_url`
183
+
184
+ Allow including content from URLs.
185
+
186
+ ```yaml
187
+ plugins:
188
+ - include-markdown:
189
+ include_from_url: true
190
+ ```
191
+
179
192
  ### Reference
180
193
 
181
194
  This plugin provides two directives, one to include Markdown files and another
@@ -61,6 +61,7 @@ plugins:
61
61
  start: <!--start-->
62
62
  end: <!--end-->
63
63
  recursive: true
64
+ order: alpha-path
64
65
  ```
65
66
 
66
67
  #### `opening_tag` and `closing_tag`
@@ -141,6 +142,18 @@ plugins:
141
142
  include: replace
142
143
  ```
143
144
 
145
+ <!-- mdpo-disable-next-line -->
146
+
147
+ #### `include_from_url`
148
+
149
+ Allow including content from URLs.
150
+
151
+ ```yaml
152
+ plugins:
153
+ - include-markdown:
154
+ include_from_url: true
155
+ ```
156
+
144
157
  ### Reference
145
158
 
146
159
  This plugin provides two directives, one to include Markdown files and another
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mkdocs-include-markdown-plugin"
3
- version = "7.2.1"
3
+ version = "7.3.0"
4
4
  description = "Mkdocs Markdown includer plugin."
5
5
  readme = "README.md"
6
6
  license = "Apache-2.0"
@@ -35,3 +35,4 @@ class PluginConfig(Config): # noqa: D101
35
35
  'include-markdown': 'include-markdown',
36
36
  },
37
37
  )
38
+ include_from_url = MkType(bool, default=True)
@@ -55,6 +55,7 @@ if TYPE_CHECKING: # pragma: no cover
55
55
  @dataclass
56
56
  class Settings: # noqa: D101
57
57
  exclude: list[str] | None
58
+ include_from_url: bool = False
58
59
 
59
60
 
60
61
  def get_file_content( # noqa: PLR0913, PLR0915
@@ -169,14 +170,25 @@ def get_file_content( # noqa: PLR0913, PLR0915
169
170
  order,
170
171
  )
171
172
 
172
- if is_url and 'order' in used_arguments: # pragma: no cover
173
- location = process.file_lineno_message(
174
- page_src_path, docs_dir, directive_lineno(),
175
- )
176
- logger.warning(
177
- f"Ignoring 'order' argument of 'include' directive"
178
- f" at {location} because the included path is a URL",
179
- )
173
+ if is_url:
174
+ if 'order' in used_arguments: # pragma: no cover
175
+ location = process.file_lineno_message(
176
+ page_src_path, docs_dir, directive_lineno(),
177
+ )
178
+ logger.warning(
179
+ f"Ignoring 'order' argument of 'include' directive"
180
+ f" at {location} because the included path is a URL",
181
+ )
182
+
183
+ if not settings.include_from_url:
184
+ location = process.file_lineno_message(
185
+ page_src_path, docs_dir, directive_lineno(),
186
+ )
187
+ raise PluginError(
188
+ f'Including from URL at {location} is not allowed because'
189
+ ' include-markdown is configured with include_from_url set'
190
+ ' to false',
191
+ )
180
192
 
181
193
  if not file_paths_to_include:
182
194
  location = process.file_lineno_message(
@@ -414,14 +426,25 @@ def get_file_content( # noqa: PLR0913, PLR0915
414
426
  order,
415
427
  )
416
428
 
417
- if is_url and 'order' in used_arguments: # pragma: no cover
418
- location = process.file_lineno_message(
419
- page_src_path, docs_dir, directive_lineno(),
420
- )
421
- logger.warning(
422
- f"Ignoring 'order' argument of 'include-markdown' directive"
423
- f" at {location} because the included path is a URL",
424
- )
429
+ if is_url:
430
+ if 'order' in used_arguments: # pragma: no cover
431
+ location = process.file_lineno_message(
432
+ page_src_path, docs_dir, directive_lineno(),
433
+ )
434
+ logger.warning(
435
+ f"Ignoring 'order' argument of 'include-markdown' directive"
436
+ f" at {location} because the included path is a URL",
437
+ )
438
+
439
+ if not settings.include_from_url:
440
+ location = process.file_lineno_message(
441
+ page_src_path, docs_dir, directive_lineno(),
442
+ )
443
+ raise PluginError(
444
+ f'Including from URL at {location} is not allowed because'
445
+ ' include-markdown is configured with include_from_url set'
446
+ ' to false',
447
+ )
425
448
 
426
449
  if not file_paths_to_include:
427
450
  location = process.file_lineno_message(
@@ -713,6 +736,7 @@ def on_page_markdown(
713
736
  },
714
737
  Settings(
715
738
  exclude=config.exclude,
739
+ include_from_url=config.include_from_url,
716
740
  ),
717
741
  files_watcher=plugin._files_watcher,
718
742
  http_cache=plugin._cache or http_cache,
@@ -547,8 +547,11 @@ def sort_paths(paths: list[str], order: OrderOption) -> list[str]:
547
547
  return os.path.splitext(p)[1]
548
548
  elif order_type == 'natural':
549
549
  if order_by == 'extension':
550
- def key(p: str) -> str:
551
- return natural_sort_key(os.path.splitext(p)[1]) # type: ignore
550
+ def key(p: str) -> tuple: # type: ignore
551
+ return (
552
+ natural_sort_key(os.path.splitext(p)[1]),
553
+ natural_sort_key(os.path.basename(p)),
554
+ )
552
555
  elif order_by == 'name':
553
556
  def key(p: str) -> str:
554
557
  return natural_sort_key(os.path.basename(p)) # type: ignore