mkdocs-document-dates 3.8.5__tar.gz → 3.8.7__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.
- {mkdocs_document_dates-3.8.5/mkdocs_document_dates.egg-info → mkdocs_document_dates-3.8.7}/PKG-INFO +1 -5
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/README.md +0 -4
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/plugin.py +14 -4
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/utils.py +23 -15
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7/mkdocs_document_dates.egg-info}/PKG-INFO +1 -5
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/pyproject.toml +1 -1
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/setup.py +1 -1
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/LICENSE +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/MANIFEST.in +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/__init__.py +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/cache_manager.py +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/hooks/pre-commit +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/hooks_installer.py +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/.DS_Store +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/config/config.css +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/config/config.js +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/core/core.css +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/core/core.js +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/core/default.config.js +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/core/md5.min.js +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/core/timeago.full.min.js +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/core/timeago.min.js +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/core/utils.js +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/fonts/material-icons.css +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/fonts/materialicons.woff2 +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/templates/recently_updated_detail.html +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/templates/recently_updated_grid.html +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/templates/recently_updated_group.html +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/templates/recently_updated_list.html +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/tippy/backdrop.css +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/tippy/light.css +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/tippy/material.css +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/tippy/popper.min.js +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/tippy/scale.css +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/tippy/shift-away.css +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/tippy/tippy.css +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/tippy/tippy.umd.min.js +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates.egg-info/SOURCES.txt +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates.egg-info/dependency_links.txt +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates.egg-info/entry_points.txt +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates.egg-info/requires.txt +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates.egg-info/top_level.txt +0 -0
- {mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/setup.cfg +0 -0
{mkdocs_document_dates-3.8.5/mkdocs_document_dates.egg-info → mkdocs_document_dates-3.8.7}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mkdocs-document-dates
|
|
3
|
-
Version: 3.8.
|
|
3
|
+
Version: 3.8.7
|
|
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
|
|
@@ -102,7 +102,3 @@ Updates have been released that refactor and add a lot of new features, see http
|
|
|
102
102
|
## Chat Group
|
|
103
103
|
|
|
104
104
|
**Discord**: https://discord.gg/cvTfge4AUy
|
|
105
|
-
|
|
106
|
-
**Wechat**:
|
|
107
|
-
|
|
108
|
-
<img src="wechat-group.jpg" width="140" />
|
|
@@ -10,7 +10,7 @@ from mkdocs.structure.pages import Page
|
|
|
10
10
|
from mkdocs.utils import get_relative_url
|
|
11
11
|
from urllib.parse import urlparse
|
|
12
12
|
from babel.dates import format_datetime
|
|
13
|
-
from .utils import compile_exclude_patterns, is_excluded, get_recently_updated_files, load_dates_and_authors
|
|
13
|
+
from .utils import compile_exclude_patterns, is_excluded, get_recently_updated_files, load_dates_and_authors, DEFAULT_WPM, DEFAULT_WPM_CJK
|
|
14
14
|
|
|
15
15
|
logger = logging.getLogger("mkdocs.plugins.document_dates")
|
|
16
16
|
logger.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, CRITICAL
|
|
@@ -38,6 +38,8 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
38
38
|
('show_created', config_options.Type(bool, default=True)),
|
|
39
39
|
('show_updated', config_options.Type(bool, default=True)),
|
|
40
40
|
('show_author', config_options.Choice((True, False, 'text'), default=True)),
|
|
41
|
+
('readtime_wpm', config_options.Type(int, default=DEFAULT_WPM)),
|
|
42
|
+
('readtime_wpm_cjk', config_options.Type(int, default=DEFAULT_WPM_CJK)),
|
|
41
43
|
('recently-updated', config_options.Type((dict, bool), default={}))
|
|
42
44
|
)
|
|
43
45
|
|
|
@@ -189,10 +191,14 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
189
191
|
# 检查是否需要排除
|
|
190
192
|
if is_excluded(rel_path, self._exclude_patterns):
|
|
191
193
|
return markdown
|
|
192
|
-
|
|
194
|
+
|
|
195
|
+
# 增强鲁棒性,碰到异常数据提前返回
|
|
196
|
+
if not created or not updated:
|
|
197
|
+
return markdown
|
|
198
|
+
|
|
193
199
|
# 生成日期和作者信息 HTML
|
|
194
200
|
info_html = self._generate_html_info(page.meta, created, updated, authors)
|
|
195
|
-
|
|
201
|
+
|
|
196
202
|
# 将信息写入 markdown
|
|
197
203
|
return self._insert_date_info(markdown, info_html)
|
|
198
204
|
|
|
@@ -215,9 +221,13 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
215
221
|
base_path = urlparse(site_url).path.rstrip("/")
|
|
216
222
|
prefix = f"{base_path}/" if base_path else "/"
|
|
217
223
|
|
|
224
|
+
# 获取阅读速度 WPM 配置
|
|
225
|
+
wpm = self.config.get('readtime_wpm', DEFAULT_WPM)
|
|
226
|
+
wpm_cjk = self.config.get('readtime_wpm_cjk', DEFAULT_WPM_CJK)
|
|
227
|
+
|
|
218
228
|
# 获取最近更新的文档数据
|
|
219
229
|
recent_exclude_patterns = compile_exclude_patterns(exclude_list)
|
|
220
|
-
recently_updated_docs = get_recently_updated_files(self.data_cached, files, recent_exclude_patterns, limit, self.recent_enable, prefix)
|
|
230
|
+
recently_updated_docs = get_recently_updated_files(self.data_cached, files, recent_exclude_patterns, limit, self.recent_enable, prefix, wpm, wpm_cjk)
|
|
221
231
|
|
|
222
232
|
# 将数据注入到 config['extra'] 中供全局访问
|
|
223
233
|
if not config.get('extra', {}).get("recently_updated_docs", {}):
|
|
@@ -17,6 +17,9 @@ logger = logging.getLogger("mkdocs.plugins.document_dates")
|
|
|
17
17
|
logger.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, CRITICAL
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
DEFAULT_WPM = 240
|
|
21
|
+
DEFAULT_WPM_CJK = 480
|
|
22
|
+
|
|
20
23
|
def load_dates_and_authors(docs_dir_path: Path, files: Files):
|
|
21
24
|
|
|
22
25
|
# git 创建日期
|
|
@@ -128,8 +131,13 @@ def load_git_metadata(docs_dir_path: Path):
|
|
|
128
131
|
['git', 'rev-parse', '--show-toplevel'],
|
|
129
132
|
cwd=docs_dir_path, encoding='utf-8'
|
|
130
133
|
).strip())
|
|
131
|
-
rel_docs_path = docs_dir_path.relative_to(git_root)
|
|
134
|
+
rel_docs_path = docs_dir_path.relative_to(git_root)
|
|
132
135
|
|
|
136
|
+
relative_arg = (
|
|
137
|
+
'--relative'
|
|
138
|
+
if rel_docs_path == Path('.')
|
|
139
|
+
else f'--relative={rel_docs_path.as_posix()}'
|
|
140
|
+
)
|
|
133
141
|
cmd = [
|
|
134
142
|
'git',
|
|
135
143
|
'-c', 'core.quotepath=false',
|
|
@@ -140,7 +148,7 @@ def load_git_metadata(docs_dir_path: Path):
|
|
|
140
148
|
'--name-only',
|
|
141
149
|
'-z',
|
|
142
150
|
'--format=%aN%x1f%aE%x1f%at%x1f%B%x00',
|
|
143
|
-
|
|
151
|
+
relative_arg,
|
|
144
152
|
'--',
|
|
145
153
|
'*.md'
|
|
146
154
|
]
|
|
@@ -192,9 +200,14 @@ def load_git_last_updated_dates(docs_dir_path: Path):
|
|
|
192
200
|
['git', 'rev-parse', '--show-toplevel'],
|
|
193
201
|
cwd=docs_dir_path, encoding='utf-8'
|
|
194
202
|
).strip())
|
|
195
|
-
rel_docs_path = docs_dir_path.relative_to(git_root)
|
|
203
|
+
rel_docs_path = docs_dir_path.relative_to(git_root)
|
|
196
204
|
|
|
197
|
-
|
|
205
|
+
relative_arg = (
|
|
206
|
+
'--relative'
|
|
207
|
+
if rel_docs_path == Path('.')
|
|
208
|
+
else f'--relative={rel_docs_path.as_posix()}'
|
|
209
|
+
)
|
|
210
|
+
cmd = ['git', '-c', 'core.quotepath=false', 'log', '--no-merges', '--use-mailmap', '--format=%aN|%aE|%at', '--name-only', relative_arg, '--', '*.md']
|
|
198
211
|
process = subprocess.run(cmd, cwd=docs_dir_path, capture_output=True, encoding='utf-8')
|
|
199
212
|
if process.returncode == 0:
|
|
200
213
|
result = subprocess.run(
|
|
@@ -220,7 +233,7 @@ def load_git_last_updated_dates(docs_dir_path: Path):
|
|
|
220
233
|
return doc_mtime_map
|
|
221
234
|
|
|
222
235
|
# 建议在 on_page_markdown 之后的全局事件中调用,因为需要读取 page.meta 中的信息
|
|
223
|
-
def get_recently_updated_files(existing_dates: dict, files: Files, exclude_list: list, limit: int = 10, recent_enable: bool = False, prefix: str = ""):
|
|
236
|
+
def get_recently_updated_files(existing_dates: dict, files: Files, exclude_list: list, limit: int = 10, recent_enable: bool = False, prefix: str = "", wpm: int = DEFAULT_WPM, wpm_cjk: int = DEFAULT_WPM_CJK):
|
|
224
237
|
recently_updated_results = []
|
|
225
238
|
if recent_enable:
|
|
226
239
|
files_meta = []
|
|
@@ -252,7 +265,7 @@ def get_recently_updated_files(existing_dates: dict, files: Files, exclude_list:
|
|
|
252
265
|
cover = prefix + cover.lstrip('/')
|
|
253
266
|
# authors = file.page.meta.document_dates.authors
|
|
254
267
|
if file.page.file:
|
|
255
|
-
|
|
268
|
+
readtime, summary = analyze_markdown(file.page.file.content_string, wpm, wpm_cjk)
|
|
256
269
|
|
|
257
270
|
meta_readtime = int((file.page.meta.get('readtime') or 0) if file.page else 0)
|
|
258
271
|
readtime = meta_readtime if meta_readtime > 0 else readtime
|
|
@@ -350,9 +363,6 @@ def write_jsonl_cache(jsonl_file: Path, dates_cache, tracked_files):
|
|
|
350
363
|
# - Supports mixed-language content (e.g. English + CJK)
|
|
351
364
|
# ==================================================
|
|
352
365
|
|
|
353
|
-
# ===== Extract Readtime =====
|
|
354
|
-
DEFAULT_WPM = 240
|
|
355
|
-
|
|
356
366
|
# Match Unicode "words" for space-delimited languages (English, Spanish, French, German, Russian, etc.)
|
|
357
367
|
# CJK characters also match \w in Python, so they are removed before applying this regex to avoid double counting
|
|
358
368
|
WORD_RE = re.compile(r"\w+", re.UNICODE)
|
|
@@ -424,7 +434,7 @@ BRACE_RE = re.compile(r"\{[^}]*\}")
|
|
|
424
434
|
MD_SYNTAX_RE = re.compile(r"[`*_#]+")
|
|
425
435
|
|
|
426
436
|
|
|
427
|
-
def analyze_markdown(md: str) ->
|
|
437
|
+
def analyze_markdown(md: str, readtime_wpm: int = DEFAULT_WPM, readtime_wpm_cjk: int = DEFAULT_WPM_CJK) -> tuple[int, str]:
|
|
428
438
|
# ---------- for Readtime ----------
|
|
429
439
|
words = 0
|
|
430
440
|
cjk = 0
|
|
@@ -590,15 +600,13 @@ def analyze_markdown(md: str) -> list:
|
|
|
590
600
|
# ===============================
|
|
591
601
|
# compute read time
|
|
592
602
|
# ===============================
|
|
593
|
-
|
|
594
|
-
seconds = math.ceil(units / DEFAULT_WPM * 60)
|
|
595
|
-
|
|
603
|
+
seconds = math.ceil((words / readtime_wpm + cjk / readtime_wpm_cjk) * 60)
|
|
596
604
|
seconds += table_rows * 2
|
|
597
605
|
seconds += code_rows
|
|
598
606
|
seconds += math_blocks * 4
|
|
599
607
|
seconds += images * 2
|
|
600
608
|
|
|
601
|
-
summary = MD_SYNTAX_RE.sub("", " ".join(summary_lines)).strip()
|
|
602
609
|
minutes = max(1, math.ceil(seconds / 60))
|
|
610
|
+
summary = MD_SYNTAX_RE.sub("", " ".join(summary_lines)).strip()
|
|
603
611
|
|
|
604
|
-
return
|
|
612
|
+
return minutes, summary
|
{mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7/mkdocs_document_dates.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mkdocs-document-dates
|
|
3
|
-
Version: 3.8.
|
|
3
|
+
Version: 3.8.7
|
|
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
|
|
@@ -102,7 +102,3 @@ Updates have been released that refactor and add a lot of new features, see http
|
|
|
102
102
|
## Chat Group
|
|
103
103
|
|
|
104
104
|
**Discord**: https://discord.gg/cvTfge4AUy
|
|
105
|
-
|
|
106
|
-
**Wechat**:
|
|
107
|
-
|
|
108
|
-
<img src="wechat-group.jpg" width="140" />
|
|
@@ -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
|
+
version = "3.8.7"
|
|
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"
|
|
File without changes
|
|
File without changes
|
{mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/__init__.py
RENAMED
|
File without changes
|
{mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/cache_manager.py
RENAMED
|
File without changes
|
{mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/hooks/pre-commit
RENAMED
|
File without changes
|
{mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/hooks_installer.py
RENAMED
|
File without changes
|
{mkdocs_document_dates-3.8.5 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/.DS_Store
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|