mkdocs-document-dates 2.2.0__tar.gz → 2.3.0__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 (27) hide show
  1. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/PKG-INFO +20 -17
  2. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/README.md +18 -15
  3. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates/__init__.py +1 -1
  4. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates/hooks/pre-commit +1 -3
  5. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates/hooks_installer.py +12 -14
  6. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates/plugin.py +6 -7
  7. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates.egg-info/PKG-INFO +20 -17
  8. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/setup.py +3 -3
  9. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/LICENSE +0 -0
  10. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates/lang/__init__.py +0 -0
  11. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates/lang/ar.py +0 -0
  12. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates/lang/de.py +0 -0
  13. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates/lang/en.py +0 -0
  14. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates/lang/es.py +0 -0
  15. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates/lang/fr.py +0 -0
  16. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates/lang/ja.py +0 -0
  17. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates/lang/ko.py +0 -0
  18. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates/lang/ru.py +0 -0
  19. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates/lang/zh.py +0 -0
  20. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates/lang/zh_tw.py +0 -0
  21. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates/styles.py +0 -0
  22. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates.egg-info/SOURCES.txt +0 -0
  23. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates.egg-info/dependency_links.txt +0 -0
  24. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates.egg-info/entry_points.txt +0 -0
  25. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates.egg-info/requires.txt +0 -0
  26. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/mkdocs_document_dates.egg-info/top_level.txt +0 -0
  27. {mkdocs_document_dates-2.2.0 → mkdocs_document_dates-2.3.0}/setup.cfg +0 -0
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mkdocs-document-dates
3
- Version: 2.2.0
3
+ Version: 2.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
7
7
  Classifier: Programming Language :: Python :: 3
8
8
  Classifier: License :: OSI Approved :: MIT License
9
9
  Classifier: Operating System :: OS Independent
10
- Requires-Python: >=3.6
10
+ Requires-Python: >=3.7
11
11
  Description-Content-Type: text/markdown
12
12
  License-File: LICENSE
13
13
  Requires-Dist: mkdocs>=1.0.0
@@ -26,12 +26,12 @@ English | [简体中文](README_zh.md)
26
26
 
27
27
 
28
28
 
29
- A MkDocs plugin for displaying **accurate** document creation and last modification dates.
29
+ A MkDocs plugin for displaying <mark>accurate</mark> document creation and last modification dates.
30
30
 
31
31
  ## Features
32
32
 
33
33
  - Automatically displays document creation and last modification times
34
- - No Git dependency, uses filesystem timestamps directly
34
+ - **No Git dependency**, uses filesystem timestamps directly
35
35
  - Supports manual date specification in `Front Matter`
36
36
  - Cross-platform support (Windows, macOS, Linux)
37
37
  - Support for multiple time formats (date, datetime, timeago)
@@ -40,6 +40,7 @@ A MkDocs plugin for displaying **accurate** document creation and last modificat
40
40
  - Material Design icons, Elegant styling
41
41
  - Lightweight with no extra dependencies
42
42
  - Multi-language support
43
+ - Support for CI/CD build systems (e.g. Github Actions)
43
44
 
44
45
  ## Installation
45
46
 
@@ -79,7 +80,7 @@ You can also manually specify the date of a Markdown document in its `Front Matt
79
80
  ```yaml
80
81
  ---
81
82
  created: 2023-01-01
82
- modified: 2023-12-31
83
+ modified: 2025-02-23
83
84
  ---
84
85
 
85
86
  # Document Title
@@ -89,33 +90,35 @@ modified: 2023-12-31
89
90
 
90
91
  ## Configuration Options
91
92
 
92
- - `type` : Date type (default: `date` )
93
+ - **type** : Date type (default: `date` )
93
94
  - `date` : Display date only
94
95
  - `datetime` : Display date and time
95
96
  - `timeago` : Display relative time (e.g., 2 minutes ago)
96
- - `locale` : Localization (default: `en` )
97
+ - **locale** : Localization (default: `en` )
97
98
  - Supports: `zh zh_tw en es fr de ar ja ko ru`
98
- - `date_format` : Date format (default: `%Y-%m-%d`)
99
+ - **date_format** : Date format (default: `%Y-%m-%d`)
99
100
  - Supports all Python datetime format strings, e.g., %Y-%m-%d, %b %d, %Y, etc.
100
- - `time_format` : Time format (default: `%H:%M:%S`)
101
- - `position` : Display position (default: `bottom`)
101
+ - **time_format** : Time format (default: `%H:%M:%S`)
102
+ - **position** : Display position (default: `bottom`)
102
103
  - `top` : Display after the first heading
103
104
  - `bottom` : Display at the end of the document
104
- - `exclude` : File exclusion list (default: [] )
105
+ - **exclude** : File exclusion list (default: [] )
105
106
  - Supports glob patterns, e.g., ["private/\*", "temp.md", "drafts/\*.md"]
106
107
 
107
108
  ## Notes
108
109
 
109
- - Creation time behavior varies across operating systems:
110
- - Windows: Uses file creation time
111
- - macOS: Uses file creation time (birthtime)
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
110
  - It still works when using CI/CD build systems (e.g. Github Actions)
114
111
  - Used a cache file `.dates_cache.json` to solve this problem
115
- - You can configure it like this:
112
+ - You can configure it like this (line 3) in your .github/workflows/ci.yml:
113
+
116
114
  ```
117
115
  ...
118
116
 
119
117
  - run: pip install mkdocs-document-dates
120
118
  - run: mkdocs gh-deploy --force
121
- ```
119
+ ```
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
122
+ - Priority of time reads:
123
+ - `Front Matter` > `Cache file` > `Filesystem timestamp`
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
@@ -4,12 +4,12 @@ English | [简体中文](README_zh.md)
4
4
 
5
5
 
6
6
 
7
- A MkDocs plugin for displaying **accurate** document creation and last modification dates.
7
+ A MkDocs plugin for displaying <mark>accurate</mark> document creation and last modification dates.
8
8
 
9
9
  ## Features
10
10
 
11
11
  - Automatically displays document creation and last modification times
12
- - No Git dependency, uses filesystem timestamps directly
12
+ - **No Git dependency**, uses filesystem timestamps directly
13
13
  - Supports manual date specification in `Front Matter`
14
14
  - Cross-platform support (Windows, macOS, Linux)
15
15
  - Support for multiple time formats (date, datetime, timeago)
@@ -18,6 +18,7 @@ A MkDocs plugin for displaying **accurate** document creation and last modificat
18
18
  - Material Design icons, Elegant styling
19
19
  - Lightweight with no extra dependencies
20
20
  - Multi-language support
21
+ - Support for CI/CD build systems (e.g. Github Actions)
21
22
 
22
23
  ## Installation
23
24
 
@@ -57,7 +58,7 @@ You can also manually specify the date of a Markdown document in its `Front Matt
57
58
  ```yaml
58
59
  ---
59
60
  created: 2023-01-01
60
- modified: 2023-12-31
61
+ modified: 2025-02-23
61
62
  ---
62
63
 
63
64
  # Document Title
@@ -67,33 +68,35 @@ modified: 2023-12-31
67
68
 
68
69
  ## Configuration Options
69
70
 
70
- - `type` : Date type (default: `date` )
71
+ - **type** : Date type (default: `date` )
71
72
  - `date` : Display date only
72
73
  - `datetime` : Display date and time
73
74
  - `timeago` : Display relative time (e.g., 2 minutes ago)
74
- - `locale` : Localization (default: `en` )
75
+ - **locale** : Localization (default: `en` )
75
76
  - Supports: `zh zh_tw en es fr de ar ja ko ru`
76
- - `date_format` : Date format (default: `%Y-%m-%d`)
77
+ - **date_format** : Date format (default: `%Y-%m-%d`)
77
78
  - Supports all Python datetime format strings, e.g., %Y-%m-%d, %b %d, %Y, etc.
78
- - `time_format` : Time format (default: `%H:%M:%S`)
79
- - `position` : Display position (default: `bottom`)
79
+ - **time_format** : Time format (default: `%H:%M:%S`)
80
+ - **position** : Display position (default: `bottom`)
80
81
  - `top` : Display after the first heading
81
82
  - `bottom` : Display at the end of the document
82
- - `exclude` : File exclusion list (default: [] )
83
+ - **exclude** : File exclusion list (default: [] )
83
84
  - Supports glob patterns, e.g., ["private/\*", "temp.md", "drafts/\*.md"]
84
85
 
85
86
  ## Notes
86
87
 
87
- - Creation time behavior varies across operating systems:
88
- - Windows: Uses file creation time
89
- - macOS: Uses file creation time (birthtime)
90
- - 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
91
88
  - It still works when using CI/CD build systems (e.g. Github Actions)
92
89
  - Used a cache file `.dates_cache.json` to solve this problem
93
- - You can configure it like this:
90
+ - You can configure it like this (line 3) in your .github/workflows/ci.yml:
91
+
94
92
  ```
95
93
  ...
96
94
 
97
95
  - run: pip install mkdocs-document-dates
98
96
  - run: mkdocs gh-deploy --force
99
- ```
97
+ ```
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
100
+ - Priority of time reads:
101
+ - `Front Matter` > `Cache file` > `Filesystem timestamp`
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
@@ -1,6 +1,6 @@
1
1
  """MkDocs Document Dates Plugin."""
2
2
 
3
- __version__ = '2.0.0'
3
+ __version__ = '2.3.0'
4
4
 
5
5
  from .hooks_installer import install
6
6
 
@@ -50,7 +50,6 @@ def get_file_dates(file_path):
50
50
 
51
51
  def update_dates_cache():
52
52
  """更新文档时间缓存"""
53
- print("开始更新文档时间缓存...")
54
53
  for project_dir in find_mkdocs_projects():
55
54
  docs_dir = project_dir / 'docs'
56
55
  if not docs_dir.exists():
@@ -75,12 +74,11 @@ def update_dates_cache():
75
74
  continue
76
75
 
77
76
  cache_file = docs_dir / '.dates_cache.json'
78
- print(f"正在写入缓存文件: {cache_file}")
79
77
  try:
80
78
  with open(cache_file, "w") as f:
81
79
  json.dump(dates_cache, f, indent=2, ensure_ascii=False)
82
80
  subprocess.run(["git", "add", str(cache_file)], check=True)
83
- print(f"缓存文件 {cache_file} 已更新.")
81
+ # print(f"缓存文件 {cache_file} 已更新.")
84
82
  except Exception as e:
85
83
  print(f"写入缓存文件时出错: {e}", file=sys.stderr)
86
84
  raise
@@ -7,10 +7,9 @@ import platform
7
7
 
8
8
  def get_config_dir():
9
9
  """获取用户配置目录"""
10
- system = platform.system().lower()
11
- if system.startswith('win'):
10
+ if platform.system().lower().startswith('win'):
12
11
  return Path(os.getenv('APPDATA', str(Path.home() / 'AppData' / 'Roaming')))
13
- else: # macOS 和 Linux 统一使用 ~/.config
12
+ else:
14
13
  return Path.home() / '.config'
15
14
 
16
15
  def install():
@@ -20,7 +19,7 @@ def install():
20
19
  try:
21
20
  subprocess.run(['git', '--version'], check=True, capture_output=True, encoding='utf-8')
22
21
  except (subprocess.CalledProcessError, FileNotFoundError):
23
- print("提示: 未检测到 Git,跳过 hooks 安装")
22
+ print("提示: 未检测到 Git, 跳过 hooks 安装")
24
23
  return False
25
24
 
26
25
  # 准备配置目录
@@ -36,12 +35,12 @@ def install():
36
35
 
37
36
  hook_path = config_dir / 'pre-commit'
38
37
 
39
- # 复制 hook 文件
38
+ # 复制 hook 文件到配置目录
40
39
  source_hook = Path(__file__).parent / 'hooks' / 'pre-commit'
41
40
  if not source_hook.exists():
42
41
  print(f"错误: 源 hook 文件不存在: {source_hook}")
43
42
  return False
44
-
43
+
45
44
  try:
46
45
  shutil.copy2(source_hook, hook_path)
47
46
  except PermissionError:
@@ -51,15 +50,14 @@ def install():
51
50
  print(f"错误: 复制文件失败, 原因: {e}")
52
51
  return False
53
52
 
54
- # 设置文件权限(Unix-like 系统)
55
- if not platform.system().lower().startswith('win'):
56
- try:
57
- os.chmod(config_dir, 0o755)
58
- os.chmod(hook_path, 0o755)
59
- except OSError as e:
60
- print(f"警告: 设置权限时出错: {e}")
53
+ # 设置文件权限
54
+ try:
55
+ os.chmod(config_dir, 0o755)
56
+ os.chmod(hook_path, 0o755)
57
+ except OSError as e:
58
+ print(f"警告: 设置权限时出错: {e}")
61
59
 
62
- # 配置 git hooks 路径
60
+ # 配置全局 git hooks 路径
63
61
  try:
64
62
  subprocess.run(['git', 'config', '--global', 'core.hooksPath',
65
63
  str(config_dir)], check=True, encoding='utf-8')
@@ -85,7 +85,7 @@ class DocumentDatesPlugin(BasePlugin):
85
85
  return markdown
86
86
 
87
87
  # 获取文件时间
88
- created, modified = self._get_file_dates(file_path, config) # 传入 config
88
+ created, modified = self._get_file_dates(file_path, config)
89
89
 
90
90
  # 处理 front matter 中的时间
91
91
  created, modified = self._process_meta_dates(page.meta, created, modified)
@@ -151,10 +151,9 @@ class DocumentDatesPlugin(BasePlugin):
151
151
  except (ValueError, TypeError):
152
152
  return default_date
153
153
 
154
- def _get_file_dates(self, file_path, config): # 添加 config 参数
154
+ def _get_file_dates(self, file_path, config):
155
155
  """获取文件的创建时间和修改时间"""
156
156
  try:
157
- # 从传入的 config 中获取 docs_dir
158
157
  docs_dir = Path(config['docs_dir'])
159
158
  rel_path = str(Path(file_path).relative_to(docs_dir))
160
159
 
@@ -172,15 +171,15 @@ class DocumentDatesPlugin(BasePlugin):
172
171
  # 如果缓存不存在或文件不在缓存中,使用文件系统时间
173
172
  stat = os.stat(file_path)
174
173
  modified = datetime.fromtimestamp(stat.st_mtime)
175
-
174
+
176
175
  system = platform.system().lower()
177
- if system == 'darwin': # macOS
176
+ if system.startswith('win'): # Windows
177
+ created = datetime.fromtimestamp(stat.st_ctime)
178
+ elif system == 'darwin': # macOS
178
179
  try:
179
180
  created = datetime.fromtimestamp(stat.st_birthtime)
180
181
  except AttributeError:
181
182
  created = datetime.fromtimestamp(stat.st_ctime)
182
- elif system == 'windows': # Windows
183
- created = datetime.fromtimestamp(stat.st_ctime)
184
183
  else: # Linux 和其他系统
185
184
  created = modified
186
185
 
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mkdocs-document-dates
3
- Version: 2.2.0
3
+ Version: 2.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
7
7
  Classifier: Programming Language :: Python :: 3
8
8
  Classifier: License :: OSI Approved :: MIT License
9
9
  Classifier: Operating System :: OS Independent
10
- Requires-Python: >=3.6
10
+ Requires-Python: >=3.7
11
11
  Description-Content-Type: text/markdown
12
12
  License-File: LICENSE
13
13
  Requires-Dist: mkdocs>=1.0.0
@@ -26,12 +26,12 @@ English | [简体中文](README_zh.md)
26
26
 
27
27
 
28
28
 
29
- A MkDocs plugin for displaying **accurate** document creation and last modification dates.
29
+ A MkDocs plugin for displaying <mark>accurate</mark> document creation and last modification dates.
30
30
 
31
31
  ## Features
32
32
 
33
33
  - Automatically displays document creation and last modification times
34
- - No Git dependency, uses filesystem timestamps directly
34
+ - **No Git dependency**, uses filesystem timestamps directly
35
35
  - Supports manual date specification in `Front Matter`
36
36
  - Cross-platform support (Windows, macOS, Linux)
37
37
  - Support for multiple time formats (date, datetime, timeago)
@@ -40,6 +40,7 @@ A MkDocs plugin for displaying **accurate** document creation and last modificat
40
40
  - Material Design icons, Elegant styling
41
41
  - Lightweight with no extra dependencies
42
42
  - Multi-language support
43
+ - Support for CI/CD build systems (e.g. Github Actions)
43
44
 
44
45
  ## Installation
45
46
 
@@ -79,7 +80,7 @@ You can also manually specify the date of a Markdown document in its `Front Matt
79
80
  ```yaml
80
81
  ---
81
82
  created: 2023-01-01
82
- modified: 2023-12-31
83
+ modified: 2025-02-23
83
84
  ---
84
85
 
85
86
  # Document Title
@@ -89,33 +90,35 @@ modified: 2023-12-31
89
90
 
90
91
  ## Configuration Options
91
92
 
92
- - `type` : Date type (default: `date` )
93
+ - **type** : Date type (default: `date` )
93
94
  - `date` : Display date only
94
95
  - `datetime` : Display date and time
95
96
  - `timeago` : Display relative time (e.g., 2 minutes ago)
96
- - `locale` : Localization (default: `en` )
97
+ - **locale** : Localization (default: `en` )
97
98
  - Supports: `zh zh_tw en es fr de ar ja ko ru`
98
- - `date_format` : Date format (default: `%Y-%m-%d`)
99
+ - **date_format** : Date format (default: `%Y-%m-%d`)
99
100
  - Supports all Python datetime format strings, e.g., %Y-%m-%d, %b %d, %Y, etc.
100
- - `time_format` : Time format (default: `%H:%M:%S`)
101
- - `position` : Display position (default: `bottom`)
101
+ - **time_format** : Time format (default: `%H:%M:%S`)
102
+ - **position** : Display position (default: `bottom`)
102
103
  - `top` : Display after the first heading
103
104
  - `bottom` : Display at the end of the document
104
- - `exclude` : File exclusion list (default: [] )
105
+ - **exclude** : File exclusion list (default: [] )
105
106
  - Supports glob patterns, e.g., ["private/\*", "temp.md", "drafts/\*.md"]
106
107
 
107
108
  ## Notes
108
109
 
109
- - Creation time behavior varies across operating systems:
110
- - Windows: Uses file creation time
111
- - macOS: Uses file creation time (birthtime)
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
110
  - It still works when using CI/CD build systems (e.g. Github Actions)
114
111
  - Used a cache file `.dates_cache.json` to solve this problem
115
- - You can configure it like this:
112
+ - You can configure it like this (line 3) in your .github/workflows/ci.yml:
113
+
116
114
  ```
117
115
  ...
118
116
 
119
117
  - run: pip install mkdocs-document-dates
120
118
  - run: mkdocs gh-deploy --force
121
- ```
119
+ ```
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
122
+ - Priority of time reads:
123
+ - `Front Matter` > `Cache file` > `Filesystem timestamp`
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.2.0'
10
+ VERSION = '2.3.0'
11
11
 
12
12
  setup(
13
13
  name="mkdocs-document-dates",
@@ -31,12 +31,12 @@ setup(
31
31
  'document-dates = mkdocs_document_dates.plugin:DocumentDatesPlugin',
32
32
  ],
33
33
  'console_scripts': [
34
- # 提供命令行工具,允许用户手动执行 hooks 安装
34
+ # 提供手动执行 hooks 安装的入口
35
35
  'mkdocs-document-dates-hooks=mkdocs_document_dates.hooks_installer:install'
36
36
  ],
37
37
  },
38
38
  package_data={
39
39
  'mkdocs_document_dates': ['hooks/*'],
40
40
  },
41
- python_requires=">=3.6",
41
+ python_requires=">=3.7",
42
42
  )