mkdocs-document-dates 2.3.2__tar.gz → 2.3.5__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 (28) hide show
  1. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/PKG-INFO +11 -4
  2. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/README.md +8 -2
  3. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates/__init__.py +0 -2
  4. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates/plugin.py +21 -6
  5. mkdocs_document_dates-2.3.5/mkdocs_document_dates/styles.py +42 -0
  6. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates.egg-info/PKG-INFO +11 -4
  7. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/setup.py +1 -1
  8. mkdocs_document_dates-2.3.2/mkdocs_document_dates/styles.py +0 -27
  9. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/LICENSE +0 -0
  10. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates/hooks/pre-commit +0 -0
  11. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates/hooks_installer.py +0 -0
  12. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates/lang/__init__.py +0 -0
  13. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates/lang/ar.py +0 -0
  14. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates/lang/de.py +0 -0
  15. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates/lang/en.py +0 -0
  16. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates/lang/es.py +0 -0
  17. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates/lang/fr.py +0 -0
  18. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates/lang/ja.py +0 -0
  19. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates/lang/ko.py +0 -0
  20. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates/lang/ru.py +0 -0
  21. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates/lang/zh.py +0 -0
  22. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates/lang/zh_tw.py +0 -0
  23. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates.egg-info/SOURCES.txt +0 -0
  24. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates.egg-info/dependency_links.txt +0 -0
  25. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates.egg-info/entry_points.txt +0 -0
  26. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates.egg-info/requires.txt +0 -0
  27. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/mkdocs_document_dates.egg-info/top_level.txt +0 -0
  28. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: mkdocs-document-dates
3
- Version: 2.3.2
3
+ Version: 2.3.5
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
@@ -16,6 +16,7 @@ Dynamic: classifier
16
16
  Dynamic: description
17
17
  Dynamic: description-content-type
18
18
  Dynamic: home-page
19
+ Dynamic: license-file
19
20
  Dynamic: requires-dist
20
21
  Dynamic: requires-python
21
22
  Dynamic: summary
@@ -36,7 +37,8 @@ A MkDocs plugin for displaying <mark>accurate</mark> document creation and last
36
37
  - Cross-platform support (Windows, macOS, Linux)
37
38
  - Support for multiple time formats (date, datetime, timeago)
38
39
  - Flexible display position (top or bottom)
39
- - Support for document exclusion
40
+ - Support for customizing display styles (CSS)
41
+ - Support for document exclusion mode
40
42
  - Material Design icons, Elegant styling
41
43
  - Lightweight with no extra dependencies
42
44
  - Multi-language support
@@ -86,7 +88,12 @@ modified: 2025-02-23
86
88
  # Document Title
87
89
  ```
88
90
 
91
+ - `created` can be replaced by any of the following fields: `created, date, creation_date, created_at, date_created`
92
+ - `modified` can be replaced by any of the following fields: `modified, updated, last_modified, updated_at, date_modified, last_update`
89
93
 
94
+ ## Custom Display Styles (CSS)
95
+
96
+ Simply modify the code in the file `docs/assets/document_dates.css`
90
97
 
91
98
  ## Configuration Options
92
99
 
@@ -105,7 +112,7 @@ modified: 2025-02-23
105
112
  - **exclude** : File exclusion list (default: [] )
106
113
  - Supports glob patterns, e.g., ["private/\*", "temp.md", "drafts/\*.md"]
107
114
 
108
- ## Notes
115
+ ## Tips
109
116
 
110
117
  - It still works when using CI/CD build systems (e.g. Github Actions), used a cache file `.dates_cache.json` to solve this problem:
111
118
  1. First, you can configure the workflow like this (penultimate line) in your .github/workflows/ci.yml:
@@ -14,7 +14,8 @@ A MkDocs plugin for displaying <mark>accurate</mark> document creation and last
14
14
  - Cross-platform support (Windows, macOS, Linux)
15
15
  - Support for multiple time formats (date, datetime, timeago)
16
16
  - Flexible display position (top or bottom)
17
- - Support for document exclusion
17
+ - Support for customizing display styles (CSS)
18
+ - Support for document exclusion mode
18
19
  - Material Design icons, Elegant styling
19
20
  - Lightweight with no extra dependencies
20
21
  - Multi-language support
@@ -64,7 +65,12 @@ modified: 2025-02-23
64
65
  # Document Title
65
66
  ```
66
67
 
68
+ - `created` can be replaced by any of the following fields: `created, date, creation_date, created_at, date_created`
69
+ - `modified` can be replaced by any of the following fields: `modified, updated, last_modified, updated_at, date_modified, last_update`
67
70
 
71
+ ## Custom Display Styles (CSS)
72
+
73
+ Simply modify the code in the file `docs/assets/document_dates.css`
68
74
 
69
75
  ## Configuration Options
70
76
 
@@ -83,7 +89,7 @@ modified: 2025-02-23
83
89
  - **exclude** : File exclusion list (default: [] )
84
90
  - Supports glob patterns, e.g., ["private/\*", "temp.md", "drafts/\*.md"]
85
91
 
86
- ## Notes
92
+ ## Tips
87
93
 
88
94
  - It still works when using CI/CD build systems (e.g. Github Actions), used a cache file `.dates_cache.json` to solve this problem:
89
95
  1. First, you can configure the workflow like this (penultimate line) in your .github/workflows/ci.yml:
@@ -1,7 +1,5 @@
1
1
  """MkDocs Document Dates Plugin."""
2
2
 
3
- __version__ = '2.3.1'
4
-
5
3
  from .hooks_installer import install
6
4
 
7
5
  # 在包被导入时自动执行 hooks 安装
@@ -16,6 +16,8 @@ class DocumentDatesPlugin(BasePlugin):
16
16
  ('time_format', config_options.Type(str, default='%H:%M:%S')),
17
17
  ('position', config_options.Type(str, default='bottom')),
18
18
  ('exclude', config_options.Type(list, default=[])),
19
+ ('created_field_names', config_options.Type(list, default=['created', 'date', 'creation_date', 'created_at', 'date_created'])),
20
+ ('modified_field_names', config_options.Type(list, default=['modified', 'updated', 'last_modified', 'updated_at', 'date_modified', 'last_update'])),
19
21
  )
20
22
 
21
23
  def __init__(self):
@@ -36,10 +38,11 @@ class DocumentDatesPlugin(BasePlugin):
36
38
 
37
39
  # 添加自定义 CSS
38
40
  css_file = Path(config['docs_dir']) / 'assets' / 'document_dates.css'
39
- css_file.parent.mkdir(parents=True, exist_ok=True)
40
- css_file.write_text(self._get_css_content())
41
+ if not css_file.exists():
42
+ css_file.parent.mkdir(parents=True, exist_ok=True)
43
+ css_file.write_text(self._get_css_content())
41
44
  config['extra_css'].append('assets/document_dates.css')
42
-
45
+
43
46
  return config
44
47
 
45
48
  def _get_date_info(self, created, modified):
@@ -48,8 +51,10 @@ class DocumentDatesPlugin(BasePlugin):
48
51
  locale = 'en'
49
52
  t = self.translations[locale]
50
53
 
54
+ position_class = 'document-dates-top' if self.config['position'] == 'top' else 'document-dates-bottom'
55
+
51
56
  return (
52
- f"<div class='document-dates-plugin-wrapper'>"
57
+ f"<div class='document-dates-plugin-wrapper {position_class}'>"
53
58
  f"<div class='document-dates-plugin'>"
54
59
  f"<span title='{t['created_time']}: {created.strftime(self.config['date_format'])}'><span class='material-icons'>add_circle</span>"
55
60
  f"{self._get_formatted_date(created)}</span>"
@@ -122,9 +127,19 @@ class DocumentDatesPlugin(BasePlugin):
122
127
  except ValueError:
123
128
  return False
124
129
 
130
+ def _find_meta_date(self, meta: dict, field_names: list, default_date: datetime) -> datetime:
131
+ """从meta中查找第一个匹配的日期字段"""
132
+ for field in field_names:
133
+ if field in meta:
134
+ result = self._parse_meta_date(meta[field], default_date)
135
+ if result != default_date: # 找到有效日期
136
+ return result
137
+ return default_date
138
+
125
139
  def _process_meta_dates(self, meta: dict, created: datetime, modified: datetime) -> tuple[datetime, datetime]:
126
- result_created = self._parse_meta_date(meta.get('created'), created)
127
- result_modified = self._parse_meta_date(meta.get('modified'), modified)
140
+ """处理meta中的日期字段,支持多种字段名"""
141
+ result_created = self._find_meta_date(meta, self.config['created_field_names'], created)
142
+ result_modified = self._find_meta_date(meta, self.config['modified_field_names'], modified)
128
143
  return result_created, result_modified
129
144
 
130
145
  def _parse_meta_date(self, date_str: str | None, default_date: datetime) -> datetime:
@@ -0,0 +1,42 @@
1
+
2
+ DOCUMENT_DATES_CSS = """
3
+ .document-dates-plugin {
4
+ color: #8e8e8e;
5
+ font-size: 0.75rem;
6
+ padding: 0.2rem 0;
7
+ opacity: 0.7;
8
+ display: flex;
9
+ gap: 1.5rem;
10
+ align-items: center;
11
+ margin-bottom: 0.3rem;
12
+ }
13
+ .document-dates-plugin span {
14
+ display: inline-flex;
15
+ align-items: center;
16
+ gap: 0.3rem;
17
+ }
18
+ .document-dates-plugin .material-icons {
19
+ font-size: 0.9rem;
20
+ opacity: 0.7;
21
+ }
22
+
23
+
24
+ /* top position style */
25
+ .document-dates-plugin-wrapper.document-dates-top {
26
+ margin-top: -1.2rem;
27
+ padding-bottom: 0.3rem;
28
+ border-bottom: 1px solid rgba(0, 0, 0, 0.07);
29
+ }
30
+ /* bottom position style */
31
+ .document-dates-plugin-wrapper.document-dates-bottom {
32
+ margin: 1rem 0;
33
+ padding-bottom: 0.3rem;
34
+ border-bottom: 1px solid rgba(0, 0, 0, 0.07);
35
+ }
36
+
37
+
38
+ /* Hide the footnote divider immediately following the date information with the CSS adjacent sibling selector */
39
+ .document-dates-plugin-wrapper + .footnote hr {
40
+ display: none;
41
+ }
42
+ """
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: mkdocs-document-dates
3
- Version: 2.3.2
3
+ Version: 2.3.5
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
@@ -16,6 +16,7 @@ Dynamic: classifier
16
16
  Dynamic: description
17
17
  Dynamic: description-content-type
18
18
  Dynamic: home-page
19
+ Dynamic: license-file
19
20
  Dynamic: requires-dist
20
21
  Dynamic: requires-python
21
22
  Dynamic: summary
@@ -36,7 +37,8 @@ A MkDocs plugin for displaying <mark>accurate</mark> document creation and last
36
37
  - Cross-platform support (Windows, macOS, Linux)
37
38
  - Support for multiple time formats (date, datetime, timeago)
38
39
  - Flexible display position (top or bottom)
39
- - Support for document exclusion
40
+ - Support for customizing display styles (CSS)
41
+ - Support for document exclusion mode
40
42
  - Material Design icons, Elegant styling
41
43
  - Lightweight with no extra dependencies
42
44
  - Multi-language support
@@ -86,7 +88,12 @@ modified: 2025-02-23
86
88
  # Document Title
87
89
  ```
88
90
 
91
+ - `created` can be replaced by any of the following fields: `created, date, creation_date, created_at, date_created`
92
+ - `modified` can be replaced by any of the following fields: `modified, updated, last_modified, updated_at, date_modified, last_update`
89
93
 
94
+ ## Custom Display Styles (CSS)
95
+
96
+ Simply modify the code in the file `docs/assets/document_dates.css`
90
97
 
91
98
  ## Configuration Options
92
99
 
@@ -105,7 +112,7 @@ modified: 2025-02-23
105
112
  - **exclude** : File exclusion list (default: [] )
106
113
  - Supports glob patterns, e.g., ["private/\*", "temp.md", "drafts/\*.md"]
107
114
 
108
- ## Notes
115
+ ## Tips
109
116
 
110
117
  - It still works when using CI/CD build systems (e.g. Github Actions), used a cache file `.dates_cache.json` to solve this problem:
111
118
  1. First, you can configure the workflow like this (penultimate line) in your .github/workflows/ci.yml:
@@ -7,7 +7,7 @@ try:
7
7
  except FileNotFoundError:
8
8
  long_description = "A MkDocs plugin for displaying accurate document creation and last modification dates."
9
9
 
10
- VERSION = '2.3.2'
10
+ VERSION = '2.3.5'
11
11
 
12
12
  setup(
13
13
  name="mkdocs-document-dates",
@@ -1,27 +0,0 @@
1
-
2
- DOCUMENT_DATES_CSS = """
3
- .document-dates-plugin {
4
- color: #8e8e8e;
5
- font-size: 0.75rem;
6
- padding: 0.2rem 0;
7
- opacity: 0.8;
8
- display: flex;
9
- gap: 1.5rem;
10
- align-items: center;
11
- margin-bottom: 0.3rem;
12
- }
13
- .document-dates-plugin span {
14
- display: inline-flex;
15
- align-items: center;
16
- gap: 0.3rem;
17
- }
18
- .document-dates-plugin .material-icons {
19
- font-size: 0.9rem;
20
- opacity: 0.7;
21
- }
22
- .document-dates-plugin-wrapper {
23
- margin: 0.3rem 0 1rem 0;
24
- border-bottom: 1px solid rgba(0, 0, 0, 0.07);
25
- padding-bottom: 0.5rem;
26
- }
27
- """