mkdocs-document-dates 2.3.0__tar.gz → 2.3.2__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 (28) hide show
  1. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/LICENSE +0 -1
  2. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/PKG-INFO +10 -10
  3. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/README.md +9 -9
  4. mkdocs_document_dates-2.3.2/mkdocs_document_dates/__init__.py +13 -0
  5. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates/hooks/pre-commit +8 -11
  6. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates/hooks_installer.py +10 -12
  7. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates/lang/__init__.py +0 -1
  8. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates/lang/ar.py +1 -0
  9. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates/lang/de.py +1 -0
  10. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates/lang/en.py +1 -0
  11. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates/lang/es.py +1 -0
  12. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates/lang/fr.py +1 -0
  13. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates/lang/ja.py +1 -0
  14. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates/lang/ko.py +1 -0
  15. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates/lang/ru.py +1 -0
  16. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates/lang/zh.py +1 -0
  17. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates/lang/zh_tw.py +1 -0
  18. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates/plugin.py +3 -21
  19. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates/styles.py +0 -1
  20. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates.egg-info/PKG-INFO +10 -10
  21. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/setup.py +1 -1
  22. mkdocs_document_dates-2.3.0/mkdocs_document_dates/__init__.py +0 -13
  23. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates.egg-info/SOURCES.txt +0 -0
  24. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates.egg-info/dependency_links.txt +0 -0
  25. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates.egg-info/entry_points.txt +0 -0
  26. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates.egg-info/requires.txt +0 -0
  27. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/mkdocs_document_dates.egg-info/top_level.txt +0 -0
  28. {mkdocs_document_dates-2.3.0 → mkdocs_document_dates-2.3.2}/setup.cfg +0 -0
@@ -9,4 +9,3 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
9
  copies of the Software, and to permit persons to whom the Software is
10
10
  furnished to do so, subject to the following conditions:
11
11
 
12
- [... 后续 MIT 许可证内容 ...]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mkdocs-document-dates
3
- Version: 2.3.0
3
+ Version: 2.3.2
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
@@ -107,18 +107,18 @@ modified: 2025-02-23
107
107
 
108
108
  ## Notes
109
109
 
110
- - It still works when using CI/CD build systems (e.g. Github Actions)
111
- - Used a cache file `.dates_cache.json` to solve this problem
112
- - You can configure it like this (line 3) in your .github/workflows/ci.yml:
113
-
110
+ - It still works when using CI/CD build systems (e.g. Github Actions), used a cache file `.dates_cache.json` to solve this problem:
111
+ 1. First, you can configure the workflow like this (penultimate line) in your .github/workflows/ci.yml:
114
112
  ```
115
113
  ...
116
114
 
117
- - run: pip install mkdocs-document-dates
118
- - run: mkdocs gh-deploy --force
115
+ - run: pip install mkdocs-document-dates
116
+ - run: mkdocs gh-deploy --force
119
117
  ```
120
- - Then update your Markdown files in MkDocs as normal, execute commands such as mkdocs build or directly git add, commit, and push
121
- - Make sure you have installed python3 ahead of time and set environment variables
118
+ 2. Then update your Markdown document in MkDocs as normal
119
+ 3. After running git add and git commit, you will see the auto-generated cache file .dates_cache.json (hidden by default) in the `docs` folder under MkDocs
120
+ - Make sure you have installed python3 ahead of time and set environment variables
121
+ 4. Finally, run git push, and you can see that there are also .dates_cache.json files in the docs directory in the GitHub repository, which means success
122
122
  - Priority of time reads:
123
- - `Front Matter` > `Cache file` > `Filesystem timestamp`
123
+ - `Front Matter` > `Cache file` > `Filesystem timestamp`
124
124
  - If you are using MkDocs on a Linux system, the modification time is used as the creation time because of system limitations. If you need the exact creation time, you can specify it manually in Front Matter
@@ -85,18 +85,18 @@ modified: 2025-02-23
85
85
 
86
86
  ## Notes
87
87
 
88
- - It still works when using CI/CD build systems (e.g. Github Actions)
89
- - Used a cache file `.dates_cache.json` to solve this problem
90
- - You can configure it like this (line 3) in your .github/workflows/ci.yml:
91
-
88
+ - It still works when using CI/CD build systems (e.g. Github Actions), used a cache file `.dates_cache.json` to solve this problem:
89
+ 1. First, you can configure the workflow like this (penultimate line) in your .github/workflows/ci.yml:
92
90
  ```
93
91
  ...
94
92
 
95
- - run: pip install mkdocs-document-dates
96
- - run: mkdocs gh-deploy --force
93
+ - run: pip install mkdocs-document-dates
94
+ - run: mkdocs gh-deploy --force
97
95
  ```
98
- - Then update your Markdown files in MkDocs as normal, execute commands such as mkdocs build or directly git add, commit, and push
99
- - Make sure you have installed python3 ahead of time and set environment variables
96
+ 2. Then update your Markdown document in MkDocs as normal
97
+ 3. After running git add and git commit, you will see the auto-generated cache file .dates_cache.json (hidden by default) in the `docs` folder under MkDocs
98
+ - Make sure you have installed python3 ahead of time and set environment variables
99
+ 4. Finally, run git push, and you can see that there are also .dates_cache.json files in the docs directory in the GitHub repository, which means success
100
100
  - Priority of time reads:
101
- - `Front Matter` > `Cache file` > `Filesystem timestamp`
101
+ - `Front Matter` > `Cache file` > `Filesystem timestamp`
102
102
  - If you are using MkDocs on a Linux system, the modification time is used as the creation time because of system limitations. If you need the exact creation time, you can specify it manually in Front Matter
@@ -0,0 +1,13 @@
1
+ """MkDocs Document Dates Plugin."""
2
+
3
+ __version__ = '2.3.1'
4
+
5
+ from .hooks_installer import install
6
+
7
+ # 在包被导入时自动执行 hooks 安装
8
+ try:
9
+ result = install()
10
+ if not result:
11
+ print("Tip: Git hooks installation was skipped (probably because Git was not detected or not in the Git repository)")
12
+ except Exception as e:
13
+ print(f"Warning: Git hooks installation failed: {e}")
@@ -9,25 +9,23 @@ from datetime import datetime
9
9
  from pathlib import Path
10
10
 
11
11
  def find_mkdocs_projects():
12
- """查找当前 git 仓库中的所有 MkDocs 项目"""
13
12
  try:
14
13
  git_root = Path(subprocess.check_output(
15
14
  ['git', 'rev-parse', '--show-toplevel'],
16
15
  text=True, encoding='utf-8'
17
16
  ).strip())
18
-
17
+
19
18
  projects = []
20
19
  for config_file in git_root.rglob('mkdocs.y*ml'):
21
20
  if config_file.name.lower() in ('mkdocs.yml', 'mkdocs.yaml'):
22
21
  projects.append(config_file.parent)
23
-
22
+
24
23
  return projects
25
24
  except subprocess.CalledProcessError as e:
26
- print(f"查找 Git 仓库根目录失败: {e}", file=sys.stderr)
25
+ print(f"Failed to find the Git repository root: {e}", file=sys.stderr)
27
26
  return []
28
27
 
29
28
  def get_file_dates(file_path):
30
- """获取文件的创建和修改时间"""
31
29
  try:
32
30
  stat = os.stat(file_path)
33
31
  modified = datetime.fromtimestamp(stat.st_mtime)
@@ -49,11 +47,10 @@ def get_file_dates(file_path):
49
47
  return current_time.isoformat(), current_time.isoformat()
50
48
 
51
49
  def update_dates_cache():
52
- """更新文档时间缓存"""
53
50
  for project_dir in find_mkdocs_projects():
54
51
  docs_dir = project_dir / 'docs'
55
52
  if not docs_dir.exists():
56
- print(f"文档目录不存在: {docs_dir}")
53
+ print(f"Document directory does not exist: {docs_dir}")
57
54
  continue
58
55
 
59
56
  dates_cache = {}
@@ -68,7 +65,7 @@ def update_dates_cache():
68
65
  "modified": modified
69
66
  }
70
67
  except Exception as e:
71
- print(f"处理文件 {md_file} 时出错: {e}")
68
+ print(f"Error processing file {md_file}: {e}")
72
69
 
73
70
  if not dates_cache:
74
71
  continue
@@ -78,14 +75,14 @@ def update_dates_cache():
78
75
  with open(cache_file, "w") as f:
79
76
  json.dump(dates_cache, f, indent=2, ensure_ascii=False)
80
77
  subprocess.run(["git", "add", str(cache_file)], check=True)
81
- # print(f"缓存文件 {cache_file} 已更新.")
78
+ # print(f"The cache file {cache_file} has been updated")
82
79
  except Exception as e:
83
- print(f"写入缓存文件时出错: {e}", file=sys.stderr)
80
+ print(f"Error writing to cache file: {e}", file=sys.stderr)
84
81
  raise
85
82
 
86
83
  if __name__ == "__main__":
87
84
  try:
88
85
  update_dates_cache()
89
86
  except Exception as e:
90
- print(f"Hook 执行出错: {e}", file=sys.stderr)
87
+ print(f"Hook execution error: {e}", file=sys.stderr)
91
88
  sys.exit(1)
@@ -6,20 +6,18 @@ from pathlib import Path
6
6
  import platform
7
7
 
8
8
  def get_config_dir():
9
- """获取用户配置目录"""
10
9
  if platform.system().lower().startswith('win'):
11
10
  return Path(os.getenv('APPDATA', str(Path.home() / 'AppData' / 'Roaming')))
12
11
  else:
13
12
  return Path.home() / '.config'
14
13
 
15
14
  def install():
16
- """安装 git hooks"""
17
15
  try:
18
16
  # 检查 git 是否可用
19
17
  try:
20
18
  subprocess.run(['git', '--version'], check=True, capture_output=True, encoding='utf-8')
21
19
  except (subprocess.CalledProcessError, FileNotFoundError):
22
- print("提示: 未检测到 Git, 跳过 hooks 安装")
20
+ print("Tip: Git not detected, skip hooks installation")
23
21
  return False
24
22
 
25
23
  # 准备配置目录
@@ -27,10 +25,10 @@ def install():
27
25
  try:
28
26
  config_dir.mkdir(parents=True, exist_ok=True)
29
27
  except PermissionError:
30
- print(f"错误: 无权限创建目录: {config_dir}")
28
+ print(f"Error: No permission to create directory: {config_dir}")
31
29
  return False
32
30
  except Exception as e:
33
- print(f"错误: 创建目录失败: {config_dir}, 原因: {e}")
31
+ print(f"Error: Failed to create directory: {config_dir}, reason: {e}")
34
32
  return False
35
33
 
36
34
  hook_path = config_dir / 'pre-commit'
@@ -38,16 +36,16 @@ def install():
38
36
  # 复制 hook 文件到配置目录
39
37
  source_hook = Path(__file__).parent / 'hooks' / 'pre-commit'
40
38
  if not source_hook.exists():
41
- print(f"错误: hook 文件不存在: {source_hook}")
39
+ print(f"Error: Source hook file does not exist: {source_hook}")
42
40
  return False
43
41
 
44
42
  try:
45
43
  shutil.copy2(source_hook, hook_path)
46
44
  except PermissionError:
47
- print(f"错误: 无权限复制文件到: {hook_path}")
45
+ print(f"Error: No permission to copy file to: {hook_path}")
48
46
  return False
49
47
  except Exception as e:
50
- print(f"错误: 复制文件失败, 原因: {e}")
48
+ print(f"Error: Failed to copy file, reason: {e}")
51
49
  return False
52
50
 
53
51
  # 设置文件权限
@@ -55,20 +53,20 @@ def install():
55
53
  os.chmod(config_dir, 0o755)
56
54
  os.chmod(hook_path, 0o755)
57
55
  except OSError as e:
58
- print(f"警告: 设置权限时出错: {e}")
56
+ print(f"Warning: Error setting permissions: {e}")
59
57
 
60
58
  # 配置全局 git hooks 路径
61
59
  try:
62
60
  subprocess.run(['git', 'config', '--global', 'core.hooksPath',
63
61
  str(config_dir)], check=True, encoding='utf-8')
64
- print(f"Git hooks 已安装到: {config_dir}")
62
+ # print(f"Git hooks are installed in the: {config_dir}")
65
63
  return True
66
64
  except subprocess.CalledProcessError as e:
67
- print(f"错误: 设置 git hooks 路径失败: {e}")
65
+ print(f"Error: Setting git hooks path failed: {e}")
68
66
  return False
69
67
 
70
68
  except Exception as e:
71
- print(f"安装 hooks 时出错: {e}")
69
+ print(f"Error installing hooks: {e}")
72
70
  return False
73
71
 
74
72
  if __name__ == '__main__':
@@ -2,7 +2,6 @@ from pathlib import Path
2
2
  import importlib.util
3
3
 
4
4
  def load_translations():
5
- """加载所有可用的翻译"""
6
5
  translations = {}
7
6
  translations_dir = Path(__file__).parent
8
7
 
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  translations = {
2
3
  'just_now': 'الآن',
3
4
  'seconds_ago': 'منذ {} ثانية',
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  translations = {
2
3
  'just_now': 'gerade jetzt',
3
4
  'seconds_ago': 'vor {} Sekunden',
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  translations = {
2
3
  'just_now': 'just now',
3
4
  'seconds_ago': '{} seconds ago',
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  translations = {
2
3
  'just_now': 'justo ahora',
3
4
  'seconds_ago': 'hace {} segundos',
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  translations = {
2
3
  'just_now': 'à l\'instant',
3
4
  'seconds_ago': 'il y a {} secondes',
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  translations = {
2
3
  'just_now': 'たった今',
3
4
  'seconds_ago': '{} 秒前',
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  translations = {
2
3
  'just_now': '방금',
3
4
  'seconds_ago': '{} 초 전',
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  translations = {
2
3
  'just_now': 'только что',
3
4
  'seconds_ago': '{} секунд назад',
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  translations = {
2
3
  'just_now': '刚刚',
3
4
  'seconds_ago': '{} 秒前',
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  translations = {
2
3
  'just_now': '剛剛',
3
4
  'seconds_ago': '{} 秒前',
@@ -23,11 +23,9 @@ class DocumentDatesPlugin(BasePlugin):
23
23
  self.translations = load_translations()
24
24
 
25
25
  def _get_css_content(self):
26
- """返回插件的 CSS 样式"""
27
26
  return DOCUMENT_DATES_CSS
28
27
 
29
28
  def on_config(self, config):
30
- """配置插件并添加必要的 CSS"""
31
29
  if 'extra_css' not in config:
32
30
  config['extra_css'] = []
33
31
 
@@ -45,8 +43,6 @@ class DocumentDatesPlugin(BasePlugin):
45
43
  return config
46
44
 
47
45
  def _get_date_info(self, created, modified):
48
- """格式化日期信息的 HTML"""
49
- # 获取翻译字典
50
46
  locale = self.config['locale']
51
47
  if locale not in self.translations:
52
48
  locale = 'en'
@@ -55,16 +51,15 @@ class DocumentDatesPlugin(BasePlugin):
55
51
  return (
56
52
  f"<div class='document-dates-plugin-wrapper'>"
57
53
  f"<div class='document-dates-plugin'>"
58
- f"<span title='{t['created_time']}'><span class='material-icons'>add_circle</span>"
54
+ f"<span title='{t['created_time']}: {created.strftime(self.config['date_format'])}'><span class='material-icons'>add_circle</span>"
59
55
  f"{self._get_formatted_date(created)}</span>"
60
- f"<span title='{t['modified_time']}'><span class='material-icons'>update</span>"
56
+ f"<span title='{t['modified_time']}: {modified.strftime(self.config['date_format'])}'><span class='material-icons'>update</span>"
61
57
  f"{self._get_formatted_date(modified)}</span>"
62
58
  f"</div>"
63
59
  f"</div>"
64
60
  )
65
61
 
66
62
  def _insert_date_info(self, markdown, date_info):
67
- """根据配置将日期信息插入到合适的位置"""
68
63
  if not markdown.strip():
69
64
  return markdown
70
65
 
@@ -78,7 +73,6 @@ class DocumentDatesPlugin(BasePlugin):
78
73
  return f"{markdown}\n\n{date_info}"
79
74
 
80
75
  def on_page_markdown(self, markdown, page, config, files):
81
- """处理页面内容,添加日期信息"""
82
76
  file_path = Path(page.file.abs_src_path)
83
77
 
84
78
  if self._is_excluded(file_path, Path(config['docs_dir'])):
@@ -97,19 +91,12 @@ class DocumentDatesPlugin(BasePlugin):
97
91
  return self._insert_date_info(markdown, date_info)
98
92
 
99
93
  def _is_excluded(self, file_path: Path, docs_dir: Path) -> bool:
100
- """检查文件是否在排除列表中"""
101
94
  for pattern in self.config['exclude']:
102
95
  if self._matches_exclude_pattern(file_path, docs_dir, pattern):
103
96
  return True
104
97
  return False
105
98
 
106
99
  def _matches_exclude_pattern(self, file_path: Path, docs_dir: Path, pattern: str) -> bool:
107
- """检查文件是否匹配排除模式
108
- 支持三种匹配模式:
109
- 1. 具体文件路径:支持多级目录,如 'private/temp.md'
110
- 2. 目录下所有文件:使用 '*' 通配符,如 'private/*',匹配包含子目录的所有文件
111
- 3. 指定目录下特定类型文件:如 'private/*.md',仅匹配当前目录下的特定类型文件
112
- """
113
100
  try:
114
101
  # 获取相对于 docs_dir 的路径
115
102
  rel_path = file_path.relative_to(docs_dir)
@@ -136,13 +123,11 @@ class DocumentDatesPlugin(BasePlugin):
136
123
  return False
137
124
 
138
125
  def _process_meta_dates(self, meta: dict, created: datetime, modified: datetime) -> tuple[datetime, datetime]:
139
- """处理 frontmatter 中的日期"""
140
126
  result_created = self._parse_meta_date(meta.get('created'), created)
141
127
  result_modified = self._parse_meta_date(meta.get('modified'), modified)
142
128
  return result_created, result_modified
143
129
 
144
130
  def _parse_meta_date(self, date_str: str | None, default_date: datetime) -> datetime:
145
- """解析 meta 中的日期字符串"""
146
131
  if not date_str:
147
132
  return default_date
148
133
 
@@ -152,7 +137,6 @@ class DocumentDatesPlugin(BasePlugin):
152
137
  return default_date
153
138
 
154
139
  def _get_file_dates(self, file_path, config):
155
- """获取文件的创建时间和修改时间"""
156
140
  try:
157
141
  docs_dir = Path(config['docs_dir'])
158
142
  rel_path = str(Path(file_path).relative_to(docs_dir))
@@ -180,7 +164,7 @@ class DocumentDatesPlugin(BasePlugin):
180
164
  created = datetime.fromtimestamp(stat.st_birthtime)
181
165
  except AttributeError:
182
166
  created = datetime.fromtimestamp(stat.st_ctime)
183
- else: # Linux 和其他系统
167
+ else: # Linux
184
168
  created = modified
185
169
 
186
170
  return created, modified
@@ -190,7 +174,6 @@ class DocumentDatesPlugin(BasePlugin):
190
174
  return current_time, current_time
191
175
 
192
176
  def _get_timeago(self, date):
193
- """将日期格式化为 timeago 格式"""
194
177
  now = datetime.now()
195
178
  diff = now - date
196
179
  seconds = diff.total_seconds()
@@ -232,7 +215,6 @@ class DocumentDatesPlugin(BasePlugin):
232
215
  return t['years_ago'].format(int(seconds / 31536000))
233
216
 
234
217
  def _get_formatted_date(self, date):
235
- """格式化日期,支持 timeago、date 和 datetime 格式"""
236
218
  if self.config['type'] == 'timeago':
237
219
  return self._get_timeago(date)
238
220
  elif self.config['type'] == 'datetime':
@@ -1,4 +1,3 @@
1
- """CSS 样式定义"""
2
1
 
3
2
  DOCUMENT_DATES_CSS = """
4
3
  .document-dates-plugin {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mkdocs-document-dates
3
- Version: 2.3.0
3
+ Version: 2.3.2
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
@@ -107,18 +107,18 @@ modified: 2025-02-23
107
107
 
108
108
  ## Notes
109
109
 
110
- - It still works when using CI/CD build systems (e.g. Github Actions)
111
- - Used a cache file `.dates_cache.json` to solve this problem
112
- - You can configure it like this (line 3) in your .github/workflows/ci.yml:
113
-
110
+ - It still works when using CI/CD build systems (e.g. Github Actions), used a cache file `.dates_cache.json` to solve this problem:
111
+ 1. First, you can configure the workflow like this (penultimate line) in your .github/workflows/ci.yml:
114
112
  ```
115
113
  ...
116
114
 
117
- - run: pip install mkdocs-document-dates
118
- - run: mkdocs gh-deploy --force
115
+ - run: pip install mkdocs-document-dates
116
+ - run: mkdocs gh-deploy --force
119
117
  ```
120
- - Then update your Markdown files in MkDocs as normal, execute commands such as mkdocs build or directly git add, commit, and push
121
- - Make sure you have installed python3 ahead of time and set environment variables
118
+ 2. Then update your Markdown document in MkDocs as normal
119
+ 3. After running git add and git commit, you will see the auto-generated cache file .dates_cache.json (hidden by default) in the `docs` folder under MkDocs
120
+ - Make sure you have installed python3 ahead of time and set environment variables
121
+ 4. Finally, run git push, and you can see that there are also .dates_cache.json files in the docs directory in the GitHub repository, which means success
122
122
  - Priority of time reads:
123
- - `Front Matter` > `Cache file` > `Filesystem timestamp`
123
+ - `Front Matter` > `Cache file` > `Filesystem timestamp`
124
124
  - If you are using MkDocs on a Linux system, the modification time is used as the creation time because of system limitations. If you need the exact creation time, you can specify it manually in Front Matter
@@ -7,7 +7,7 @@ try:
7
7
  except FileNotFoundError:
8
8
  long_description = "A MkDocs plugin for displaying accurate document creation and last modification dates."
9
9
 
10
- VERSION = '2.3.0'
10
+ VERSION = '2.3.2'
11
11
 
12
12
  setup(
13
13
  name="mkdocs-document-dates",
@@ -1,13 +0,0 @@
1
- """MkDocs Document Dates Plugin."""
2
-
3
- __version__ = '2.3.0'
4
-
5
- from .hooks_installer import install
6
-
7
- # 在包被导入时自动执行 hooks 安装
8
- try:
9
- result = install()
10
- if not result:
11
- print("提示: Git hooks 安装被跳过(可能是因为未检测到 Git 或不在 Git 仓库中)")
12
- except Exception as e:
13
- print(f"警告: Git hooks 安装失败: {e}")