mkdocs-document-dates 1.9.7__tar.gz → 1.9.8__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.9.7 → mkdocs_document_dates-1.9.8}/PKG-INFO +1 -1
  2. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates/hooks/pre-commit +8 -83
  3. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates.egg-info/PKG-INFO +1 -1
  4. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/setup.py +4 -6
  5. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/LICENSE +0 -0
  6. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/README.md +0 -0
  7. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates/__init__.py +0 -0
  8. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates/lang/__init__.py +0 -0
  9. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates/lang/ar.py +0 -0
  10. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates/lang/de.py +0 -0
  11. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates/lang/en.py +0 -0
  12. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates/lang/es.py +0 -0
  13. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates/lang/fr.py +0 -0
  14. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates/lang/ja.py +0 -0
  15. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates/lang/ko.py +0 -0
  16. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates/lang/ru.py +0 -0
  17. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates/lang/zh.py +0 -0
  18. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates/lang/zh_tw.py +0 -0
  19. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates/plugin.py +0 -0
  20. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates/styles.py +0 -0
  21. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates.egg-info/SOURCES.txt +0 -0
  22. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates.egg-info/dependency_links.txt +0 -0
  23. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates.egg-info/entry_points.txt +0 -0
  24. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates.egg-info/requires.txt +0 -0
  25. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/mkdocs_document_dates.egg-info/top_level.txt +0 -0
  26. {mkdocs_document_dates-1.9.7 → mkdocs_document_dates-1.9.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mkdocs-document-dates
3
- Version: 1.9.7
3
+ Version: 1.9.8
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
@@ -8,80 +8,6 @@ import subprocess
8
8
  from datetime import datetime
9
9
  from pathlib import Path
10
10
 
11
- # 添加调试日志到项目的 docs 目录
12
- def log_debug(message):
13
- try:
14
- git_root = Path(subprocess.check_output(
15
- ['git', 'rev-parse', '--show-toplevel'],
16
- text=True
17
- ).strip())
18
-
19
- docs_dir = git_root / 'docs'
20
- if docs_dir.exists():
21
- with open(docs_dir / '.hook_debug.log', 'a') as f:
22
- f.write(f"{datetime.now()}: {message}\n")
23
- except:
24
- pass # 静默失败,不影响主流程
25
-
26
- # 配置日志
27
- def setup_logging():
28
- """设置日志"""
29
- try:
30
- # 获取当前 git 仓库根目录
31
- git_root = Path(subprocess.check_output(
32
- ['git', 'rev-parse', '--show-toplevel'],
33
- text=True
34
- ).strip())
35
-
36
- # 在 git 仓库根目录下创建日志目录
37
- log_dir = git_root / '.mkdocs_dates'
38
- log_dir.mkdir(exist_ok=True)
39
- log_file = log_dir / 'hook.log'
40
-
41
- logging.basicConfig(
42
- level=logging.INFO,
43
- format='%(asctime)s - %(levelname)s - %(message)s',
44
- handlers=[
45
- logging.FileHandler(log_file),
46
- logging.StreamHandler(sys.stderr)
47
- ]
48
- )
49
- return True
50
- except Exception as e:
51
- print(f"Failed to setup logging: {e}", file=sys.stderr)
52
- return False
53
-
54
- # 添加调试函数
55
- def debug_info():
56
- info = {
57
- 'cwd': os.getcwd(),
58
- 'python_path': sys.executable,
59
- 'env_path': os.environ.get('PATH', ''),
60
- 'script_path': __file__,
61
- 'timestamp': datetime.now().isoformat()
62
- }
63
-
64
- # 保存调试信息到固定位置
65
- debug_file = Path('/tmp/mkdocs_hook_debug.json')
66
- try:
67
- with open(debug_file, 'w') as f:
68
- json.dump(info, f, indent=2)
69
-
70
- # 同时输出到 stderr(git 会显示这些信息)
71
- print("Hook debug info:", file=sys.stderr)
72
- for k, v in info.items():
73
- print(f"{k}: {v}", file=sys.stderr)
74
- except Exception as e:
75
- print(f"Debug error: {e}", file=sys.stderr)
76
-
77
- if __name__ == "__main__":
78
- try:
79
- debug_info() # 添加调试信息
80
- update_dates_cache()
81
- except Exception as e:
82
- print(f"Hook error: {e}", file=sys.stderr)
83
- sys.exit(1)
84
-
85
11
  def find_mkdocs_projects():
86
12
  """查找当前 git 仓库中的所有 MkDocs 项目"""
87
13
  try:
@@ -121,7 +47,6 @@ def get_file_dates(file_path):
121
47
  current_time = datetime.now()
122
48
  return current_time.isoformat(), current_time.isoformat()
123
49
 
124
-
125
50
  def update_dates_cache():
126
51
  """更新文档时间缓存"""
127
52
  for project_dir in find_mkdocs_projects():
@@ -129,9 +54,6 @@ def update_dates_cache():
129
54
  if not docs_dir.exists():
130
55
  continue
131
56
 
132
- logging.info(f"Processing MkDocs project: {project_dir}")
133
- logging.info(f"Docs directory: {docs_dir}")
134
-
135
57
  dates_cache = {}
136
58
  for md_file in docs_dir.rglob("*.md"):
137
59
  rel_path = str(md_file.relative_to(docs_dir))
@@ -140,16 +62,19 @@ def update_dates_cache():
140
62
  "created": created,
141
63
  "modified": modified
142
64
  }
143
- logging.info(f"Processing file: {rel_path}")
144
65
 
145
66
  cache_file = docs_dir / '.dates_cache.json'
146
- logging.info(f"Saving cache to: {cache_file}")
147
-
148
67
  try:
149
68
  with open(cache_file, "w") as f:
150
69
  json.dump(dates_cache, f, indent=2, ensure_ascii=False)
151
70
  subprocess.run(["git", "add", str(cache_file)], check=True)
152
- logging.info(f"Added cache file to git: {cache_file}")
153
71
  except Exception as e:
154
- logging.error(f"Error handling cache file: {e}")
72
+ print(f"Error handling cache file: {e}", file=sys.stderr)
155
73
  raise
74
+
75
+ if __name__ == "__main__":
76
+ try:
77
+ update_dates_cache()
78
+ except Exception as e:
79
+ print(f"Hook error: {e}", file=sys.stderr)
80
+ sys.exit(1)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mkdocs-document-dates
3
- Version: 1.9.7
3
+ Version: 1.9.8
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
@@ -9,13 +9,11 @@ from pathlib import Path
9
9
 
10
10
  def install_git_hooks():
11
11
  try:
12
- # 先等待包安装完成并打印调试信息
13
12
  print("Starting hooks installation...")
14
13
 
15
- # 使用 pkg_resources 获取已安装包的位置
16
- import pkg_resources
17
- dist = pkg_resources.get_distribution('mkdocs-document-dates')
18
- hooks_dir = Path(dist.location) / 'mkdocs_document_dates' / 'hooks'
14
+ # 直接使用系统 Python 路径
15
+ python_path = sys.prefix
16
+ hooks_dir = Path(python_path) / 'lib' / f'python{sys.version_info.major}.{sys.version_info.minor}' / 'site-packages' / 'mkdocs_document_dates' / 'hooks'
19
17
 
20
18
  print(f"Looking for hooks in: {hooks_dir}")
21
19
 
@@ -72,7 +70,7 @@ try:
72
70
  except FileNotFoundError:
73
71
  long_description = "A MkDocs plugin for displaying accurate document creation and last modification dates."
74
72
 
75
- VERSION = '1.9.7'
73
+ VERSION = '1.9.8'
76
74
 
77
75
  setup(
78
76
  name="mkdocs-document-dates",