mkdocs-document-dates 3.8.9__tar.gz → 3.9.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 (44) hide show
  1. {mkdocs_document_dates-3.8.9/mkdocs_document_dates.egg-info → mkdocs_document_dates-3.9.0}/PKG-INFO +1 -1
  2. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/plugin.py +5 -0
  3. mkdocs_document_dates-3.9.0/mkdocs_document_dates/static/core/avatar.js +50 -0
  4. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/core/core.js +3 -30
  5. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/utils.py +40 -2
  6. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0/mkdocs_document_dates.egg-info}/PKG-INFO +1 -1
  7. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates.egg-info/SOURCES.txt +1 -0
  8. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/pyproject.toml +1 -1
  9. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/setup.py +1 -1
  10. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/LICENSE +0 -0
  11. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/MANIFEST.in +0 -0
  12. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/README.md +0 -0
  13. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/__init__.py +0 -0
  14. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/cache_manager.py +0 -0
  15. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/hooks/pre-commit +0 -0
  16. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/hooks_installer.py +0 -0
  17. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/.DS_Store +0 -0
  18. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/config/config.css +0 -0
  19. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/config/config.js +0 -0
  20. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/core/core.css +0 -0
  21. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/core/default.config.js +0 -0
  22. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/core/md5.min.js +0 -0
  23. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/core/timeago.full.min.js +0 -0
  24. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/core/timeago.min.js +0 -0
  25. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/core/utils.js +0 -0
  26. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/fonts/material-icons.css +0 -0
  27. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/fonts/materialicons.woff2 +0 -0
  28. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/templates/recently_updated_detail.html +0 -0
  29. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/templates/recently_updated_grid.html +0 -0
  30. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/templates/recently_updated_group.html +0 -0
  31. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/templates/recently_updated_list.html +0 -0
  32. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/tippy/backdrop.css +0 -0
  33. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/tippy/light.css +0 -0
  34. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/tippy/material.css +0 -0
  35. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/tippy/popper.min.js +0 -0
  36. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/tippy/scale.css +0 -0
  37. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/tippy/shift-away.css +0 -0
  38. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/tippy/tippy.css +0 -0
  39. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates/static/tippy/tippy.umd.min.js +0 -0
  40. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates.egg-info/dependency_links.txt +0 -0
  41. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates.egg-info/entry_points.txt +0 -0
  42. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates.egg-info/requires.txt +0 -0
  43. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/mkdocs_document_dates.egg-info/top_level.txt +0 -0
  44. {mkdocs_document_dates-3.8.9 → mkdocs_document_dates-3.9.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocs-document-dates
3
- Version: 3.8.9
3
+ Version: 3.9.0
4
4
  Summary: A new generation MkDocs plugin for displaying exact creation date, last updated date, authors, email of documents
5
5
  Author-email: Aaron Wang <aaronwqt@gmail.com>
6
6
  License-Expression: MIT
@@ -132,6 +132,11 @@ class DocumentDatesPlugin(BasePlugin):
132
132
  for js_file in js_core_files:
133
133
  config['extra_javascript'].append(f'assets/document_dates/tippy/{js_file}')
134
134
 
135
+ # Shared text-avatar helper must be available before the core runtime.
136
+ avatar_script = 'assets/document_dates/core/avatar.js'
137
+ if not any(str(item) == avatar_script for item in config['extra_javascript']):
138
+ config['extra_javascript'].append(avatar_script)
139
+
135
140
  # Plugin JS
136
141
  config['extra_javascript'].extend([
137
142
  'assets/document_dates/core/md5.min.js',
@@ -0,0 +1,50 @@
1
+ /* Shared text-avatar helpers used by Blog and Document Dates. */
2
+ (() => {
3
+ function isLatin(name) {
4
+ return /^[A-Za-z\s]+$/.test(name.trim());
5
+ }
6
+
7
+ function extractInitials(name) {
8
+ name = name.trim();
9
+ if (!name) return "?";
10
+ if (isLatin(name)) {
11
+ const parts = name.toUpperCase().split(/\s+/).filter(Boolean);
12
+ return parts.length >= 2
13
+ ? parts[0][0] + parts[parts.length - 1][0]
14
+ : parts[0][0];
15
+ }
16
+ return name[0];
17
+ }
18
+
19
+ function nameToHSL(name, saturation = 50, lightness = 55) {
20
+ let hash = 0;
21
+ for (let i = 0; i < name.length; i++) {
22
+ hash = name.charCodeAt(i) + ((hash << 5) - hash);
23
+ }
24
+ return `hsl(${hash % 360}, ${saturation}%, ${lightness}%)`;
25
+ }
26
+
27
+ function renderInitials(root = document) {
28
+ root.querySelectorAll(".avatar-wrapper").forEach(wrapper => {
29
+ const name = wrapper.dataset.name || "";
30
+ const text = wrapper.querySelector(".avatar-text");
31
+ if (!text) return;
32
+ text.textContent = extractInitials(name);
33
+ text.style.backgroundColor = nameToHSL(name);
34
+ });
35
+ }
36
+
37
+ window.ddAvatar = Object.freeze({
38
+ extractInitials,
39
+ nameToHSL,
40
+ renderInitials
41
+ });
42
+
43
+ if (window.document$ && !window.document$.isStopped) {
44
+ window.document$.subscribe(() => renderInitials());
45
+ } else if (document.readyState === "loading") {
46
+ document.addEventListener("DOMContentLoaded", () => renderInitials());
47
+ } else {
48
+ renderInitials();
49
+ }
50
+ })();
@@ -1,38 +1,10 @@
1
1
  /*
2
2
  1.加载头像
3
3
  */
4
- function isLatin(name) {
5
- return /^[A-Za-z\s]+$/.test(name.trim());
6
- }
7
- function extractInitials(name) {
8
- name = name.trim();
9
- if (!name) return '?';
10
- if (isLatin(name)) {
11
- const parts = name.toUpperCase().split(/\s+/).filter(Boolean);
12
- return parts.length >= 2 ? parts[0][0] + parts[parts.length - 1][0] : parts[0][0];
13
- } else {
14
- return name[0];
15
- }
16
- }
17
- function nameToHSL(name, s = 50, l = 55) {
18
- let hash = 0;
19
- for (let i = 0; i < name.length; i++) {
20
- hash = name.charCodeAt(i) + ((hash << 5) - hash);
21
- }
22
- const hue = hash % 360;
23
- return `hsl(${hue}, ${s}%, ${l}%)`;
24
- }
25
-
26
4
  function loadAvatars() {
27
- document.querySelectorAll('.avatar-wrapper').forEach(wrapper => {
28
- const name = wrapper.dataset.name || '';
29
- const initials = extractInitials(name);
30
- const bgColor = nameToHSL(name);
31
-
32
- const textEl = wrapper.querySelector('.avatar-text');
33
- textEl.textContent = initials;
34
- textEl.style.backgroundColor = bgColor;
5
+ if (window.ddAvatar) window.ddAvatar.renderInitials(document);
35
6
 
7
+ document.querySelectorAll('.avatar-wrapper').forEach(wrapper => {
36
8
  const imgEl = wrapper.querySelector('img.avatar');
37
9
  if (imgEl) {
38
10
  const urls = [];
@@ -433,6 +405,7 @@ function initLayoutSwitcher() {
433
405
  */
434
406
  let datesAutoWrapObserver = null;
435
407
  function initPluginFeatures() {
408
+ if (window.ddAvatar) window.ddAvatar.renderInitials(document);
436
409
  tippyManager.initialize();
437
410
  processDataLoading();
438
411
  initLayoutSwitcher();
@@ -21,10 +21,19 @@ DEFAULT_WPM = 240
21
21
  DEFAULT_WPM_CJK = 480
22
22
 
23
23
  def load_dates_and_authors(docs_dir_path: Path, files: Files):
24
+ docs_dir_path = Path(docs_dir_path).resolve()
24
25
 
25
26
  # git 创建日期
26
27
  created_data = load_git_metadata(docs_dir_path)
27
28
 
29
+ # Submodule files are gitlinks in the parent repository, so load their
30
+ # history from each initialized submodule and map it back to docs-relative paths.
31
+ submodule_roots = _load_initialized_submodule_roots(docs_dir_path)
32
+ for submodule_root in submodule_roots:
33
+ prefix = submodule_root.relative_to(docs_dir_path).as_posix().rstrip('/')
34
+ for rel_path, metadata in load_git_metadata(submodule_root).items():
35
+ created_data[f"{prefix}/{rel_path}"] = metadata
36
+
28
37
  # 覆盖 jsonl 创建日期
29
38
  jsonl_cache_file = docs_dir_path / '.dates_cache.jsonl'
30
39
  if jsonl_cache_file.exists():
@@ -35,6 +44,10 @@ def load_dates_and_authors(docs_dir_path: Path, files: Files):
35
44
 
36
45
  # git 更新日期
37
46
  updated_data = load_git_last_updated_dates(docs_dir_path)
47
+ for submodule_root in submodule_roots:
48
+ prefix = submodule_root.relative_to(docs_dir_path).as_posix().rstrip('/')
49
+ for rel_path, timestamp in load_git_last_updated_dates(submodule_root).items():
50
+ updated_data[f"{prefix}/{rel_path}"] = timestamp
38
51
 
39
52
  for file in files:
40
53
  if file.inclusion.is_excluded():
@@ -58,6 +71,29 @@ def load_dates_and_authors(docs_dir_path: Path, files: Files):
58
71
 
59
72
  return created_data
60
73
 
74
+
75
+ def _load_initialized_submodule_roots(docs_dir_path: Path):
76
+ try:
77
+ output = subprocess.check_output(
78
+ ['git', 'submodule', 'foreach', '--quiet', '--recursive', 'git rev-parse --show-toplevel'],
79
+ cwd=docs_dir_path,
80
+ encoding='utf-8',
81
+ stderr=subprocess.DEVNULL,
82
+ )
83
+ except (OSError, subprocess.CalledProcessError):
84
+ return []
85
+
86
+ roots = []
87
+ for line in output.splitlines():
88
+ try:
89
+ root = Path(line).resolve()
90
+ root.relative_to(docs_dir_path)
91
+ except (OSError, ValueError):
92
+ continue
93
+ if root.is_dir():
94
+ roots.append(root)
95
+ return roots
96
+
61
97
  def compile_exclude_patterns(exclude_list):
62
98
  if not exclude_list:
63
99
  return []
@@ -153,10 +189,11 @@ def parse_commit_authors(name, email, body, git_root: Path = None, mailmap_cache
153
189
  def load_git_metadata(docs_dir_path: Path):
154
190
  dates_cache = {}
155
191
  try:
192
+ docs_dir_path = Path(docs_dir_path).resolve()
156
193
  git_root = Path(subprocess.check_output(
157
194
  ['git', 'rev-parse', '--show-toplevel'],
158
195
  cwd=docs_dir_path, encoding='utf-8'
159
- ).strip())
196
+ ).strip()).resolve()
160
197
  rel_docs_path = docs_dir_path.relative_to(git_root)
161
198
 
162
199
  relative_arg = (
@@ -222,10 +259,11 @@ def load_git_metadata(docs_dir_path: Path):
222
259
  def load_git_last_updated_dates(docs_dir_path: Path):
223
260
  doc_mtime_map = {}
224
261
  try:
262
+ docs_dir_path = Path(docs_dir_path).resolve()
225
263
  git_root = Path(subprocess.check_output(
226
264
  ['git', 'rev-parse', '--show-toplevel'],
227
265
  cwd=docs_dir_path, encoding='utf-8'
228
- ).strip())
266
+ ).strip()).resolve()
229
267
  rel_docs_path = docs_dir_path.relative_to(git_root)
230
268
 
231
269
  relative_arg = (
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocs-document-dates
3
- Version: 3.8.9
3
+ Version: 3.9.0
4
4
  Summary: A new generation MkDocs plugin for displaying exact creation date, last updated date, authors, email of documents
5
5
  Author-email: Aaron Wang <aaronwqt@gmail.com>
6
6
  License-Expression: MIT
@@ -18,6 +18,7 @@ mkdocs_document_dates/hooks/pre-commit
18
18
  mkdocs_document_dates/static/.DS_Store
19
19
  mkdocs_document_dates/static/config/config.css
20
20
  mkdocs_document_dates/static/config/config.js
21
+ mkdocs_document_dates/static/core/avatar.js
21
22
  mkdocs_document_dates/static/core/core.css
22
23
  mkdocs_document_dates/static/core/core.js
23
24
  mkdocs_document_dates/static/core/default.config.js
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "mkdocs-document-dates"
7
- version = "3.8.9"
7
+ version = "3.9.0"
8
8
  description = "A new generation MkDocs plugin for displaying exact creation date, last updated date, authors, email of documents"
9
9
  readme = { file = "README.md", content-type = "text/markdown" }
10
10
  requires-python = ">=3.7"
@@ -4,7 +4,7 @@ from setuptools import find_packages, setup
4
4
  def legacy_setup():
5
5
  setup(
6
6
  name="mkdocs-document-dates",
7
- version="3.8.9",
7
+ version="3.9.0",
8
8
  author="Aaron Wang",
9
9
  author_email="aaronwqt@gmail.com",
10
10
  license="MIT",