mkdocs-document-dates 3.1.2__tar.gz → 3.1.5__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.
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/PKG-INFO +50 -34
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/README.md +46 -32
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/cache_manager.py +10 -11
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/hooks/pre-commit +2 -3
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/hooks_installer.py +1 -1
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/plugin.py +145 -156
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/config/user.config.css +2 -6
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/config/user.config.js +10 -5
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/core/core.js +26 -77
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates.egg-info/PKG-INFO +50 -34
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates.egg-info/SOURCES.txt +1 -1
- mkdocs_document_dates-3.1.5/mkdocs_document_dates.egg-info/requires.txt +1 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/setup.py +3 -2
- mkdocs_document_dates-3.1.2/mkdocs_document_dates.egg-info/requires.txt +0 -1
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/LICENSE +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/__init__.py +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/core/core.css +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/core/timeago-load.js +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/core/timeago.full.min.js +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/core/timeago.min.js +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/languages/ar.json +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/languages/de.json +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/languages/en.json +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/languages/es.json +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/languages/fr.json +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/languages/ja.json +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/languages/ko.json +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/languages/ru.json +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/languages/zh.json +0 -0
- /mkdocs_document_dates-3.1.2/mkdocs_document_dates/static/languages/zh_tw.json → /mkdocs_document_dates-3.1.5/mkdocs_document_dates/static/languages/zh_TW.json +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/tippy/backdrop.css +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/tippy/light.css +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/tippy/material.css +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/tippy/popper.min.js +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/tippy/scale.css +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/tippy/shift-away.css +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/tippy/tippy.css +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/static/tippy/tippy.umd.min.js +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates.egg-info/dependency_links.txt +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates.egg-info/entry_points.txt +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates.egg-info/top_level.txt +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/setup.cfg +0 -0
@@ -1,9 +1,10 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mkdocs-document-dates
|
3
|
-
Version: 3.1.
|
3
|
+
Version: 3.1.5
|
4
4
|
Summary: An easy-to-use, lightweight MkDocs plugin for displaying the exact creation time, last modification time and author info of markdown documents.
|
5
5
|
Home-page: https://github.com/jaywhj/mkdocs-document-dates
|
6
6
|
Author: Aaron Wang
|
7
|
+
Author-email: aaronwqt@gmail.com
|
7
8
|
License: MIT
|
8
9
|
Classifier: Programming Language :: Python :: 3
|
9
10
|
Classifier: License :: OSI Approved :: MIT License
|
@@ -11,8 +12,9 @@ Classifier: Operating System :: OS Independent
|
|
11
12
|
Requires-Python: >=3.7
|
12
13
|
Description-Content-Type: text/markdown
|
13
14
|
License-File: LICENSE
|
14
|
-
Requires-Dist: mkdocs>=1.
|
15
|
+
Requires-Dist: mkdocs>=1.1.0
|
15
16
|
Dynamic: author
|
17
|
+
Dynamic: author-email
|
16
18
|
Dynamic: classifier
|
17
19
|
Dynamic: description
|
18
20
|
Dynamic: description-content-type
|
@@ -33,8 +35,8 @@ An easy-to-use, lightweight MkDocs plugin for displaying the <mark>exact</mark>
|
|
33
35
|
|
34
36
|
## Features
|
35
37
|
|
36
|
-
-
|
37
|
-
- Support for manually specifying time and author
|
38
|
+
- Always display exact meta-info of the document for any environment (no-Git, Git, all CI/CD build systems, etc)
|
39
|
+
- Support for manually specifying time and author in `Front Matter`
|
38
40
|
- Support for multiple time formats (date, datetime, timeago)
|
39
41
|
- Support for document exclusion mode
|
40
42
|
- Flexible display position (top or bottom)
|
@@ -72,15 +74,14 @@ plugins:
|
|
72
74
|
- document-dates:
|
73
75
|
position: top # Display position: top (after title) bottom (end of document), default: bottom
|
74
76
|
type: date # Date type: date datetime timeago, default: date
|
75
|
-
locale: en # Localization: zh zh_TW
|
76
|
-
date_format: '%Y-%m-%d' # Date format
|
77
|
-
time_format: '%H:%M:%S' # Time format (valid only if type=datetime)
|
77
|
+
locale: en # Localization: en zh zh_TW es fr de ar ja ko ru, default: en
|
78
|
+
date_format: '%Y-%m-%d' # Date format strings, e.g., %Y-%m-%d, %b %d, %Y, etc
|
79
|
+
time_format: '%H:%M:%S' # Time format strings (valid only if type=datetime)
|
78
80
|
exclude: # List of excluded files
|
79
81
|
- temp.md # Exclude specific file
|
80
82
|
- private/* # Exclude all files in private directory, including subdirectories
|
81
|
-
- drafts/*.md # Exclude all markdown files in the current directory drafts, but not subdirectories
|
82
83
|
|
83
|
-
show_author: true #
|
84
|
+
show_author: true # Show author or not, default: true
|
84
85
|
|
85
86
|
```
|
86
87
|
|
@@ -88,7 +89,7 @@ plugins:
|
|
88
89
|
|
89
90
|
The plugin will automatically get the exact time of the document, will automatically cache the creation time, but of course, you can also specify it manually in `Front Matter`
|
90
91
|
|
91
|
-
Priority: `Front Matter` > `Cache Files` > `File System Timestamps`
|
92
|
+
Priority order: `Front Matter` > `Cache Files` > `File System Timestamps`
|
92
93
|
|
93
94
|
```yaml
|
94
95
|
---
|
@@ -106,7 +107,7 @@ modified: 2025-02-23
|
|
106
107
|
|
107
108
|
The plugin will automatically get the author of the document, will parse the email and make a link, also you can specify it manually in `Front Matter`
|
108
109
|
|
109
|
-
Priority: `Front Matter` > `Git Author
|
110
|
+
Priority order: `Front Matter` > `Git Author` > `site_author (mkdocs.yml)` > `PC Username`
|
110
111
|
|
111
112
|
```yaml
|
112
113
|
---
|
@@ -122,27 +123,42 @@ email: e-name@gmail.com
|
|
122
123
|
|
123
124
|
## Customization
|
124
125
|
|
125
|
-
The plugin supports deep customization, such as icon style, font style, theme color, animation type, dividing line
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
126
|
+
The plugin supports deep customization, such as **icon style, font style, theme color, animation type, dividing line**, etc. All of it can be customized by modifying the preset values in the corresponding file (I've already written the code and comments, you just need to turn on the switch and change the value):
|
127
|
+
|
128
|
+
| Function: | Location: |
|
129
|
+
| :----------------------: | ---------------------------------------- |
|
130
|
+
| **Style & Theme** | `docs/assets/document_dates/user.config.css` |
|
131
|
+
| **Properties & Functions** | `docs/assets/document_dates/user.config.js` |
|
132
|
+
| **Localized languages** | `docs/assets/document_dates/languages/` <br />refer to the template file `en.json` for any additions or modifications |
|
133
|
+
|
134
|
+
**Tip**: when `type: timeago` is set, timeago.js is enabled to render time dynamically, `timeago.min.js` only contains English and Chinese by default, if you need to load other languages, you can configure it as below (choose one):
|
135
|
+
|
136
|
+
- In `user.config.js`, refer to [the demo commented out](https://github.com/jaywhj/mkdocs-document-dates/blob/main/mkdocs_document_dates/static/config/user.config.js) at the bottom, translate it into your local language
|
137
|
+
- In `mkdocs.yml`, add the following two lines to configure the full version of `timeago.full.min.js` to load all languages at once
|
138
|
+
```yaml
|
139
|
+
extra_javascript:
|
140
|
+
- assets/document_dates/core/timeago.full.min.js
|
141
|
+
- assets/document_dates/core/timeago-load.js
|
142
|
+
```
|
143
|
+
|
144
|
+
**Demo Images**:
|
145
|
+
|
146
|
+

|
147
|
+

|
148
|
+

|
149
|
+

|
150
|
+

|
151
|
+
|
152
|
+

|
153
|
+

|
154
|
+

|
139
155
|
|
140
156
|
## Other Tips
|
141
157
|
|
142
|
-
- In order to get the exact creation time, a separate cache file is used to store the creation time of the
|
158
|
+
- In order to always get the exact creation time, a separate cache file is used to store the creation time of the document, located in the docs folder (hidden by default), please don't delete it:
|
143
159
|
- `docs/.dates_cache.jsonl`, cache file
|
144
|
-
- `docs/.gitattributes`, merge mechanism for cache file
|
145
|
-
- The Git Hooks mechanism is used to automatically trigger the storing of the cache (
|
160
|
+
- `docs/.gitattributes`, merge mechanism for cache file
|
161
|
+
- The Git Hooks mechanism is used to automatically trigger the storing of the cache (on each git commit), and the cached file is automatically committed along with it, in addition, the installation of Git Hooks is automatically triggered when the plugin is installed, without any manual intervention!
|
146
162
|
|
147
163
|
<br />
|
148
164
|
|
@@ -151,11 +167,11 @@ The plugin supports deep customization, such as icon style, font style, theme co
|
|
151
167
|
A dispensable, insignificant little plug-in, friends who have time can take a look \^\_\^
|
152
168
|
|
153
169
|
- **Origin**:
|
154
|
-
- Because [mkdocs-git-revision-date-localized-plugin](https://github.com/timvink/mkdocs-git-revision-date-localized-plugin), a great project. When I used it at the end of 2024, I found that I couldn't use it locally because my mkdocs documentation was not included in git management,
|
170
|
+
- Because [mkdocs-git-revision-date-localized-plugin](https://github.com/timvink/mkdocs-git-revision-date-localized-plugin), a great project. When I used it at the end of 2024, I found that I couldn't use it locally because my mkdocs documentation was not included in git management, I don't understand why not read the file system time, but to use the git time, and the filesystem time is more accurate, then raised an issue to the author, but didn't get a reply for about a week (the author had a reply later, nice guy, I guess he was busy at the time), and then I thought, there is nothing to do during the Chinese New Year, and now AI is so hot, why not with the help of the AI try it out for myself, it was born, born in February 2025
|
155
171
|
- **Iteration**:
|
156
172
|
- After development, I understood why not use filesystem time, because files will be rebuilt when they go through git checkout or clone, resulting in the loss of original timestamp information, and there are many solutions:
|
157
173
|
- Method 1: Use the last git commit time as the last update time, and the first git commit time as the creation (there is a margin of error, but it's acceptable), mkdocs-git-revision-date-localized-plugin does this
|
158
|
-
- Method 2: You can cache the original time, and then read the cache subsequently. The cache can be in Front Matter of the source document or in a separate file, I chose the latter. Storing in Front Matter makes sense and is
|
174
|
+
- Method 2: You can cache the original time in advance, and then read the cache subsequently. The cache can be in Front Matter of the source document or in a separate file, I chose the latter. Storing in Front Matter makes sense and is easier, but this will modify the source content of the document, although it doesn't have any impact on the body, but I still want to ensure the originality of the data!
|
159
175
|
- **Difficulty**:
|
160
176
|
1. When to read and store original time? This is just a plugin for mkdocs, with very limited access and permissions, mkdocs provides only build and serve, so in case a user commits directly without executing build or serve (e.g., when using a CI/CD build system), then you won't be able to retrieve the time information of the file, not to mention caching it!
|
161
177
|
- Let's take a straight shot: the Git Hooks mechanism was found, prompted by the AI, which can trigger a custom script when a specific git action occurs, such as every time commit is performed
|
@@ -166,10 +182,10 @@ A dispensable, insignificant little plug-in, friends who have time can take a lo
|
|
166
182
|
4. How can I ensure that a single cache file does not conflict when collaborating with multi-person?
|
167
183
|
- Workaround: use JSONL (JSON Lines) instead of JSON, and with the merge strategy 'merge=union'
|
168
184
|
- **Improve**:
|
169
|
-
- Since it
|
170
|
-
- Ease of use
|
171
|
-
- Simplicity
|
172
|
-
- Personalization
|
185
|
+
- Since it's a newly developed plugin, it will be designed in the direction of **excellent products**, and the pursuit of the ultimate **ease of use, simplicity and personalization**
|
186
|
+
- **Ease of use**: don't let users do things manually if you can, e.g., auto-install Git Hooks, auto-cache, auto-commit, provide customized templates, etc
|
187
|
+
- **Simplicity**: no unnecessary configuration, no Git dependencies, no CI/CD configuration dependencies, no other package dependencies
|
188
|
+
- **Personalization**: almost everything can be customized, whether it's icons, styles, themes, or features, it's all fully customizable
|
173
189
|
- In addition, it has good compatibility and extensibility, and works well in WIN7, mobile devices, old Safari, etc
|
174
190
|
- **The Last Secret**:
|
175
191
|
- Programming is a hobby, and I'm a marketer of 8 years (Feel free to leave a comment)
|
@@ -8,8 +8,8 @@ An easy-to-use, lightweight MkDocs plugin for displaying the <mark>exact</mark>
|
|
8
8
|
|
9
9
|
## Features
|
10
10
|
|
11
|
-
-
|
12
|
-
- Support for manually specifying time and author
|
11
|
+
- Always display exact meta-info of the document for any environment (no-Git, Git, all CI/CD build systems, etc)
|
12
|
+
- Support for manually specifying time and author in `Front Matter`
|
13
13
|
- Support for multiple time formats (date, datetime, timeago)
|
14
14
|
- Support for document exclusion mode
|
15
15
|
- Flexible display position (top or bottom)
|
@@ -47,15 +47,14 @@ plugins:
|
|
47
47
|
- document-dates:
|
48
48
|
position: top # Display position: top (after title) bottom (end of document), default: bottom
|
49
49
|
type: date # Date type: date datetime timeago, default: date
|
50
|
-
locale: en # Localization: zh zh_TW
|
51
|
-
date_format: '%Y-%m-%d' # Date format
|
52
|
-
time_format: '%H:%M:%S' # Time format (valid only if type=datetime)
|
50
|
+
locale: en # Localization: en zh zh_TW es fr de ar ja ko ru, default: en
|
51
|
+
date_format: '%Y-%m-%d' # Date format strings, e.g., %Y-%m-%d, %b %d, %Y, etc
|
52
|
+
time_format: '%H:%M:%S' # Time format strings (valid only if type=datetime)
|
53
53
|
exclude: # List of excluded files
|
54
54
|
- temp.md # Exclude specific file
|
55
55
|
- private/* # Exclude all files in private directory, including subdirectories
|
56
|
-
- drafts/*.md # Exclude all markdown files in the current directory drafts, but not subdirectories
|
57
56
|
|
58
|
-
show_author: true #
|
57
|
+
show_author: true # Show author or not, default: true
|
59
58
|
|
60
59
|
```
|
61
60
|
|
@@ -63,7 +62,7 @@ plugins:
|
|
63
62
|
|
64
63
|
The plugin will automatically get the exact time of the document, will automatically cache the creation time, but of course, you can also specify it manually in `Front Matter`
|
65
64
|
|
66
|
-
Priority: `Front Matter` > `Cache Files` > `File System Timestamps`
|
65
|
+
Priority order: `Front Matter` > `Cache Files` > `File System Timestamps`
|
67
66
|
|
68
67
|
```yaml
|
69
68
|
---
|
@@ -81,7 +80,7 @@ modified: 2025-02-23
|
|
81
80
|
|
82
81
|
The plugin will automatically get the author of the document, will parse the email and make a link, also you can specify it manually in `Front Matter`
|
83
82
|
|
84
|
-
Priority: `Front Matter` > `Git Author
|
83
|
+
Priority order: `Front Matter` > `Git Author` > `site_author (mkdocs.yml)` > `PC Username`
|
85
84
|
|
86
85
|
```yaml
|
87
86
|
---
|
@@ -97,27 +96,42 @@ email: e-name@gmail.com
|
|
97
96
|
|
98
97
|
## Customization
|
99
98
|
|
100
|
-
The plugin supports deep customization, such as icon style, font style, theme color, animation type, dividing line
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
99
|
+
The plugin supports deep customization, such as **icon style, font style, theme color, animation type, dividing line**, etc. All of it can be customized by modifying the preset values in the corresponding file (I've already written the code and comments, you just need to turn on the switch and change the value):
|
100
|
+
|
101
|
+
| Function: | Location: |
|
102
|
+
| :----------------------: | ---------------------------------------- |
|
103
|
+
| **Style & Theme** | `docs/assets/document_dates/user.config.css` |
|
104
|
+
| **Properties & Functions** | `docs/assets/document_dates/user.config.js` |
|
105
|
+
| **Localized languages** | `docs/assets/document_dates/languages/` <br />refer to the template file `en.json` for any additions or modifications |
|
106
|
+
|
107
|
+
**Tip**: when `type: timeago` is set, timeago.js is enabled to render time dynamically, `timeago.min.js` only contains English and Chinese by default, if you need to load other languages, you can configure it as below (choose one):
|
108
|
+
|
109
|
+
- In `user.config.js`, refer to [the demo commented out](https://github.com/jaywhj/mkdocs-document-dates/blob/main/mkdocs_document_dates/static/config/user.config.js) at the bottom, translate it into your local language
|
110
|
+
- In `mkdocs.yml`, add the following two lines to configure the full version of `timeago.full.min.js` to load all languages at once
|
111
|
+
```yaml
|
112
|
+
extra_javascript:
|
113
|
+
- assets/document_dates/core/timeago.full.min.js
|
114
|
+
- assets/document_dates/core/timeago-load.js
|
115
|
+
```
|
116
|
+
|
117
|
+
**Demo Images**:
|
118
|
+
|
119
|
+

|
120
|
+

|
121
|
+

|
122
|
+

|
123
|
+

|
124
|
+
|
125
|
+

|
126
|
+

|
127
|
+

|
114
128
|
|
115
129
|
## Other Tips
|
116
130
|
|
117
|
-
- In order to get the exact creation time, a separate cache file is used to store the creation time of the
|
131
|
+
- In order to always get the exact creation time, a separate cache file is used to store the creation time of the document, located in the docs folder (hidden by default), please don't delete it:
|
118
132
|
- `docs/.dates_cache.jsonl`, cache file
|
119
|
-
- `docs/.gitattributes`, merge mechanism for cache file
|
120
|
-
- The Git Hooks mechanism is used to automatically trigger the storing of the cache (
|
133
|
+
- `docs/.gitattributes`, merge mechanism for cache file
|
134
|
+
- The Git Hooks mechanism is used to automatically trigger the storing of the cache (on each git commit), and the cached file is automatically committed along with it, in addition, the installation of Git Hooks is automatically triggered when the plugin is installed, without any manual intervention!
|
121
135
|
|
122
136
|
<br />
|
123
137
|
|
@@ -126,11 +140,11 @@ The plugin supports deep customization, such as icon style, font style, theme co
|
|
126
140
|
A dispensable, insignificant little plug-in, friends who have time can take a look \^\_\^
|
127
141
|
|
128
142
|
- **Origin**:
|
129
|
-
- Because [mkdocs-git-revision-date-localized-plugin](https://github.com/timvink/mkdocs-git-revision-date-localized-plugin), a great project. When I used it at the end of 2024, I found that I couldn't use it locally because my mkdocs documentation was not included in git management,
|
143
|
+
- Because [mkdocs-git-revision-date-localized-plugin](https://github.com/timvink/mkdocs-git-revision-date-localized-plugin), a great project. When I used it at the end of 2024, I found that I couldn't use it locally because my mkdocs documentation was not included in git management, I don't understand why not read the file system time, but to use the git time, and the filesystem time is more accurate, then raised an issue to the author, but didn't get a reply for about a week (the author had a reply later, nice guy, I guess he was busy at the time), and then I thought, there is nothing to do during the Chinese New Year, and now AI is so hot, why not with the help of the AI try it out for myself, it was born, born in February 2025
|
130
144
|
- **Iteration**:
|
131
145
|
- After development, I understood why not use filesystem time, because files will be rebuilt when they go through git checkout or clone, resulting in the loss of original timestamp information, and there are many solutions:
|
132
146
|
- Method 1: Use the last git commit time as the last update time, and the first git commit time as the creation (there is a margin of error, but it's acceptable), mkdocs-git-revision-date-localized-plugin does this
|
133
|
-
- Method 2: You can cache the original time, and then read the cache subsequently. The cache can be in Front Matter of the source document or in a separate file, I chose the latter. Storing in Front Matter makes sense and is
|
147
|
+
- Method 2: You can cache the original time in advance, and then read the cache subsequently. The cache can be in Front Matter of the source document or in a separate file, I chose the latter. Storing in Front Matter makes sense and is easier, but this will modify the source content of the document, although it doesn't have any impact on the body, but I still want to ensure the originality of the data!
|
134
148
|
- **Difficulty**:
|
135
149
|
1. When to read and store original time? This is just a plugin for mkdocs, with very limited access and permissions, mkdocs provides only build and serve, so in case a user commits directly without executing build or serve (e.g., when using a CI/CD build system), then you won't be able to retrieve the time information of the file, not to mention caching it!
|
136
150
|
- Let's take a straight shot: the Git Hooks mechanism was found, prompted by the AI, which can trigger a custom script when a specific git action occurs, such as every time commit is performed
|
@@ -141,10 +155,10 @@ A dispensable, insignificant little plug-in, friends who have time can take a lo
|
|
141
155
|
4. How can I ensure that a single cache file does not conflict when collaborating with multi-person?
|
142
156
|
- Workaround: use JSONL (JSON Lines) instead of JSON, and with the merge strategy 'merge=union'
|
143
157
|
- **Improve**:
|
144
|
-
- Since it
|
145
|
-
- Ease of use
|
146
|
-
- Simplicity
|
147
|
-
- Personalization
|
158
|
+
- Since it's a newly developed plugin, it will be designed in the direction of **excellent products**, and the pursuit of the ultimate **ease of use, simplicity and personalization**
|
159
|
+
- **Ease of use**: don't let users do things manually if you can, e.g., auto-install Git Hooks, auto-cache, auto-commit, provide customized templates, etc
|
160
|
+
- **Simplicity**: no unnecessary configuration, no Git dependencies, no CI/CD configuration dependencies, no other package dependencies
|
161
|
+
- **Personalization**: almost everything can be customized, whether it's icons, styles, themes, or features, it's all fully customizable
|
148
162
|
- In addition, it has good compatibility and extensibility, and works well in WIN7, mobile devices, old Safari, etc
|
149
163
|
- **The Last Secret**:
|
150
164
|
- Programming is a hobby, and I'm a marketer of 8 years (Feel free to leave a comment)
|
{mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/cache_manager.py
RENAMED
@@ -13,13 +13,13 @@ logging.basicConfig(
|
|
13
13
|
)
|
14
14
|
|
15
15
|
def find_mkdocs_projects():
|
16
|
+
projects = []
|
16
17
|
try:
|
17
18
|
git_root = Path(subprocess.check_output(
|
18
19
|
['git', 'rev-parse', '--show-toplevel'],
|
19
20
|
text=True, encoding='utf-8'
|
20
21
|
).strip())
|
21
22
|
|
22
|
-
projects = []
|
23
23
|
# 遍历 git_root 及子目录, 寻找 mkdocs.yml 文件
|
24
24
|
for config_file in git_root.rglob('mkdocs.y*ml'):
|
25
25
|
if config_file.name.lower() in ('mkdocs.yml', 'mkdocs.yaml'):
|
@@ -27,13 +27,12 @@ def find_mkdocs_projects():
|
|
27
27
|
|
28
28
|
if not projects:
|
29
29
|
logging.info("No MkDocs projects found in the repository")
|
30
|
-
return projects
|
31
30
|
except subprocess.CalledProcessError as e:
|
32
31
|
logging.error(f"Failed to find the Git repository root: {e}")
|
33
|
-
return []
|
34
32
|
except Exception as e:
|
35
33
|
logging.error(f"Unexpected error while searching for MkDocs projects: {e}")
|
36
|
-
|
34
|
+
|
35
|
+
return projects
|
37
36
|
|
38
37
|
def get_file_creation_time(file_path):
|
39
38
|
try:
|
@@ -57,9 +56,9 @@ def get_git_first_commit_time(file_path):
|
|
57
56
|
# git log --reverse --format="%aI" --date=iso -- {file_path} | head -n 1
|
58
57
|
result = subprocess.run(['git', 'log', '--reverse', '--format=%aI', '--', file_path], capture_output=True, text=True)
|
59
58
|
if result.returncode == 0:
|
60
|
-
|
61
|
-
if
|
62
|
-
return datetime.fromisoformat(
|
59
|
+
first_line = result.stdout.partition('\n')[0].strip()
|
60
|
+
if first_line:
|
61
|
+
return datetime.fromisoformat(first_line).replace(tzinfo=None)
|
63
62
|
except Exception as e:
|
64
63
|
logging.info(f"Error getting git first commit time for {file_path}: {e}")
|
65
64
|
return None
|
@@ -164,7 +163,7 @@ def update_cache():
|
|
164
163
|
cmd = ["git", "ls-files", "*.md"]
|
165
164
|
result = subprocess.run(cmd, cwd=docs_dir, capture_output=True, text=True, check=True)
|
166
165
|
tracked_files = result.stdout.splitlines() if result.stdout else []
|
167
|
-
|
166
|
+
|
168
167
|
if not tracked_files:
|
169
168
|
logging.info(f"No tracked markdown files found in {docs_dir}")
|
170
169
|
continue
|
@@ -176,17 +175,17 @@ def update_cache():
|
|
176
175
|
# 读取新的JSONL缓存文件(如果存在)
|
177
176
|
jsonl_cache_file = docs_dir / '.dates_cache.jsonl'
|
178
177
|
jsonl_dates_cache = read_jsonl_cache(jsonl_cache_file)
|
179
|
-
|
178
|
+
|
180
179
|
# 根据 git已跟踪的文件来更新
|
181
180
|
for file_path in tracked_files:
|
182
181
|
try:
|
183
182
|
rel_path = file_path
|
184
183
|
full_path = docs_dir / rel_path
|
185
|
-
|
184
|
+
|
186
185
|
# 如果文件已在JSONL缓存中,跳过
|
187
186
|
if rel_path in jsonl_dates_cache:
|
188
187
|
continue
|
189
|
-
|
188
|
+
|
190
189
|
# 处理新文件或迁移旧JSON缓存
|
191
190
|
if rel_path in json_dates_cache:
|
192
191
|
jsonl_dates_cache[rel_path] = json_dates_cache[rel_path]
|
{mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.5}/mkdocs_document_dates/hooks_installer.py
RENAMED
@@ -23,7 +23,7 @@ def check_python_version(interpreter):
|
|
23
23
|
[interpreter, "-c", "import sys; print(sys.version_info >= (3, 7))"],
|
24
24
|
capture_output=True, text=True, check=False
|
25
25
|
)
|
26
|
-
if result.returncode == 0 and result.stdout.strip() == '
|
26
|
+
if result.returncode == 0 and result.stdout.strip().lower() == 'true':
|
27
27
|
return True
|
28
28
|
else:
|
29
29
|
logging.warning(f"Low python version, requires python_requires >=3.7")
|