mkdocs-document-dates 1.1.0__tar.gz → 1.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 (26) hide show
  1. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/PKG-INFO +3 -3
  2. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/README.md +2 -2
  3. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates/plugin.py +19 -18
  4. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates.egg-info/PKG-INFO +3 -3
  5. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/setup.py +13 -4
  6. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/LICENSE +0 -0
  7. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates/__init__.py +0 -0
  8. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates/hooks/pre-commit +0 -0
  9. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates/lang/__init__.py +0 -0
  10. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates/lang/ar.py +0 -0
  11. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates/lang/de.py +0 -0
  12. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates/lang/en.py +0 -0
  13. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates/lang/es.py +0 -0
  14. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates/lang/fr.py +0 -0
  15. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates/lang/ja.py +0 -0
  16. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates/lang/ko.py +0 -0
  17. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates/lang/ru.py +0 -0
  18. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates/lang/zh.py +0 -0
  19. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates/lang/zh_tw.py +0 -0
  20. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates/styles.py +0 -0
  21. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates.egg-info/SOURCES.txt +0 -0
  22. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates.egg-info/dependency_links.txt +0 -0
  23. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates.egg-info/entry_points.txt +0 -0
  24. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates.egg-info/requires.txt +0 -0
  25. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/mkdocs_document_dates.egg-info/top_level.txt +0 -0
  26. {mkdocs_document_dates-1.1.0 → mkdocs_document_dates-1.3.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mkdocs-document-dates
3
- Version: 1.1.0
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 `.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.1.0`
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
@@ -89,8 +89,8 @@ modified: 2023-12-31
89
89
  - macOS: Uses file creation time (birthtime)
90
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
91
  - It still works when using CI/CD build systems (e.g. Github Actions)
92
- - Used a cache file `.dates_cache.json` to solve this problem
93
- - You can configure it like this: `pip install --upgrade mkdocs-document-dates` or `pip install mkdocs-document-dates==1.1.0`
92
+ - Used a cache file `dates_cache.json` to solve this problem
93
+ - You can configure it like this: `pip install --upgrade mkdocs-document-dates` or `pip install mkdocs-document-dates==1.2.0`
94
94
  ```
95
95
  - run: pip install --upgrade mkdocs-document-dates
96
96
  - run: mkdocs gh-deploy --force
@@ -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
- file_dir = Path(file_path).parent
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
- # 首先尝试发布后的路径(assets/dates_cache.json)
155
- cache_file = file_dir / 'assets' / 'dates_cache.json'
156
- if not cache_file.exists():
157
- # 如果不存在,尝试开发时的路径(docs/assets/dates_cache.json)
158
- docs_dir = Path(file_path).parent.parent
159
- cache_file = docs_dir / 'assets' / 'dates_cache.json'
160
-
161
- if cache_file.exists():
162
- with open(cache_file) as f:
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.1.0
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 `.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.1.0`
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
@@ -10,15 +10,24 @@ def install_git_hooks():
10
10
  hooks_dir = project_dir / 'mkdocs_document_dates' / 'hooks'
11
11
 
12
12
  if not hooks_dir.exists():
13
+ print("Warning: Hooks directory not found")
13
14
  return
14
15
 
15
- # 通过 git hooks 机制捕获 git commit 事件,git 在执行 commit 时会自动查找并执行 pre-commit hook
16
+ # 确保 hooks 目录存在且有执行权限
17
+ subprocess.run(['chmod', '-R', '755', str(hooks_dir)], check=True)
18
+
19
+ # 设置全局 hooks 路径
16
20
  subprocess.run(['git', 'config', '--global', 'core.hooksPath', str(hooks_dir)],
17
21
  check=True)
18
22
 
23
+ # 验证 hook 是否正确安装
19
24
  hook_path = hooks_dir / 'pre-commit'
20
- if hook_path.exists():
21
- os.chmod(hook_path, 0o755)
25
+ if not hook_path.exists():
26
+ print("Warning: pre-commit hook not found")
27
+ return
28
+
29
+ os.chmod(hook_path, 0o755)
30
+ print(f"Git hooks installed successfully at: {hooks_dir}")
22
31
 
23
32
  except Exception as e:
24
33
  print(f"Warning: Failed to install git hooks: {e}")
@@ -34,7 +43,7 @@ try:
34
43
  except FileNotFoundError:
35
44
  long_description = "A MkDocs plugin for displaying accurate document creation and last modification dates."
36
45
 
37
- VERSION = '1.1.0'
46
+ VERSION = '1.3.0'
38
47
 
39
48
  setup(
40
49
  name="mkdocs-document-dates",