mkdocs-document-dates 1.8.0__py3-none-any.whl → 1.9.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.
@@ -9,17 +9,42 @@ from datetime import datetime
9
9
  from pathlib import Path
10
10
 
11
11
  # 配置日志
12
- log_file = Path.home() / '.mkdocs_document_dates' / 'hooks.log'
13
- log_file.parent.mkdir(parents=True, exist_ok=True)
12
+ def setup_logging():
13
+ """设置日志"""
14
+ try:
15
+ # 获取当前 git 仓库根目录
16
+ git_root = Path(subprocess.check_output(
17
+ ['git', 'rev-parse', '--show-toplevel'],
18
+ text=True
19
+ ).strip())
20
+
21
+ # 在 git 仓库根目录下创建日志目录
22
+ log_dir = git_root / '.mkdocs_dates'
23
+ log_dir.mkdir(exist_ok=True)
24
+ log_file = log_dir / 'hook.log'
25
+
26
+ logging.basicConfig(
27
+ level=logging.INFO,
28
+ format='%(asctime)s - %(levelname)s - %(message)s',
29
+ handlers=[
30
+ logging.FileHandler(log_file),
31
+ logging.StreamHandler(sys.stderr)
32
+ ]
33
+ )
34
+ return True
35
+ except Exception as e:
36
+ print(f"Failed to setup logging: {e}", file=sys.stderr)
37
+ return False
14
38
 
15
- logging.basicConfig(
16
- level=logging.INFO,
17
- format='%(asctime)s - %(levelname)s - %(message)s',
18
- handlers=[
19
- logging.FileHandler(log_file),
20
- logging.StreamHandler(sys.stderr) # 同时输出到stderr,方便调试
21
- ]
22
- )
39
+ if __name__ == "__main__":
40
+ try:
41
+ if setup_logging():
42
+ logging.info("Starting pre-commit hook...")
43
+ update_dates_cache()
44
+ logging.info("Pre-commit hook completed successfully")
45
+ except Exception as e:
46
+ print(f"Error in pre-commit hook: {e}", file=sys.stderr)
47
+ sys.exit(1)
23
48
 
24
49
  def find_mkdocs_projects():
25
50
  """查找当前 git 仓库中的所有 MkDocs 项目"""
@@ -92,12 +117,3 @@ def update_dates_cache():
92
117
  except Exception as e:
93
118
  logging.error(f"Error handling cache file: {e}")
94
119
  raise
95
-
96
- if __name__ == "__main__":
97
- try:
98
- logging.info("Starting pre-commit hook...")
99
- update_dates_cache()
100
- logging.info("Pre-commit hook completed successfully")
101
- except Exception as e:
102
- logging.error(f"Error in pre-commit hook: {e}")
103
- sys.exit(1)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mkdocs-document-dates
3
- Version: 1.8.0
3
+ Version: 1.9.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
@@ -1,7 +1,7 @@
1
1
  mkdocs_document_dates/__init__.py,sha256=CZ37u8DC6kbkupKFk-VKyfKZZFAJ4rOD0aPzOzVoATc,58
2
2
  mkdocs_document_dates/plugin.py,sha256=zgZ9QrbfsMDAv80P11I_99urSvFolJq93Ow7P-pfS_A,9753
3
3
  mkdocs_document_dates/styles.py,sha256=ujhlKgDWsOo5sHiYtf3XekuGg4C5Yjol8RzP3W9Wzjo,578
4
- mkdocs_document_dates/hooks/pre-commit,sha256=kDQaQ_f2dDNgOkZD6QTHxew0ZySyMDQkTsahf43IQ04,3411
4
+ mkdocs_document_dates/hooks/pre-commit,sha256=QjNR2Xlz2KNkOOmDJvdHo9tVvGUM4MpTQPRZzcA5m4Q,3934
5
5
  mkdocs_document_dates/lang/__init__.py,sha256=M1BLjCOA3HHKeAitk45YAgzxxNpnxFUvVAk6-FO_QSA,690
6
6
  mkdocs_document_dates/lang/ar.py,sha256=BsZlxz54U_spOZ5SBiKt73ywoLKbR54cZNkKAs86OxM,632
7
7
  mkdocs_document_dates/lang/de.py,sha256=B0Ffrn4lVSvcxFpGho7SiMm16GXYEmpjcVAR-k4UgSI,585
@@ -13,9 +13,9 @@ mkdocs_document_dates/lang/ko.py,sha256=GwY6yrKYAOj6S6feq9yqNxr2XpyGHC0XeenO541v
13
13
  mkdocs_document_dates/lang/ru.py,sha256=fK5s4mQKCoP6KI3jf6eqqmqB3YVn39q81U7Cw1QWNNg,721
14
14
  mkdocs_document_dates/lang/zh.py,sha256=OrLElrSTZhHSwxBzuUtUj7NpQb7wm0s83viimpk2ynM,519
15
15
  mkdocs_document_dates/lang/zh_tw.py,sha256=t3qu-a7UOzgcmYDkLFiosJZCcpfMU4xiKTJfu1ZHoHA,519
16
- mkdocs_document_dates-1.8.0.dist-info/LICENSE,sha256=1YKfCs5WKSk-bON8a68WZE5to1B2klCrHBYiuaVCThM,514
17
- mkdocs_document_dates-1.8.0.dist-info/METADATA,sha256=e2LmLz1YLBjP_xwAhdnFx1wqyFCKSBqr7SjY8adtwE0,3908
18
- mkdocs_document_dates-1.8.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
19
- mkdocs_document_dates-1.8.0.dist-info/entry_points.txt,sha256=gI-OFLGjDG6-oLEfyevl3Gwwj2GcqVFQeX3bvL1IF8o,83
20
- mkdocs_document_dates-1.8.0.dist-info/top_level.txt,sha256=yWkKQdNuAJJVqUQ9uLa5xD4x_Gux4IfOUpy8Ryagdwc,22
21
- mkdocs_document_dates-1.8.0.dist-info/RECORD,,
16
+ mkdocs_document_dates-1.9.0.dist-info/LICENSE,sha256=1YKfCs5WKSk-bON8a68WZE5to1B2klCrHBYiuaVCThM,514
17
+ mkdocs_document_dates-1.9.0.dist-info/METADATA,sha256=hZ91KZRU5tBp8OnX9fk0xaeQdxWasHomYQTgGqxbgrk,3908
18
+ mkdocs_document_dates-1.9.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
19
+ mkdocs_document_dates-1.9.0.dist-info/entry_points.txt,sha256=gI-OFLGjDG6-oLEfyevl3Gwwj2GcqVFQeX3bvL1IF8o,83
20
+ mkdocs_document_dates-1.9.0.dist-info/top_level.txt,sha256=yWkKQdNuAJJVqUQ9uLa5xD4x_Gux4IfOUpy8Ryagdwc,22
21
+ mkdocs_document_dates-1.9.0.dist-info/RECORD,,