mkdocs-document-dates 1.1.0__py3-none-any.whl → 1.3.0__py3-none-any.whl
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_document_dates/plugin.py +19 -18
- {mkdocs_document_dates-1.1.0.dist-info → mkdocs_document_dates-1.3.0.dist-info}/METADATA +3 -3
- {mkdocs_document_dates-1.1.0.dist-info → mkdocs_document_dates-1.3.0.dist-info}/RECORD +7 -7
- {mkdocs_document_dates-1.1.0.dist-info → mkdocs_document_dates-1.3.0.dist-info}/LICENSE +0 -0
- {mkdocs_document_dates-1.1.0.dist-info → mkdocs_document_dates-1.3.0.dist-info}/WHEEL +0 -0
- {mkdocs_document_dates-1.1.0.dist-info → mkdocs_document_dates-1.3.0.dist-info}/entry_points.txt +0 -0
- {mkdocs_document_dates-1.1.0.dist-info → mkdocs_document_dates-1.3.0.dist-info}/top_level.txt +0 -0
mkdocs_document_dates/plugin.py
CHANGED
@@ -148,26 +148,27 @@ class DocumentDatesPlugin(BasePlugin):
|
|
148
148
|
def _get_file_dates(self, file_path):
|
149
149
|
"""获取文件的创建时间和修改时间"""
|
150
150
|
try:
|
151
|
+
# 获取文件的相对路径(相对于 docs 目录)
|
152
|
+
docs_dir = Path(self.config['docs_dir'])
|
153
|
+
rel_path = str(Path(file_path).relative_to(docs_dir))
|
154
|
+
|
151
155
|
# 尝试从缓存读取时间信息
|
152
|
-
|
156
|
+
cache_paths = [
|
157
|
+
# 部署环境路径(gh-pages)
|
158
|
+
Path(file_path).parent / 'assets' / 'dates_cache.json',
|
159
|
+
# 开发环境路径(main)
|
160
|
+
docs_dir / 'assets' / 'dates_cache.json'
|
161
|
+
]
|
153
162
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
dates_cache = json.load(f)
|
164
|
-
# 获取相对于 docs 目录的路径
|
165
|
-
rel_path = str(Path(file_path).name) # 只使用文件名,因为发布后目录结构已改变
|
166
|
-
if rel_path in dates_cache:
|
167
|
-
return (
|
168
|
-
datetime.fromisoformat(dates_cache[rel_path]['created']),
|
169
|
-
datetime.fromisoformat(dates_cache[rel_path]['modified'])
|
170
|
-
)
|
163
|
+
for cache_file in cache_paths:
|
164
|
+
if cache_file.exists():
|
165
|
+
with open(cache_file) as f:
|
166
|
+
dates_cache = json.load(f)
|
167
|
+
if rel_path in dates_cache:
|
168
|
+
return (
|
169
|
+
datetime.fromisoformat(dates_cache[rel_path]['created']),
|
170
|
+
datetime.fromisoformat(dates_cache[rel_path]['modified'])
|
171
|
+
)
|
171
172
|
|
172
173
|
# 如果缓存不存在或文件不在缓存中,使用文件系统时间
|
173
174
|
stat = os.stat(file_path)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: mkdocs-document-dates
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.3.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
|
@@ -111,8 +111,8 @@ modified: 2023-12-31
|
|
111
111
|
- macOS: Uses file creation time (birthtime)
|
112
112
|
- Linux: Uses modification time as creation time due to system limitations, if you need the exact creation time, you can manually specify it in Front Matter
|
113
113
|
- It still works when using CI/CD build systems (e.g. Github Actions)
|
114
|
-
- Used a cache file
|
115
|
-
- You can configure it like this: `pip install --upgrade mkdocs-document-dates` or `pip install mkdocs-document-dates==1.
|
114
|
+
- Used a cache file `dates_cache.json` to solve this problem
|
115
|
+
- You can configure it like this: `pip install --upgrade mkdocs-document-dates` or `pip install mkdocs-document-dates==1.2.0`
|
116
116
|
```
|
117
117
|
- run: pip install --upgrade mkdocs-document-dates
|
118
118
|
- run: mkdocs gh-deploy --force
|
@@ -1,5 +1,5 @@
|
|
1
1
|
mkdocs_document_dates/__init__.py,sha256=CZ37u8DC6kbkupKFk-VKyfKZZFAJ4rOD0aPzOzVoATc,58
|
2
|
-
mkdocs_document_dates/plugin.py,sha256
|
2
|
+
mkdocs_document_dates/plugin.py,sha256=_L4h7WYNAYWkzOLc4EAUAxpPAoO27eOc5GAMbutgGjA,9879
|
3
3
|
mkdocs_document_dates/styles.py,sha256=ujhlKgDWsOo5sHiYtf3XekuGg4C5Yjol8RzP3W9Wzjo,578
|
4
4
|
mkdocs_document_dates/hooks/pre-commit,sha256=gZNpQ2_l5ETAo_c1T2oOzkZ3JohSRb2CepWZg2ukqSg,3807
|
5
5
|
mkdocs_document_dates/lang/__init__.py,sha256=M1BLjCOA3HHKeAitk45YAgzxxNpnxFUvVAk6-FO_QSA,690
|
@@ -13,9 +13,9 @@ mkdocs_document_dates/lang/ko.py,sha256=GwY6yrKYAOj6S6feq9yqNxr2XpyGHC0XeenO541v
|
|
13
13
|
mkdocs_document_dates/lang/ru.py,sha256=fK5s4mQKCoP6KI3jf6eqqmqB3YVn39q81U7Cw1QWNNg,721
|
14
14
|
mkdocs_document_dates/lang/zh.py,sha256=OrLElrSTZhHSwxBzuUtUj7NpQb7wm0s83viimpk2ynM,519
|
15
15
|
mkdocs_document_dates/lang/zh_tw.py,sha256=t3qu-a7UOzgcmYDkLFiosJZCcpfMU4xiKTJfu1ZHoHA,519
|
16
|
-
mkdocs_document_dates-1.
|
17
|
-
mkdocs_document_dates-1.
|
18
|
-
mkdocs_document_dates-1.
|
19
|
-
mkdocs_document_dates-1.
|
20
|
-
mkdocs_document_dates-1.
|
21
|
-
mkdocs_document_dates-1.
|
16
|
+
mkdocs_document_dates-1.3.0.dist-info/LICENSE,sha256=1YKfCs5WKSk-bON8a68WZE5to1B2klCrHBYiuaVCThM,514
|
17
|
+
mkdocs_document_dates-1.3.0.dist-info/METADATA,sha256=ZWYtaew6x56ReiQn8RYcGaqNldu-slQnA13nv47T9ek,3941
|
18
|
+
mkdocs_document_dates-1.3.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
19
|
+
mkdocs_document_dates-1.3.0.dist-info/entry_points.txt,sha256=gI-OFLGjDG6-oLEfyevl3Gwwj2GcqVFQeX3bvL1IF8o,83
|
20
|
+
mkdocs_document_dates-1.3.0.dist-info/top_level.txt,sha256=yWkKQdNuAJJVqUQ9uLa5xD4x_Gux4IfOUpy8Ryagdwc,22
|
21
|
+
mkdocs_document_dates-1.3.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{mkdocs_document_dates-1.1.0.dist-info → mkdocs_document_dates-1.3.0.dist-info}/entry_points.txt
RENAMED
File without changes
|
{mkdocs_document_dates-1.1.0.dist-info → mkdocs_document_dates-1.3.0.dist-info}/top_level.txt
RENAMED
File without changes
|