mkdocs-document-dates 3.8.7__tar.gz → 3.8.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 (43) hide show
  1. {mkdocs_document_dates-3.8.7/mkdocs_document_dates.egg-info → mkdocs_document_dates-3.8.8}/PKG-INFO +3 -3
  2. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/README.md +2 -2
  3. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/cache_manager.py +1 -1
  4. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/plugin.py +21 -6
  5. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/templates/recently_updated_detail.html +4 -4
  6. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/templates/recently_updated_grid.html +4 -4
  7. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/templates/recently_updated_group.html +5 -5
  8. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/utils.py +31 -5
  9. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8/mkdocs_document_dates.egg-info}/PKG-INFO +3 -3
  10. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/pyproject.toml +1 -1
  11. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/setup.py +1 -1
  12. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/LICENSE +0 -0
  13. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/MANIFEST.in +0 -0
  14. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/__init__.py +0 -0
  15. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/hooks/pre-commit +0 -0
  16. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/hooks_installer.py +0 -0
  17. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/.DS_Store +0 -0
  18. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/config/config.css +0 -0
  19. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/config/config.js +0 -0
  20. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/core/core.css +0 -0
  21. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/core/core.js +0 -0
  22. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/core/default.config.js +0 -0
  23. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/core/md5.min.js +0 -0
  24. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/core/timeago.full.min.js +0 -0
  25. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/core/timeago.min.js +0 -0
  26. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/core/utils.js +0 -0
  27. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/fonts/material-icons.css +0 -0
  28. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/fonts/materialicons.woff2 +0 -0
  29. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/templates/recently_updated_list.html +0 -0
  30. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/tippy/backdrop.css +0 -0
  31. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/tippy/light.css +0 -0
  32. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/tippy/material.css +0 -0
  33. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/tippy/popper.min.js +0 -0
  34. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/tippy/scale.css +0 -0
  35. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/tippy/shift-away.css +0 -0
  36. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/tippy/tippy.css +0 -0
  37. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates/static/tippy/tippy.umd.min.js +0 -0
  38. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates.egg-info/SOURCES.txt +0 -0
  39. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates.egg-info/dependency_links.txt +0 -0
  40. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates.egg-info/entry_points.txt +0 -0
  41. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates.egg-info/requires.txt +0 -0
  42. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/mkdocs_document_dates.egg-info/top_level.txt +0 -0
  43. {mkdocs_document_dates-3.8.7 → mkdocs_document_dates-3.8.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocs-document-dates
3
- Version: 3.8.7
3
+ Version: 3.8.8
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
@@ -25,7 +25,7 @@ English | [简体中文](README_zh.md)
25
25
 
26
26
  A new generation MkDocs plugin for displaying exact **creation date, last updated date, authors, email** of documents
27
27
 
28
- ![render](render.gif)
28
+ ![render](docs/assets/document-dates.gif)
29
29
 
30
30
  ## Features
31
31
 
@@ -90,7 +90,7 @@ In addition to the above basic configuration, the plug-in also provides a wealth
90
90
 
91
91
  See the documentation for details: https://jaywhj.netlify.app/document-dates-en
92
92
 
93
- ![recently-updated](recently-updated-en.gif)
93
+ ![recently-updated](docs/assets/recently-updated-en.gif)
94
94
 
95
95
  ## Other Projects
96
96
 
@@ -6,7 +6,7 @@ English | [简体中文](README_zh.md)
6
6
 
7
7
  A new generation MkDocs plugin for displaying exact **creation date, last updated date, authors, email** of documents
8
8
 
9
- ![render](render.gif)
9
+ ![render](docs/assets/document-dates.gif)
10
10
 
11
11
  ## Features
12
12
 
@@ -71,7 +71,7 @@ In addition to the above basic configuration, the plug-in also provides a wealth
71
71
 
72
72
  See the documentation for details: https://jaywhj.netlify.app/document-dates-en
73
73
 
74
- ![recently-updated](recently-updated-en.gif)
74
+ ![recently-updated](docs/assets/recently-updated-en.gif)
75
75
 
76
76
  ## Other Projects
77
77
 
@@ -88,7 +88,7 @@ def _clean_git_env():
88
88
 
89
89
  return env
90
90
 
91
- def find_mkdocs_projects() -> dict[Path, Path]:
91
+ def find_mkdocs_projects():
92
92
  projects = {}
93
93
 
94
94
  try:
@@ -23,6 +23,8 @@ class Author:
23
23
  self.avatar = avatar
24
24
  self.url = url
25
25
  self.description = description
26
+ for k, v in kwargs.items():
27
+ setattr(self, k, v)
26
28
 
27
29
 
28
30
  class DocumentDatesPlugin(BasePlugin):
@@ -270,11 +272,15 @@ class DocumentDatesPlugin(BasePlugin):
270
272
  with open(file_path, 'r', encoding='utf-8') as f:
271
273
  data = yaml.safe_load(f)
272
274
  for key, info in (data or {}).get('authors', {}).items():
273
- self.authors_yml[key] = Author(**info)
275
+ author_obj = Author(**info)
276
+ self.authors_yml[key] = author_obj
277
+ if author_obj.name and author_obj.name not in self.authors_yml:
278
+ self.authors_yml[author_obj.name] = author_obj
279
+ if author_obj.email and author_obj.email not in self.authors_yml:
280
+ self.authors_yml[author_obj.email] = author_obj
274
281
  except Exception as e:
275
282
  logger.info(f"Error parsing .authors.yml: {e}")
276
283
 
277
-
278
284
  def _render_recently_updated_html(self, env, config, recently_updated_data, summary_lines):
279
285
  # 设置模板加载器
280
286
  template_path = Path(__file__).parent / 'static' / 'templates'
@@ -321,22 +327,31 @@ class DocumentDatesPlugin(BasePlugin):
321
327
  authors_list = self.data_cached.get(rel_path, {}).get('authors', None)
322
328
  if authors_list:
323
329
  authors = []
330
+ seen_names = set()
324
331
  for data in authors_list:
325
- full_author = self.authors_yml.get(data['name'])
332
+ full_author = self.authors_yml.get(data.get('name')) or self.authors_yml.get(data.get('email'))
326
333
  if full_author:
327
- authors.append(self._repair_author(full_author, page.url))
334
+ if getattr(full_author, 'ignore', False) or getattr(full_author, 'exclude', False) or getattr(full_author, 'hidden', False):
335
+ continue
336
+ repaired = self._repair_author(full_author, page.url)
337
+ if repaired.name not in seen_names:
338
+ seen_names.add(repaired.name)
339
+ authors.append(repaired)
328
340
  else:
329
- authors.append(Author(**data))
341
+ if data.get('name') not in seen_names:
342
+ seen_names.add(data.get('name'))
343
+ authors.append(Author(**data))
330
344
  return authors
331
345
 
332
346
  # 2. site_author 或 PC username
333
347
  name = config.get('site_author') or Path.home().name
334
348
  full_author = self.authors_yml.get(name)
335
349
  if full_author:
350
+ if getattr(full_author, 'ignore', False) or getattr(full_author, 'exclude', False) or getattr(full_author, 'hidden', False):
351
+ return []
336
352
  return [self._repair_author(full_author, page.url)]
337
353
  else:
338
354
  return [Author(name=name)]
339
-
340
355
  def _load_meta_author(self, meta, page_url):
341
356
  try:
342
357
  # 匹配 authors 数组
@@ -82,15 +82,15 @@
82
82
  <div>
83
83
  {%- for mtime, rel_path, title, url, cover, summary in recent_docs %}
84
84
  <div class="article-card">
85
- <a class="card-header" href="{{ url }}" target="_blank">
86
- <div class="card-title">{{ title }}</div>
85
+ <a class="card-header" href="{{ url | e }}" target="_blank">
86
+ <div class="card-title">{{ title | e }}</div>
87
87
  <time class="dd-timeago card-date" datetime="{{ mtime }}">{{ mtime[:10] }}</time>
88
88
  </a>
89
89
  <div class="card-body">
90
- <div class="card-summary">{{ summary }}</div>
90
+ <div class="card-summary">{{ summary | e }}</div>
91
91
  {%- if cover %}
92
92
  <div class="card-cover">
93
- <img src="{{ cover }}" alt="{{ title }}">
93
+ <img src="{{ cover | e }}" alt="{{ title | e }}">
94
94
  </div>
95
95
  {%- endif %}
96
96
  </div>
@@ -89,15 +89,15 @@
89
89
  <div class="article-grid">
90
90
  {%- for mtime, rel_path, title, url, cover, summary in recent_docs %}
91
91
  <div class="article-card">
92
- <a class="card-header" href="{{ url }}" target="_blank">
93
- <div class="card-title">{{ title }}</div>
92
+ <a class="card-header" href="{{ url | e }}" target="_blank">
93
+ <div class="card-title">{{ title | e }}</div>
94
94
  <time class="dd-timeago card-date" datetime="{{ mtime }}">{{ mtime[:10] }}</time>
95
95
  </a>
96
96
  <div class="card-body">
97
- <div class="card-summary">{{ summary }}</div>
97
+ <div class="card-summary">{{ summary | e }}</div>
98
98
  {%- if cover %}
99
99
  <div class="card-cover">
100
- <img src="{{ cover }}" alt="{{ title }}">
100
+ <img src="{{ cover | e }}" alt="{{ title | e }}">
101
101
  </div>
102
102
  {%- endif %}
103
103
  </div>
@@ -270,17 +270,17 @@
270
270
  {%- set readtime = doc.readtime | default(0) %}
271
271
  {%- set tags = doc.tags | default([]) %}
272
272
  <div class="article-card">
273
- <a class="card-header" href="{{ url }}" target="_blank">
274
- <div class="card-title">{{ title }}</div>
273
+ <a class="card-header" href="{{ url | e }}" target="_blank">
274
+ <div class="card-title">{{ title | e }}</div>
275
275
  <time class="dd-timeago card-date" datetime="{{ updated_dt }}">{{ updated }}</time>
276
276
  </a>
277
277
  <div class="card-body">
278
278
  {%- if cover %}
279
279
  <div class="card-cover">
280
- <img src="{{ cover }}" alt="{{ title }}">
280
+ <img src="{{ cover | e }}" alt="{{ title | e }}">
281
281
  </div>
282
282
  {%- endif %}
283
- <div class="card-summary">{{ summary }}</div>
283
+ <div class="card-summary">{{ summary | e }}</div>
284
284
  </div>
285
285
 
286
286
  {%- if tags or readtime > 0 %}
@@ -298,7 +298,7 @@
298
298
  {%- if tags %}
299
299
  <div class="md-tags">
300
300
  {%- for tag in tags %}
301
- <span class="md-tag md-tag-icon">{{- tag -}}</span>
301
+ <span class="md-tag md-tag-icon">{{- tag | e -}}</span>
302
302
  {%- endfor %}
303
303
  </div>
304
304
  {%- endif %}
@@ -110,12 +110,38 @@ COAUTHOR_RE = re.compile(
110
110
  r'^Co-authored-by:\s*(.+?) <([^<>]+)>$',
111
111
  re.MULTILINE | re.IGNORECASE
112
112
  )
113
- def parse_commit_authors(name, email, body):
113
+ def check_mailmap(name: str, email: str, git_root: Path = None, cache: dict = None):
114
+ key = (name, email)
115
+ if cache is not None and key in cache:
116
+ return cache[key]
117
+ if git_root:
118
+ try:
119
+ proc = subprocess.run(
120
+ ['git', 'check-mailmap', f'{name} <{email}>'],
121
+ cwd=git_root,
122
+ capture_output=True,
123
+ encoding='utf-8'
124
+ )
125
+ if proc.returncode == 0 and proc.stdout.strip():
126
+ m = re.match(r'^(.*?)\s*<([^<>]+)>$', proc.stdout.strip())
127
+ if m:
128
+ res = (m.group(1).strip(), m.group(2).strip())
129
+ if cache is not None:
130
+ cache[key] = res
131
+ return res
132
+ except Exception as e:
133
+ logger.debug(f"Error checking mailmap for {name} <{email}>: {e}")
134
+ if cache is not None:
135
+ cache[key] = key
136
+ return key
137
+
138
+ def parse_commit_authors(name, email, body, git_root: Path = None, mailmap_cache: dict = None):
139
+ # name/email come from `git log --use-mailmap`; mapping them again can diverge on chained entries
114
140
  authors = [(name, email)]
115
141
  seen = {(name, email)}
116
142
 
117
143
  for co_name, co_email in COAUTHOR_RE.findall(body):
118
- author = (co_name, co_email)
144
+ author = check_mailmap(co_name, co_email, git_root, mailmap_cache)
119
145
  if author in seen:
120
146
  continue
121
147
 
@@ -157,6 +183,7 @@ def load_git_metadata(docs_dir_path: Path):
157
183
  authors_dict = defaultdict(dict)
158
184
  first_commit = {}
159
185
  current_commit = None
186
+ mailmap_cache = {}
160
187
 
161
188
  records = process.stdout.split('\x00')
162
189
  for item in records:
@@ -167,7 +194,7 @@ def load_git_metadata(docs_dir_path: Path):
167
194
  parts = item.split('\x1f', 3)
168
195
  if len(parts) == 4:
169
196
  name, email, created, body = parts
170
- authors = parse_commit_authors(name, email, body)
197
+ authors = parse_commit_authors(name, email, body, git_root, mailmap_cache)
171
198
  current_commit = (authors, int(created))
172
199
  elif item.endswith('.md') and current_commit:
173
200
  authors, created = current_commit
@@ -178,7 +205,6 @@ def load_git_metadata(docs_dir_path: Path):
178
205
  authors_dict[item].setdefault(author, None)
179
206
 
180
207
  first_commit.setdefault(item, created)
181
-
182
208
  # 构建最终的缓存数据
183
209
  for file_path in first_commit:
184
210
  authors_list = [
@@ -434,7 +460,7 @@ BRACE_RE = re.compile(r"\{[^}]*\}")
434
460
  MD_SYNTAX_RE = re.compile(r"[`*_#]+")
435
461
 
436
462
 
437
- def analyze_markdown(md: str, readtime_wpm: int = DEFAULT_WPM, readtime_wpm_cjk: int = DEFAULT_WPM_CJK) -> tuple[int, str]:
463
+ def analyze_markdown(md: str, readtime_wpm: int = DEFAULT_WPM, readtime_wpm_cjk: int = DEFAULT_WPM_CJK):
438
464
  # ---------- for Readtime ----------
439
465
  words = 0
440
466
  cjk = 0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocs-document-dates
3
- Version: 3.8.7
3
+ Version: 3.8.8
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
@@ -25,7 +25,7 @@ English | [简体中文](README_zh.md)
25
25
 
26
26
  A new generation MkDocs plugin for displaying exact **creation date, last updated date, authors, email** of documents
27
27
 
28
- ![render](render.gif)
28
+ ![render](docs/assets/document-dates.gif)
29
29
 
30
30
  ## Features
31
31
 
@@ -90,7 +90,7 @@ In addition to the above basic configuration, the plug-in also provides a wealth
90
90
 
91
91
  See the documentation for details: https://jaywhj.netlify.app/document-dates-en
92
92
 
93
- ![recently-updated](recently-updated-en.gif)
93
+ ![recently-updated](docs/assets/recently-updated-en.gif)
94
94
 
95
95
  ## Other Projects
96
96
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "mkdocs-document-dates"
7
- version = "3.8.7"
7
+ version = "3.8.8"
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.7",
7
+ version="3.8.8",
8
8
  author="Aaron Wang",
9
9
  author_email="aaronwqt@gmail.com",
10
10
  license="MIT",