mkdocs-document-dates 3.8.6__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.6/mkdocs_document_dates.egg-info → mkdocs_document_dates-3.8.7}/PKG-INFO +1 -5
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/README.md +0 -4
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/plugin.py +8 -2
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/utils.py +9 -11
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7/mkdocs_document_dates.egg-info}/PKG-INFO +1 -5
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/pyproject.toml +1 -1
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/setup.py +1 -1
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/LICENSE +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/MANIFEST.in +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/__init__.py +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/cache_manager.py +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/hooks/pre-commit +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/hooks_installer.py +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/.DS_Store +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/config/config.css +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/config/config.js +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/core/core.css +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/core/core.js +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/core/default.config.js +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/core/md5.min.js +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/core/timeago.full.min.js +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/core/timeago.min.js +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/core/utils.js +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/fonts/material-icons.css +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/fonts/materialicons.woff2 +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/templates/recently_updated_detail.html +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/templates/recently_updated_grid.html +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/templates/recently_updated_group.html +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/templates/recently_updated_list.html +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/tippy/backdrop.css +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/tippy/light.css +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/tippy/material.css +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/tippy/popper.min.js +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/tippy/scale.css +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/tippy/shift-away.css +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/tippy/tippy.css +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/static/tippy/tippy.umd.min.js +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates.egg-info/SOURCES.txt +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates.egg-info/dependency_links.txt +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates.egg-info/entry_points.txt +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates.egg-info/requires.txt +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates.egg-info/top_level.txt +0 -0
- {mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/setup.cfg +0 -0
{mkdocs_document_dates-3.8.6/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
|
|
|
@@ -219,9 +221,13 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
219
221
|
base_path = urlparse(site_url).path.rstrip("/")
|
|
220
222
|
prefix = f"{base_path}/" if base_path else "/"
|
|
221
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
|
+
|
|
222
228
|
# 获取最近更新的文档数据
|
|
223
229
|
recent_exclude_patterns = compile_exclude_patterns(exclude_list)
|
|
224
|
-
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)
|
|
225
231
|
|
|
226
232
|
# 将数据注入到 config['extra'] 中供全局访问
|
|
227
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 创建日期
|
|
@@ -230,7 +233,7 @@ def load_git_last_updated_dates(docs_dir_path: Path):
|
|
|
230
233
|
return doc_mtime_map
|
|
231
234
|
|
|
232
235
|
# 建议在 on_page_markdown 之后的全局事件中调用,因为需要读取 page.meta 中的信息
|
|
233
|
-
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):
|
|
234
237
|
recently_updated_results = []
|
|
235
238
|
if recent_enable:
|
|
236
239
|
files_meta = []
|
|
@@ -262,7 +265,7 @@ def get_recently_updated_files(existing_dates: dict, files: Files, exclude_list:
|
|
|
262
265
|
cover = prefix + cover.lstrip('/')
|
|
263
266
|
# authors = file.page.meta.document_dates.authors
|
|
264
267
|
if file.page.file:
|
|
265
|
-
|
|
268
|
+
readtime, summary = analyze_markdown(file.page.file.content_string, wpm, wpm_cjk)
|
|
266
269
|
|
|
267
270
|
meta_readtime = int((file.page.meta.get('readtime') or 0) if file.page else 0)
|
|
268
271
|
readtime = meta_readtime if meta_readtime > 0 else readtime
|
|
@@ -360,9 +363,6 @@ def write_jsonl_cache(jsonl_file: Path, dates_cache, tracked_files):
|
|
|
360
363
|
# - Supports mixed-language content (e.g. English + CJK)
|
|
361
364
|
# ==================================================
|
|
362
365
|
|
|
363
|
-
# ===== Extract Readtime =====
|
|
364
|
-
DEFAULT_WPM = 240
|
|
365
|
-
|
|
366
366
|
# Match Unicode "words" for space-delimited languages (English, Spanish, French, German, Russian, etc.)
|
|
367
367
|
# CJK characters also match \w in Python, so they are removed before applying this regex to avoid double counting
|
|
368
368
|
WORD_RE = re.compile(r"\w+", re.UNICODE)
|
|
@@ -434,7 +434,7 @@ BRACE_RE = re.compile(r"\{[^}]*\}")
|
|
|
434
434
|
MD_SYNTAX_RE = re.compile(r"[`*_#]+")
|
|
435
435
|
|
|
436
436
|
|
|
437
|
-
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]:
|
|
438
438
|
# ---------- for Readtime ----------
|
|
439
439
|
words = 0
|
|
440
440
|
cjk = 0
|
|
@@ -600,15 +600,13 @@ def analyze_markdown(md: str) -> list:
|
|
|
600
600
|
# ===============================
|
|
601
601
|
# compute read time
|
|
602
602
|
# ===============================
|
|
603
|
-
|
|
604
|
-
seconds = math.ceil(units / DEFAULT_WPM * 60)
|
|
605
|
-
|
|
603
|
+
seconds = math.ceil((words / readtime_wpm + cjk / readtime_wpm_cjk) * 60)
|
|
606
604
|
seconds += table_rows * 2
|
|
607
605
|
seconds += code_rows
|
|
608
606
|
seconds += math_blocks * 4
|
|
609
607
|
seconds += images * 2
|
|
610
608
|
|
|
611
|
-
summary = MD_SYNTAX_RE.sub("", " ".join(summary_lines)).strip()
|
|
612
609
|
minutes = max(1, math.ceil(seconds / 60))
|
|
610
|
+
summary = MD_SYNTAX_RE.sub("", " ".join(summary_lines)).strip()
|
|
613
611
|
|
|
614
|
-
return
|
|
612
|
+
return minutes, summary
|
{mkdocs_document_dates-3.8.6 → 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.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/__init__.py
RENAMED
|
File without changes
|
{mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/cache_manager.py
RENAMED
|
File without changes
|
{mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/hooks/pre-commit
RENAMED
|
File without changes
|
{mkdocs_document_dates-3.8.6 → mkdocs_document_dates-3.8.7}/mkdocs_document_dates/hooks_installer.py
RENAMED
|
File without changes
|
{mkdocs_document_dates-3.8.6 → 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
|