mkdocs-document-dates 0.1.0__py3-none-any.whl → 0.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.
@@ -1,4 +1,5 @@
1
1
  import os
2
+ import platform
2
3
  from datetime import datetime
3
4
  from pathlib import Path
4
5
  from mkdocs.plugins import BasePlugin
@@ -103,9 +104,20 @@ class DocumentDatesPlugin(BasePlugin):
103
104
  # 检查 frontmatter 中的日期
104
105
  meta = getattr(page, 'meta', {})
105
106
  if 'created_date' in meta:
106
- created = datetime.fromisoformat(meta['created_date'])
107
+ try:
108
+ date_str = str(meta['created_date']).strip("'\"") # 移除可能存在的引号
109
+ created = datetime.fromisoformat(date_str)
110
+ except (ValueError, TypeError):
111
+ # 如果解析失败,保持原有的文件系统日期
112
+ pass
113
+
107
114
  if 'modified_date' in meta:
108
- modified = datetime.fromisoformat(meta['modified_date'])
115
+ try:
116
+ date_str = str(meta['modified_date']).strip("'\"") # 移除可能存在的引号
117
+ modified = datetime.fromisoformat(date_str)
118
+ except (ValueError, TypeError):
119
+ # 如果解析失败,保持原有的文件系统日期
120
+ pass
109
121
 
110
122
  # 格式化并插入日期信息
111
123
  date_info = self.format_date_info(created, modified)
@@ -113,7 +125,6 @@ class DocumentDatesPlugin(BasePlugin):
113
125
 
114
126
  def get_file_dates(self, file_path):
115
127
  """获取文件的创建时间和修改时间"""
116
- import platform
117
128
 
118
129
  stat = os.stat(file_path)
119
130
  modified = datetime.fromtimestamp(stat.st_mtime)
@@ -0,0 +1,110 @@
1
+ Metadata-Version: 2.2
2
+ Name: mkdocs-document-dates
3
+ Version: 0.3.0
4
+ Summary: A MkDocs plugin for displaying accurate document creation and last modification dates.
5
+ Home-page: https://github.com/jaywhj/mkdocs-document-dates
6
+ Author: Aaron Wang
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.6
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: mkdocs>=1.0.0
14
+ Dynamic: author
15
+ Dynamic: classifier
16
+ Dynamic: description
17
+ Dynamic: description-content-type
18
+ Dynamic: home-page
19
+ Dynamic: requires-dist
20
+ Dynamic: requires-python
21
+ Dynamic: summary
22
+
23
+ # mkdocs-document-dates
24
+
25
+ English | [简体中文](README_zh.md)
26
+
27
+
28
+
29
+ A MkDocs plugin for displaying **accurate** document creation and last modification dates.
30
+
31
+ ## Features
32
+
33
+ - Automatically displays document creation and last modification times
34
+ - Supports manual date specification in `Front Matter`
35
+ - No Git dependency, uses filesystem timestamps directly
36
+ - Cross-platform support (Windows, macOS, Linux)
37
+ - Configurable date and time formats
38
+ - Flexible display position (top or bottom)
39
+ - File exclusion rules support
40
+ - Material Design icons
41
+ - Elegant styling
42
+ - Lightweight with no extra dependencies
43
+
44
+ ## Installation
45
+
46
+ ```bash
47
+ pip install mkdocs-document-dates
48
+ ```
49
+
50
+ ## Configuration
51
+
52
+ Add the plugin to your mkdocs.yml:
53
+
54
+ ```yaml
55
+ plugins:
56
+ - document-dates
57
+ ```
58
+
59
+ Or, customize the configuration:
60
+
61
+ ```yaml
62
+ plugins:
63
+ - document-dates:
64
+ date_format: '%Y-%m-%d' # Date format
65
+ show_time: false # Whether to show time
66
+ time_format: '%H:%M:%S' # Time format
67
+ position: bottom # Display position: top (after title) or bottom (end of document)
68
+ exclude: # List of file patterns to exclude
69
+ - "private/*" # Exclude all files in private directory
70
+ - "drafts/*.md" # Exclude all markdown files in drafts directory
71
+ - "temp.md" # Exclude specific file
72
+ - "*.tmp" # Exclude all files with .tmp extension
73
+ ```
74
+
75
+ ## Manual Date Specification
76
+
77
+ You can also manually specify the date of a Markdown document in its `Front Matter` :
78
+
79
+ ```yaml
80
+ ---
81
+ created_date: 2023-01-01
82
+ modified_date: 2023-12-31
83
+ ---
84
+
85
+ # Document Title
86
+ ```
87
+
88
+ ## Configuration Options
89
+
90
+ - `date_format`: Date format (default: %Y-%m-%d)
91
+ - Supports all Python datetime format strings, examples: %Y-%m-%d, %b %d, %Y, etc.
92
+ - `show_time`: Whether to show time (default: false)
93
+ - true: Show both date and time
94
+ - false: Show date only
95
+ - `time_format`: Time format (default: %H:%M:%S)
96
+ - Only effective when show_time is true
97
+ - `position`: Display position (default: bottom)
98
+ - top: Display after the first heading
99
+ - bottom: Display at the end of document
100
+ - `exclude`: List of files to exclude (default: [])
101
+ - Supports glob patterns, example: ["private/*", "temp.md"]
102
+
103
+ ## Notes
104
+
105
+ - Creation time behavior varies across operating systems:
106
+ - Windows: Uses file creation time
107
+ - macOS: Uses file creation time (birthtime)
108
+ - Linux: Uses modification time as creation time due to system limitations
109
+ - For accurate creation times, it's recommended to use Front Matter for manual specification
110
+
@@ -0,0 +1,8 @@
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,,
@@ -1,110 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: mkdocs-document-dates
3
- Version: 0.1.0
4
- Summary: 一个用于显示文档创建日期和最后修改日期的 MkDocs 插件
5
- Home-page: https://github.com/jaywhj/mkdocs-document-dates
6
- Author: Aaron Wang
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Operating System :: OS Independent
10
- Requires-Python: >=3.6
11
- Description-Content-Type: text/markdown
12
- License-File: LICENSE
13
- Requires-Dist: mkdocs>=1.0.0
14
- Dynamic: author
15
- Dynamic: classifier
16
- Dynamic: description
17
- Dynamic: description-content-type
18
- Dynamic: home-page
19
- Dynamic: requires-dist
20
- Dynamic: requires-python
21
- Dynamic: summary
22
-
23
- # mkdocs-document-dates
24
-
25
- [English](README_en.md) | 简体中文
26
-
27
-
28
-
29
- 一个用于显示准确的文档创建日期和最后修改日期的 MkDocs 插件。
30
-
31
- ## 特性
32
-
33
- - 自动显示文档的创建时间和最后修改时间
34
- - 支持在 `Front Matter` 中手动指定日期
35
- - 不依赖 Git,直接使用文件系统的时间戳
36
- - 跨平台支持(Windows、macOS、Linux)
37
- - 可配置的日期和时间格式
38
- - 灵活的显示位置(顶部或底部)
39
- - 支持文件排除规则
40
- - Material Design 风格的图标
41
- - 优雅的样式设计
42
- - 轻量级,无额外依赖
43
-
44
- ## 安装
45
-
46
- ```bash
47
- pip install mkdocs-document-dates
48
- ```
49
-
50
- ## 配置
51
-
52
- 在你的 mkdocs.yml 中添加插件即可:
53
-
54
- ```yaml
55
- plugins:
56
- - document-dates
57
- ```
58
-
59
- 或者,你要自定义配置:
60
-
61
- ```yaml
62
- plugins:
63
- - document-dates:
64
- date_format: '%Y-%m-%d' # 日期格式
65
- show_time: false # 是否显示时间
66
- time_format: '%H:%M:%S' # 时间格式
67
- position: bottom # 显示位置:top(标题后)或 bottom(文档末尾)
68
- exclude: # 排除的文件模式列表
69
- - "private/*" # 排除 private 目录下的所有文件
70
- - "drafts/*.md" # 排除 drafts 目录下的所有 markdown 文件
71
- - "temp.md" # 排除特定文件
72
- - "*.tmp" # 排除所有 .tmp 后缀的文件
73
- ```
74
-
75
- ## 手动指定日期
76
-
77
- 你也可以为 Markdown 文档手动指定日期,在 Markdown 文档的 `Front Matter` 中设置:
78
-
79
- ```yaml
80
- ---
81
- created_date: '2023-01-01'
82
- modified_date: '2023-12-31'
83
- ---
84
-
85
- # 文档标题
86
- ```
87
-
88
- ## 配置选项
89
-
90
- - date_format: 日期格式(默认:%Y-%m-%d)
91
- - 支持所有 Python datetime 格式化字符串,例如:%Y年%m月%d日、%b %d, %Y 等
92
- - show_time: 是否显示时间(默认:false)
93
- - true: 同时显示日期和时间
94
- - false: 仅显示日期
95
- - time_format: 时间格式(默认:%H:%M:%S)
96
- - 仅在 show_time 为 true 时生效
97
- - position: 显示位置(默认:bottom)
98
- - top: 在文档第一个标题后显示
99
- - bottom: 在文档末尾显示
100
- - exclude: 排除文件列表(默认:[])
101
- - 支持 glob 模式,例如:["private/*", "temp.md"]
102
-
103
- ## 注意事项
104
-
105
- - 创建时间在不同操作系统上的行为可能不同:
106
- - Windows: 使用文件创建时间
107
- - macOS: 使用文件创建时间(birthtime)
108
- - Linux: 由于系统限制,使用修改时间作为创建时间
109
- - 如果需要准确的创建时间,建议使用 Front Matter 手动指定
110
-
@@ -1,8 +0,0 @@
1
- mkdocs_document_dates/__init__.py,sha256=yom7psmObebsZY0AwCN1PjlGUwPkny2r6NyzoO0cudg,58
2
- mkdocs_document_dates/plugin.py,sha256=x5oFH2K54Wlr5DJUSKG6gl85tZ9HHrgjbnaksGuqkzc,4900
3
- mkdocs_document_dates-0.1.0.dist-info/LICENSE,sha256=1YKfCs5WKSk-bON8a68WZE5to1B2klCrHBYiuaVCThM,514
4
- mkdocs_document_dates-0.1.0.dist-info/METADATA,sha256=q-Eft96oExZ_ARZLhaNGy5uS_mR9Tsfk0yCTcosG1Jw,3193
5
- mkdocs_document_dates-0.1.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
6
- mkdocs_document_dates-0.1.0.dist-info/entry_points.txt,sha256=gI-OFLGjDG6-oLEfyevl3Gwwj2GcqVFQeX3bvL1IF8o,83
7
- mkdocs_document_dates-0.1.0.dist-info/top_level.txt,sha256=yWkKQdNuAJJVqUQ9uLa5xD4x_Gux4IfOUpy8Ryagdwc,22
8
- mkdocs_document_dates-0.1.0.dist-info/RECORD,,