mkdocs-document-dates 1.9.8__py3-none-any.whl → 1.9.9__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,3 +1,11 @@
1
1
  """MkDocs Document Dates Plugin."""
2
2
 
3
- __version__ = '1.0.0'
3
+ __version__ = '1.0.0'
4
+
5
+ from .hooks_installer import install
6
+
7
+ # 当包被导入时自动安装 hooks
8
+ try:
9
+ install()
10
+ except Exception as e:
11
+ print(f"自动安装 git hooks 失败: {e}")
@@ -0,0 +1,49 @@
1
+ import os
2
+ import sys
3
+ import subprocess
4
+ from pathlib import Path
5
+ import site
6
+
7
+ def install():
8
+ """安装 git hooks 的入口点函数"""
9
+ print("\n正在安装 git hooks...\n")
10
+ try:
11
+ # 先清除旧的配置
12
+ subprocess.run(['git', 'config', '--global', '--unset', 'core.hooksPath'],
13
+ check=False)
14
+
15
+ # 优先使用开发目录
16
+ dev_hooks_dir = Path(__file__).parent.resolve() / 'hooks'
17
+ if dev_hooks_dir.exists():
18
+ hook_path = dev_hooks_dir / 'pre-commit'
19
+ if hook_path.exists():
20
+ if os.name != 'nt':
21
+ os.chmod(dev_hooks_dir, 0o755)
22
+ os.chmod(hook_path, 0o755)
23
+ subprocess.run(['git', 'config', '--global', 'core.hooksPath', str(dev_hooks_dir)],
24
+ check=True)
25
+ print(f"Hooks 已安装到 (开发模式): {dev_hooks_dir}")
26
+ return True
27
+
28
+ # 如果开发目录不存在,再尝试 site-packages
29
+ for site_dir in site.getsitepackages():
30
+ hooks_dir = Path(site_dir) / 'mkdocs_document_dates' / 'hooks'
31
+ if hooks_dir.exists():
32
+ hook_path = hooks_dir / 'pre-commit'
33
+ if hook_path.exists():
34
+ if os.name != 'nt':
35
+ os.chmod(hooks_dir, 0o755)
36
+ os.chmod(hook_path, 0o755)
37
+ subprocess.run(['git', 'config', '--global', 'core.hooksPath', str(hooks_dir)],
38
+ check=True)
39
+ print(f"Hooks 已安装到: {hooks_dir}")
40
+ return True
41
+
42
+ print("错误: 未找到 hooks 目录")
43
+ return False
44
+ except Exception as e:
45
+ print(f"安装 hooks 时出错: {e}")
46
+ return False
47
+
48
+ if __name__ == '__main__':
49
+ install()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mkdocs-document-dates
3
- Version: 1.9.8
3
+ Version: 1.9.9
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,4 +1,5 @@
1
- mkdocs_document_dates/__init__.py,sha256=CZ37u8DC6kbkupKFk-VKyfKZZFAJ4rOD0aPzOzVoATc,58
1
+ mkdocs_document_dates/__init__.py,sha256=21uV4d5z91W4O-aAPrwosujLGgsR7Mh5rQUCKDoGsT8,227
2
+ mkdocs_document_dates/hooks_installer.py,sha256=dJcFQxohWnLI7gp-bxkB3Vz6E0rFw63o0xXiFEcjOw0,1868
2
3
  mkdocs_document_dates/plugin.py,sha256=zgZ9QrbfsMDAv80P11I_99urSvFolJq93Ow7P-pfS_A,9753
3
4
  mkdocs_document_dates/styles.py,sha256=ujhlKgDWsOo5sHiYtf3XekuGg4C5Yjol8RzP3W9Wzjo,578
4
5
  mkdocs_document_dates/hooks/pre-commit,sha256=YoNwuoT2NxMbpzwxMctH4EFB5ex_LdzG5xDxKjl93LQ,2601
@@ -13,9 +14,9 @@ mkdocs_document_dates/lang/ko.py,sha256=GwY6yrKYAOj6S6feq9yqNxr2XpyGHC0XeenO541v
13
14
  mkdocs_document_dates/lang/ru.py,sha256=fK5s4mQKCoP6KI3jf6eqqmqB3YVn39q81U7Cw1QWNNg,721
14
15
  mkdocs_document_dates/lang/zh.py,sha256=OrLElrSTZhHSwxBzuUtUj7NpQb7wm0s83viimpk2ynM,519
15
16
  mkdocs_document_dates/lang/zh_tw.py,sha256=t3qu-a7UOzgcmYDkLFiosJZCcpfMU4xiKTJfu1ZHoHA,519
16
- mkdocs_document_dates-1.9.8.dist-info/LICENSE,sha256=1YKfCs5WKSk-bON8a68WZE5to1B2klCrHBYiuaVCThM,514
17
- mkdocs_document_dates-1.9.8.dist-info/METADATA,sha256=lJqJx-D5OX8JPQPw0r_LZ1DvOe88BASuAtMenlwHtxc,3908
18
- mkdocs_document_dates-1.9.8.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
19
- mkdocs_document_dates-1.9.8.dist-info/entry_points.txt,sha256=gI-OFLGjDG6-oLEfyevl3Gwwj2GcqVFQeX3bvL1IF8o,83
20
- mkdocs_document_dates-1.9.8.dist-info/top_level.txt,sha256=yWkKQdNuAJJVqUQ9uLa5xD4x_Gux4IfOUpy8Ryagdwc,22
21
- mkdocs_document_dates-1.9.8.dist-info/RECORD,,
17
+ mkdocs_document_dates-1.9.9.dist-info/LICENSE,sha256=1YKfCs5WKSk-bON8a68WZE5to1B2klCrHBYiuaVCThM,514
18
+ mkdocs_document_dates-1.9.9.dist-info/METADATA,sha256=Q8Oqd5iOcL1-r7v993WwCf9HoZnV2TH5a-XMp8rSZA8,3908
19
+ mkdocs_document_dates-1.9.9.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
20
+ mkdocs_document_dates-1.9.9.dist-info/entry_points.txt,sha256=4JFXqAAay470D6qgPzAAhDC-lwXVSF7THDBRFJE0yYQ,171
21
+ mkdocs_document_dates-1.9.9.dist-info/top_level.txt,sha256=yWkKQdNuAJJVqUQ9uLa5xD4x_Gux4IfOUpy8Ryagdwc,22
22
+ mkdocs_document_dates-1.9.9.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ [console_scripts]
2
+ install-mkdocs-hooks = mkdocs_document_dates.hooks_installer:install
3
+
4
+ [mkdocs.plugins]
5
+ document-dates = mkdocs_document_dates.plugin:DocumentDatesPlugin
@@ -1,2 +0,0 @@
1
- [mkdocs.plugins]
2
- document-dates = mkdocs_document_dates.plugin:DocumentDatesPlugin