mkdocs-document-dates 0.3.0__py3-none-any.whl → 0.4.0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- mkdocs_document_dates/plugin.py +27 -2
- {mkdocs_document_dates-0.3.0.dist-info → mkdocs_document_dates-0.4.0.dist-info}/METADATA +2 -2
- mkdocs_document_dates-0.4.0.dist-info/RECORD +8 -0
- mkdocs_document_dates-0.3.0.dist-info/RECORD +0 -8
- {mkdocs_document_dates-0.3.0.dist-info → mkdocs_document_dates-0.4.0.dist-info}/LICENSE +0 -0
- {mkdocs_document_dates-0.3.0.dist-info → mkdocs_document_dates-0.4.0.dist-info}/WHEEL +0 -0
- {mkdocs_document_dates-0.3.0.dist-info → mkdocs_document_dates-0.4.0.dist-info}/entry_points.txt +0 -0
- {mkdocs_document_dates-0.3.0.dist-info → mkdocs_document_dates-0.4.0.dist-info}/top_level.txt +0 -0
mkdocs_document_dates/plugin.py
CHANGED
@@ -91,11 +91,36 @@ class DocumentDatesPlugin(BasePlugin):
|
|
91
91
|
|
92
92
|
def on_page_markdown(self, markdown, page, config, files):
|
93
93
|
"""处理页面内容,添加日期信息"""
|
94
|
-
file_path = page.file.abs_src_path
|
94
|
+
file_path = Path(page.file.abs_src_path)
|
95
|
+
docs_dir = Path(config['docs_dir'])
|
95
96
|
|
96
97
|
# 检查是否在排除列表中
|
97
98
|
for exclude_pattern in self.config['exclude']:
|
98
|
-
|
99
|
+
# 处理目录递归排除(如 private/*)
|
100
|
+
if exclude_pattern.endswith('/*'):
|
101
|
+
base_dir = exclude_pattern[:-2] # 移除 /*
|
102
|
+
try:
|
103
|
+
# 检查当前文件是否在指定目录或其子目录中
|
104
|
+
rel_path = file_path.relative_to(docs_dir)
|
105
|
+
if str(rel_path).startswith(f"{base_dir}/"):
|
106
|
+
return markdown
|
107
|
+
except ValueError:
|
108
|
+
continue
|
109
|
+
|
110
|
+
# 处理特定目录下的特定类型文件(如 drafts/*.md)
|
111
|
+
elif '/*.' in exclude_pattern:
|
112
|
+
dir_part, ext_part = exclude_pattern.split('/*.')
|
113
|
+
if (file_path.parent.name == dir_part and
|
114
|
+
file_path.suffix == f".{ext_part}"):
|
115
|
+
return markdown
|
116
|
+
|
117
|
+
# 处理特定后缀文件(如 *.tmp)
|
118
|
+
elif exclude_pattern.startswith('*.'):
|
119
|
+
if file_path.suffix == f".{exclude_pattern[2:]}":
|
120
|
+
return markdown
|
121
|
+
|
122
|
+
# 处理精确文件匹配(如 temp.md)
|
123
|
+
elif file_path.name == exclude_pattern:
|
99
124
|
return markdown
|
100
125
|
|
101
126
|
# 直接获取日期信息
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: mkdocs-document-dates
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.4.0
|
4
4
|
Summary: A MkDocs plugin for displaying accurate document creation and last modification dates.
|
5
5
|
Home-page: https://github.com/jaywhj/mkdocs-document-dates
|
6
6
|
Author: Aaron Wang
|
@@ -66,7 +66,7 @@ plugins:
|
|
66
66
|
time_format: '%H:%M:%S' # Time format
|
67
67
|
position: bottom # Display position: top (after title) or bottom (end of document)
|
68
68
|
exclude: # List of file patterns to exclude
|
69
|
-
- "private/*" # Exclude all files in private directory
|
69
|
+
- "private/*" # Exclude all files in private directory, including subdirectories
|
70
70
|
- "drafts/*.md" # Exclude all markdown files in drafts directory
|
71
71
|
- "temp.md" # Exclude specific file
|
72
72
|
- "*.tmp" # Exclude all files with .tmp extension
|
@@ -0,0 +1,8 @@
|
|
1
|
+
mkdocs_document_dates/__init__.py,sha256=yom7psmObebsZY0AwCN1PjlGUwPkny2r6NyzoO0cudg,58
|
2
|
+
mkdocs_document_dates/plugin.py,sha256=zn9BfgqR3peyH33uY8Jwx1BDFT9fuMQgPsT5Y-0xo-Y,6584
|
3
|
+
mkdocs_document_dates-0.4.0.dist-info/LICENSE,sha256=1YKfCs5WKSk-bON8a68WZE5to1B2klCrHBYiuaVCThM,514
|
4
|
+
mkdocs_document_dates-0.4.0.dist-info/METADATA,sha256=4_lWCetVk8oxW6Acp7JEi7WG5GVTI7AffuHzCBgPNhw,3278
|
5
|
+
mkdocs_document_dates-0.4.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
6
|
+
mkdocs_document_dates-0.4.0.dist-info/entry_points.txt,sha256=gI-OFLGjDG6-oLEfyevl3Gwwj2GcqVFQeX3bvL1IF8o,83
|
7
|
+
mkdocs_document_dates-0.4.0.dist-info/top_level.txt,sha256=yWkKQdNuAJJVqUQ9uLa5xD4x_Gux4IfOUpy8Ryagdwc,22
|
8
|
+
mkdocs_document_dates-0.4.0.dist-info/RECORD,,
|
@@ -1,8 +0,0 @@
|
|
1
|
-
mkdocs_document_dates/__init__.py,sha256=yom7psmObebsZY0AwCN1PjlGUwPkny2r6NyzoO0cudg,58
|
2
|
-
mkdocs_document_dates/plugin.py,sha256=uxjid20k8O3PnOdCV0FMxnE6iLp_J3aPJ3RIsNQcUUE,5397
|
3
|
-
mkdocs_document_dates-0.3.0.dist-info/LICENSE,sha256=1YKfCs5WKSk-bON8a68WZE5to1B2klCrHBYiuaVCThM,514
|
4
|
-
mkdocs_document_dates-0.3.0.dist-info/METADATA,sha256=E2lIEIgHJ0Kw9ZaavKM-Fqrv-AIm9Gsz10nFsbuNb8o,3252
|
5
|
-
mkdocs_document_dates-0.3.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
6
|
-
mkdocs_document_dates-0.3.0.dist-info/entry_points.txt,sha256=gI-OFLGjDG6-oLEfyevl3Gwwj2GcqVFQeX3bvL1IF8o,83
|
7
|
-
mkdocs_document_dates-0.3.0.dist-info/top_level.txt,sha256=yWkKQdNuAJJVqUQ9uLa5xD4x_Gux4IfOUpy8Ryagdwc,22
|
8
|
-
mkdocs_document_dates-0.3.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{mkdocs_document_dates-0.3.0.dist-info → mkdocs_document_dates-0.4.0.dist-info}/entry_points.txt
RENAMED
File without changes
|
{mkdocs_document_dates-0.3.0.dist-info → mkdocs_document_dates-0.4.0.dist-info}/top_level.txt
RENAMED
File without changes
|