mkdocs-include-markdown-plugin 6.0.6__tar.gz → 6.0.7__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.6 → mkdocs_include_markdown_plugin-6.0.7}/PKG-INFO +1 -1
  2. {mkdocs_include_markdown_plugin-6.0.6 → mkdocs_include_markdown_plugin-6.0.7}/pyproject.toml +1 -1
  3. {mkdocs_include_markdown_plugin-6.0.6 → mkdocs_include_markdown_plugin-6.0.7}/src/mkdocs_include_markdown_plugin/event.py +19 -3
  4. {mkdocs_include_markdown_plugin-6.0.6 → mkdocs_include_markdown_plugin-6.0.7}/.gitignore +0 -0
  5. {mkdocs_include_markdown_plugin-6.0.6 → mkdocs_include_markdown_plugin-6.0.7}/LICENSE +0 -0
  6. {mkdocs_include_markdown_plugin-6.0.6 → mkdocs_include_markdown_plugin-6.0.7}/README.md +0 -0
  7. {mkdocs_include_markdown_plugin-6.0.6 → mkdocs_include_markdown_plugin-6.0.7}/src/mkdocs_include_markdown_plugin/__init__.py +0 -0
  8. {mkdocs_include_markdown_plugin-6.0.6 → mkdocs_include_markdown_plugin-6.0.7}/src/mkdocs_include_markdown_plugin/cache.py +0 -0
  9. {mkdocs_include_markdown_plugin-6.0.6 → mkdocs_include_markdown_plugin-6.0.7}/src/mkdocs_include_markdown_plugin/config.py +0 -0
  10. {mkdocs_include_markdown_plugin-6.0.6 → mkdocs_include_markdown_plugin-6.0.7}/src/mkdocs_include_markdown_plugin/directive.py +0 -0
  11. {mkdocs_include_markdown_plugin-6.0.6 → mkdocs_include_markdown_plugin-6.0.7}/src/mkdocs_include_markdown_plugin/files_watcher.py +0 -0
  12. {mkdocs_include_markdown_plugin-6.0.6 → mkdocs_include_markdown_plugin-6.0.7}/src/mkdocs_include_markdown_plugin/plugin.py +0 -0
  13. {mkdocs_include_markdown_plugin-6.0.6 → mkdocs_include_markdown_plugin-6.0.7}/src/mkdocs_include_markdown_plugin/process.py +0 -0
  14. {mkdocs_include_markdown_plugin-6.0.6 → mkdocs_include_markdown_plugin-6.0.7}/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.6
3
+ Version: 6.0.7
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mkdocs-include-markdown-plugin"
3
- version = "6.0.6"
3
+ version = "6.0.7"
4
4
  description = "Mkdocs Markdown includer plugin."
5
5
  readme = "README.md"
6
6
  license = "Apache-2.0"
@@ -58,6 +58,22 @@ def lineno_from_content_start(content: str, start: int) -> int:
58
58
  return content[:start].count('\n') + 1
59
59
 
60
60
 
61
+ def safe_os_path_relpath(path: str, start: str) -> str:
62
+ """Return the relative path of a file from a start directory.
63
+
64
+ Safe version of `os.path.relpath` that catches `ValueError` exceptions
65
+ on Windows and returns the original path in case of error.
66
+ On Windows, `ValueError` is raised when `path` and `start` are on
67
+ different drives.
68
+ """
69
+ if os.name != 'nt': # pragma: nt no cover
70
+ return os.path.relpath(path, start)
71
+ try: # pragma: nt cover
72
+ return os.path.relpath(path, start)
73
+ except ValueError: # pragma: no cover
74
+ return path
75
+
76
+
61
77
  def file_lineno_message(
62
78
  page_src_path: str | None,
63
79
  docs_dir: str,
@@ -67,7 +83,7 @@ def file_lineno_message(
67
83
  if page_src_path is None: # pragma: no cover
68
84
  return f'generated page content (line {lineno})'
69
85
  return (
70
- f'{os.path.relpath(page_src_path, docs_dir)}'
86
+ f'{safe_os_path_relpath(page_src_path, docs_dir)}'
71
87
  f':{lineno}'
72
88
  )
73
89
 
@@ -287,7 +303,7 @@ def get_file_content( # noqa: PLR0913, PLR0915
287
303
  if expected_but_any_found[i]:
288
304
  delimiter_value = locals()[delimiter_name]
289
305
  readable_files_to_include = ', '.join([
290
- os.path.relpath(fpath, docs_dir)
306
+ safe_os_path_relpath(fpath, docs_dir)
291
307
  for fpath in file_paths_to_include
292
308
  ])
293
309
  plural_suffix = 's' if len(file_paths_to_include) > 1 else ''
@@ -593,7 +609,7 @@ def get_file_content( # noqa: PLR0913, PLR0915
593
609
  if expected_but_any_found[i]:
594
610
  delimiter_value = locals()[delimiter_name]
595
611
  readable_files_to_include = ', '.join([
596
- os.path.relpath(fpath, docs_dir)
612
+ safe_os_path_relpath(fpath, docs_dir)
597
613
  for fpath in file_paths_to_include
598
614
  ])
599
615
  plural_suffix = 's' if len(file_paths_to_include) > 1 else ''