Skip to content

Commit ab88e1f

Browse files
Prepare for 1.1.1
1 parent 578b752 commit ab88e1f

File tree

8 files changed

+61
-10
lines changed

8 files changed

+61
-10
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
strategy:
2727
fail-fast: false
2828
matrix:
29-
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
29+
python-version: [3.9, "3.10", "3.11", "3.12", "3.13"]
3030

3131
steps:
3232
- uses: actions/checkout@v1
@@ -103,18 +103,18 @@ jobs:
103103
104104
- name: Install distribution dependencies
105105
run: pip install build
106-
if: matrix.python-version == '3.11'
106+
if: matrix.python-version == '3.12'
107107

108108
- name: Create distribution package
109109
run: python -m build
110-
if: matrix.python-version == '3.11'
110+
if: matrix.python-version == '3.12'
111111

112112
- name: Upload distribution package
113113
uses: actions/upload-artifact@v4
114114
with:
115115
name: dist-${{ matrix.os }}-${{ matrix.python-version }}
116116
path: dist
117-
if: matrix.python-version == '3.11'
117+
if: matrix.python-version == '3.12'
118118

119119
publish:
120120
runs-on: ubuntu-latest
@@ -128,10 +128,10 @@ jobs:
128128
merge-multiple: true
129129
path: dist
130130

131-
- name: Use Python 3.11
131+
- name: Use Python 3.12
132132
uses: actions/setup-python@v1
133133
with:
134-
python-version: '3.11'
134+
python-version: '3.12'
135135

136136
- name: Install dependencies
137137
run: |

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ dist/
1717

1818
# for downloaded dependencies
1919
deps/
20+
.local

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,29 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.1.1] 2025-04-18 🌵
9+
10+
- Improve the `contribs` plugin to not pollute the logs with
11+
`dateutil.parser.ParseError` while working on a new file that is not
12+
committed in Git, yet.
13+
- Add the possibility to enable and disable the `contribs` plugin by env
14+
variable, through plugin configuration. To use, specify the following
15+
setting:
16+
17+
```yaml
18+
- neoteroi.contribs:
19+
enabled_by_env: "GIT_CONTRIBS_ON" # Use the name you wish here for the env var
20+
```
21+
22+
- When `enabled_by_env` is not empty, the Git contributors plugin is only
23+
enabled if such variable exists and its value is a value in `{"1", "true"}`
24+
(case insensitive). This is useful to disable the plugin by default during
25+
local development, and enable it only during an automated build that builds
26+
the documentation for publishing. The rationale for this setting is that
27+
this plugin has an heavy impact on the build performance as it uses the Git
28+
CLI to obtain the list of contributors who worked on each page.
29+
- Remove Python 3.8 from the build matrix, add 3.13.
30+
831
## [1.1.0] 2024-08-10 🐢
932

1033
- Improve the `cards` plugin to automatically use cards' titles for the `alt`

neoteroi/mkdocs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.1.0"
1+
__version__ = "1.1.1"

neoteroi/mkdocs/contribs/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""
99

1010
import logging
11+
import os
1112
from datetime import datetime
1213
from fnmatch import fnmatch
1314
from pathlib import Path
@@ -60,6 +61,7 @@ class ContribsPlugin(BasePlugin):
6061
("contributors", c.Type(list, default=[])),
6162
("show_last_modified_time", c.Type(bool, default=True)),
6263
("show_contributors_title", c.Type(bool, default=False)),
64+
("enabled_by_env", c.Type(str, default="")),
6365
("exclude", c.Type(list, default=[])),
6466
)
6567

@@ -182,7 +184,25 @@ def _is_ignored_page(self, page: Page) -> bool:
182184
for ignored_pattern in self.config["exclude"]
183185
)
184186

187+
def _is_enabled_by_env(self):
188+
"""
189+
Returns a value indicating if the plugin is enabled by env variable
190+
(default True if there is no env variable).
191+
If the user specified in the plugin configuration an env variable that controls
192+
if the plugin is enabled, read the env variable by that name and check if its
193+
value is (ci) {"1", "true"} to continue.
194+
"""
195+
enabled_by_env = self.config.get("enabled_by_env")
196+
if enabled_by_env:
197+
env_var = os.environ.get(enabled_by_env)
198+
if env_var is None:
199+
return False
200+
return env_var.lower() in {"1", "true"}
201+
return True # enabled since the user did not specify `enabled_by_env` setting
202+
185203
def on_page_markdown(self, markdown, *args, **kwargs):
204+
if not self._is_enabled_by_env():
205+
return
186206
if self._is_ignored_page(kwargs["page"]):
187207
return markdown
188208
try:

neoteroi/mkdocs/contribs/git.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pathlib import Path
1212
from typing import Iterable, List, Tuple
1313

14-
from dateutil.parser import parse as parse_date
14+
from dateutil.parser import parse as parse_date, ParserError
1515

1616
from neoteroi.mkdocs.contribs.domain import ContributionsReader, Contributor
1717

@@ -70,4 +70,7 @@ def get_last_modified_date(self, file_path: Path) -> datetime:
7070
["git", "log", "-1", "--pretty=format:%ci", str(file_path)]
7171
)
7272
)
73-
return parse_date(result)
73+
try:
74+
return parse_date(result)
75+
except ParserError:
76+
return datetime.min

neoteroi/mkdocs/contribs/html.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ def contribution_stats_to_element(
3131
) -> etree.Element:
3232
element = etree.Element("div", {"class": "nt-contribs"})
3333

34-
if options.show_last_modified_time:
34+
if (
35+
options.show_last_modified_time
36+
and last_commit_date.replace(tzinfo=None) > datetime.min
37+
):
3538
last_modified_time = etree.SubElement(
3639
element,
3740
"p",

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ classifiers = [
1919
"Programming Language :: Python :: 3.10",
2020
"Programming Language :: Python :: 3.11",
2121
"Programming Language :: Python :: 3.12",
22+
"Programming Language :: Python :: 3.13",
2223
"Operating System :: OS Independent",
2324
]
2425
keywords = [

0 commit comments

Comments
 (0)