mkdocs-include-markdown-plugin 6.0.7__tar.gz → 6.1.1__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 (14) hide show
  1. {mkdocs_include_markdown_plugin-6.0.7 → mkdocs_include_markdown_plugin-6.1.1}/PKG-INFO +5 -1
  2. {mkdocs_include_markdown_plugin-6.0.7 → mkdocs_include_markdown_plugin-6.1.1}/README.md +4 -0
  3. {mkdocs_include_markdown_plugin-6.0.7 → mkdocs_include_markdown_plugin-6.1.1}/pyproject.toml +1 -1
  4. {mkdocs_include_markdown_plugin-6.0.7 → mkdocs_include_markdown_plugin-6.1.1}/src/mkdocs_include_markdown_plugin/config.py +1 -0
  5. {mkdocs_include_markdown_plugin-6.0.7 → mkdocs_include_markdown_plugin-6.1.1}/src/mkdocs_include_markdown_plugin/directive.py +2 -0
  6. {mkdocs_include_markdown_plugin-6.0.7 → mkdocs_include_markdown_plugin-6.1.1}/src/mkdocs_include_markdown_plugin/event.py +44 -51
  7. {mkdocs_include_markdown_plugin-6.0.7 → mkdocs_include_markdown_plugin-6.1.1}/.gitignore +0 -0
  8. {mkdocs_include_markdown_plugin-6.0.7 → mkdocs_include_markdown_plugin-6.1.1}/LICENSE +0 -0
  9. {mkdocs_include_markdown_plugin-6.0.7 → mkdocs_include_markdown_plugin-6.1.1}/src/mkdocs_include_markdown_plugin/__init__.py +0 -0
  10. {mkdocs_include_markdown_plugin-6.0.7 → mkdocs_include_markdown_plugin-6.1.1}/src/mkdocs_include_markdown_plugin/cache.py +0 -0
  11. {mkdocs_include_markdown_plugin-6.0.7 → mkdocs_include_markdown_plugin-6.1.1}/src/mkdocs_include_markdown_plugin/files_watcher.py +0 -0
  12. {mkdocs_include_markdown_plugin-6.0.7 → mkdocs_include_markdown_plugin-6.1.1}/src/mkdocs_include_markdown_plugin/plugin.py +0 -0
  13. {mkdocs_include_markdown_plugin-6.0.7 → mkdocs_include_markdown_plugin-6.1.1}/src/mkdocs_include_markdown_plugin/process.py +0 -0
  14. {mkdocs_include_markdown_plugin-6.0.7 → mkdocs_include_markdown_plugin-6.1.1}/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.7
3
+ Version: 6.1.1
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
@@ -94,6 +94,7 @@ plugins:
94
94
  heading_offset: 0
95
95
  start: <!--start-->
96
96
  end: <!--end-->
97
+ recursive: true
97
98
  ```
98
99
 
99
100
  #### `opening_tag` and `closing_tag`
@@ -280,6 +281,9 @@ Includes the content of a file or a group of files.
280
281
  - <a name="include_encoding" href="#include_encoding">#</a>
281
282
  **encoding** (_utf-8_): Specify the encoding of the included file.
282
283
  If not defined `utf-8` will be used.
284
+ - <a name="recursive" href="#include_recursive">#</a>
285
+ **recursive** (_true_): When this option is disabled, included files are not
286
+ processed for recursive includes. Possible values are `true` and `false`.
283
287
 
284
288
  ##### Examples
285
289
 
@@ -59,6 +59,7 @@ plugins:
59
59
  heading_offset: 0
60
60
  start: <!--start-->
61
61
  end: <!--end-->
62
+ recursive: true
62
63
  ```
63
64
 
64
65
  #### `opening_tag` and `closing_tag`
@@ -245,6 +246,9 @@ Includes the content of a file or a group of files.
245
246
  - <a name="include_encoding" href="#include_encoding">#</a>
246
247
  **encoding** (_utf-8_): Specify the encoding of the included file.
247
248
  If not defined `utf-8` will be used.
249
+ - <a name="recursive" href="#include_recursive">#</a>
250
+ **recursive** (_true_): When this option is disabled, included files are not
251
+ processed for recursive includes. Possible values are `true` and `false`.
248
252
 
249
253
  ##### Examples
250
254
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mkdocs-include-markdown-plugin"
3
- version = "6.0.7"
3
+ version = "6.1.1"
4
4
  description = "Mkdocs Markdown includer plugin."
5
5
  readme = "README.md"
6
6
  license = "Apache-2.0"
@@ -24,3 +24,4 @@ class PluginConfig(Config): # noqa: D101
24
24
  end = Optional(MkType(str))
25
25
  exclude = ListOfItems(MkType(str), default=[])
26
26
  cache = MkType(int, default=0)
27
+ recursive = MkType(bool, default=True)
@@ -34,6 +34,7 @@ if TYPE_CHECKING:
34
34
  'comments': bool,
35
35
  'rewrite-relative-urls': bool,
36
36
  'heading-offset': int,
37
+ 'recursive': bool,
37
38
  'start': str | None,
38
39
  'end': str | None,
39
40
  },
@@ -96,6 +97,7 @@ ARGUMENT_REGEXES = {
96
97
  'dedent': arg('dedent'),
97
98
  'trailing-newlines': arg('trailing-newlines'),
98
99
  'rewrite-relative-urls': arg('rewrite-relative-urls'),
100
+ 'recursive': arg('recursive'),
99
101
 
100
102
  # int
101
103
  'heading-offset': arg('heading-offset'),
@@ -103,6 +103,22 @@ def get_file_content( # noqa: PLR0913, PLR0915
103
103
  http_cache: Cache | None = None,
104
104
  ) -> str:
105
105
  """Return the content of the file to include."""
106
+ settings_ignore_paths = []
107
+ if settings.exclude is not None:
108
+ for path in glob.glob(
109
+ [
110
+ os.path.join(docs_dir, fp)
111
+ if not os.path.isabs(fp)
112
+ else fp for fp in settings.exclude
113
+ ],
114
+ flags=GLOB_FLAGS,
115
+ root_dir=docs_dir,
116
+ ):
117
+ if path not in settings_ignore_paths:
118
+ settings_ignore_paths.append(path)
119
+ if page_src_path in settings_ignore_paths:
120
+ return markdown
121
+
106
122
  def found_include_tag( # noqa: PLR0912, PLR0915
107
123
  match: re.Match[str],
108
124
  ) -> str:
@@ -125,19 +141,7 @@ def get_file_content( # noqa: PLR0913, PLR0915
125
141
  arguments_string = match['arguments']
126
142
 
127
143
  exclude_match = ARGUMENT_REGEXES['exclude'].search(arguments_string)
128
- ignore_paths = []
129
- if settings.exclude:
130
- ignore_paths.extend(
131
- glob.glob(
132
- [
133
- os.path.join(docs_dir, fp)
134
- if not os.path.isabs(fp)
135
- else fp for fp in settings.exclude
136
- ],
137
- flags=GLOB_FLAGS,
138
- root_dir=docs_dir,
139
- ),
140
- )
144
+ ignore_paths = [*settings_ignore_paths]
141
145
  if exclude_match is not None:
142
146
  exclude_string = parse_string_argument(exclude_match)
143
147
  if exclude_string is None:
@@ -151,14 +155,13 @@ def get_file_content( # noqa: PLR0913, PLR0915
151
155
  f' {file_lineno_message(page_src_path, docs_dir, lineno)}',
152
156
  )
153
157
 
154
- ignore_paths.extend(
155
- resolve_file_paths_to_exclude(
158
+ for path in resolve_file_paths_to_exclude(
156
159
  exclude_string,
157
160
  page_src_path,
158
161
  docs_dir,
159
- ),
160
- )
161
- ignore_paths = list(set(ignore_paths))
162
+ ):
163
+ if path not in ignore_paths:
164
+ ignore_paths.append(path)
162
165
 
163
166
  file_paths_to_include, is_url = resolve_file_paths_to_include(
164
167
  filename,
@@ -181,7 +184,8 @@ def get_file_content( # noqa: PLR0913, PLR0915
181
184
  files_watcher.included_files.extend(file_paths_to_include)
182
185
 
183
186
  bool_options, invalid_bool_args = parse_bool_options(
184
- ['preserve-includer-indent', 'dedent', 'trailing-newlines'],
187
+ ['preserve-includer-indent', 'dedent',
188
+ 'trailing-newlines', 'recursive'],
185
189
  defaults,
186
190
  arguments_string,
187
191
  )
@@ -264,16 +268,17 @@ def get_file_content( # noqa: PLR0913, PLR0915
264
268
  expected_but_any_found[i] = False
265
269
 
266
270
  # nested includes
267
- new_text_to_include = get_file_content(
268
- new_text_to_include,
269
- file_path,
270
- docs_dir,
271
- tags,
272
- defaults,
273
- settings,
274
- files_watcher=files_watcher,
275
- http_cache=http_cache,
276
- )
271
+ if bool_options['recursive'].value:
272
+ new_text_to_include = get_file_content(
273
+ new_text_to_include,
274
+ file_path,
275
+ docs_dir,
276
+ tags,
277
+ defaults,
278
+ settings,
279
+ files_watcher=files_watcher,
280
+ http_cache=http_cache,
281
+ )
277
282
 
278
283
  # trailing newlines right stripping
279
284
  if not bool_options['trailing-newlines'].value:
@@ -349,19 +354,7 @@ def get_file_content( # noqa: PLR0913, PLR0915
349
354
  arguments_string = match['arguments']
350
355
 
351
356
  exclude_match = ARGUMENT_REGEXES['exclude'].search(arguments_string)
352
- ignore_paths = []
353
- if settings.exclude is not None:
354
- ignore_paths.extend(
355
- glob.glob(
356
- [
357
- os.path.join(docs_dir, fp)
358
- if not os.path.isabs(fp)
359
- else fp for fp in settings.exclude
360
- ],
361
- flags=GLOB_FLAGS,
362
- root_dir=docs_dir,
363
- ),
364
- )
357
+ ignore_paths = [*settings_ignore_paths]
365
358
  if exclude_match is not None:
366
359
  exclude_string = parse_string_argument(exclude_match)
367
360
  if exclude_string is None:
@@ -374,14 +367,13 @@ def get_file_content( # noqa: PLR0913, PLR0915
374
367
  f' directive at'
375
368
  f' {file_lineno_message(page_src_path, docs_dir, lineno)}',
376
369
  )
377
- ignore_paths.extend(
378
- resolve_file_paths_to_exclude(
370
+ for path in resolve_file_paths_to_exclude(
379
371
  exclude_string,
380
372
  page_src_path,
381
373
  docs_dir,
382
- ),
383
- )
384
- ignore_paths = list(set(ignore_paths))
374
+ ):
375
+ if path not in ignore_paths:
376
+ ignore_paths.append(path)
385
377
 
386
378
  file_paths_to_include, is_url = resolve_file_paths_to_include(
387
379
  filename,
@@ -632,12 +624,12 @@ def get_file_content( # noqa: PLR0913, PLR0915
632
624
 
633
625
  return text_to_include
634
626
 
635
- markdown = tags['include'].sub(
636
- found_include_tag,
627
+ markdown = tags['include-markdown'].sub(
628
+ found_include_markdown_tag,
637
629
  markdown,
638
630
  )
639
- return tags['include-markdown'].sub(
640
- found_include_markdown_tag,
631
+ return tags['include'].sub(
632
+ found_include_tag,
641
633
  markdown,
642
634
  )
643
635
 
@@ -667,6 +659,7 @@ def on_page_markdown(
667
659
  'comments': config.comments,
668
660
  'rewrite-relative-urls': config.rewrite_relative_urls,
669
661
  'heading-offset': config.heading_offset,
662
+ 'recursive': config.recursive,
670
663
  'start': config.start,
671
664
  'end': config.end,
672
665
  },