mkdocs-document-dates 2.3.2__tar.gz → 2.3.3__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 (27) hide show
  1. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/PKG-INFO +5 -3
  2. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/README.md +2 -1
  3. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates/__init__.py +1 -1
  4. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates/plugin.py +14 -2
  5. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates.egg-info/PKG-INFO +5 -3
  6. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/setup.py +1 -1
  7. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/LICENSE +0 -0
  8. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates/hooks/pre-commit +0 -0
  9. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates/hooks_installer.py +0 -0
  10. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates/lang/__init__.py +0 -0
  11. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates/lang/ar.py +0 -0
  12. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates/lang/de.py +0 -0
  13. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates/lang/en.py +0 -0
  14. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates/lang/es.py +0 -0
  15. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates/lang/fr.py +0 -0
  16. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates/lang/ja.py +0 -0
  17. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates/lang/ko.py +0 -0
  18. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates/lang/ru.py +0 -0
  19. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates/lang/zh.py +0 -0
  20. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates/lang/zh_tw.py +0 -0
  21. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates/styles.py +0 -0
  22. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates.egg-info/SOURCES.txt +0 -0
  23. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates.egg-info/dependency_links.txt +0 -0
  24. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates.egg-info/entry_points.txt +0 -0
  25. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates.egg-info/requires.txt +0 -0
  26. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/mkdocs_document_dates.egg-info/top_level.txt +0 -0
  27. {mkdocs_document_dates-2.3.2 → mkdocs_document_dates-2.3.3}/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.3
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
@@ -86,7 +87,8 @@ modified: 2025-02-23
86
87
  # Document Title
87
88
  ```
88
89
 
89
-
90
+ - `created` can be replaced by any of the following fields: `created, date, creation_date, created_at, date_created`
91
+ - `modified` can be replaced by any of the following fields: `modified, updated, last_modified, updated_at, date_modified, last_update`
90
92
 
91
93
  ## Configuration Options
92
94
 
@@ -64,7 +64,8 @@ modified: 2025-02-23
64
64
  # Document Title
65
65
  ```
66
66
 
67
-
67
+ - `created` can be replaced by any of the following fields: `created, date, creation_date, created_at, date_created`
68
+ - `modified` can be replaced by any of the following fields: `modified, updated, last_modified, updated_at, date_modified, last_update`
68
69
 
69
70
  ## Configuration Options
70
71
 
@@ -1,6 +1,6 @@
1
1
  """MkDocs Document Dates Plugin."""
2
2
 
3
- __version__ = '2.3.1'
3
+ __version__ = '2.3.3'
4
4
 
5
5
  from .hooks_installer import install
6
6
 
@@ -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):
@@ -122,9 +124,19 @@ class DocumentDatesPlugin(BasePlugin):
122
124
  except ValueError:
123
125
  return False
124
126
 
127
+ def _find_meta_date(self, meta: dict, field_names: list, default_date: datetime) -> datetime:
128
+ """从meta中查找第一个匹配的日期字段"""
129
+ for field in field_names:
130
+ if field in meta:
131
+ result = self._parse_meta_date(meta[field], default_date)
132
+ if result != default_date: # 找到有效日期
133
+ return result
134
+ return default_date
135
+
125
136
  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)
137
+ """处理meta中的日期字段,支持多种字段名"""
138
+ result_created = self._find_meta_date(meta, self.config['created_field_names'], created)
139
+ result_modified = self._find_meta_date(meta, self.config['modified_field_names'], modified)
128
140
  return result_created, result_modified
129
141
 
130
142
  def _parse_meta_date(self, date_str: str | None, default_date: datetime) -> datetime:
@@ -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.3
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
@@ -86,7 +87,8 @@ modified: 2025-02-23
86
87
  # Document Title
87
88
  ```
88
89
 
89
-
90
+ - `created` can be replaced by any of the following fields: `created, date, creation_date, created_at, date_created`
91
+ - `modified` can be replaced by any of the following fields: `modified, updated, last_modified, updated_at, date_modified, last_update`
90
92
 
91
93
  ## Configuration Options
92
94
 
@@ -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.3'
11
11
 
12
12
  setup(
13
13
  name="mkdocs-document-dates",