Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ plugins:
# Regex string for matching the release name.
autoprocess: True
# Autoprocess the body for user and issue/pull request links
include_prereleases: False
# Include prereleases
enabled: True
# Enable or disable the plugin.
```
Expand All @@ -50,6 +52,7 @@ markdown
github_api_url: <url>
release_template: <jinja2 str>
match: '[0-9+].[0-9+].[0-9]+'
include_prereleases: false
autoprocess: true
```

Expand Down
12 changes: 9 additions & 3 deletions src/mkdocs_github_changelog/get_releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,14 @@
return release


def _process_releases(releases, match: str | None = None, autoprocess: bool = True):
def _process_releases(releases, match: str | None = None, autoprocess: bool = True, include_prerelease: bool = False):

Check failure on line 98 in src/mkdocs_github_changelog/get_releases.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 20 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=djpugh_mkdocs_github_changelog&issues=AZ0q1WqJjqmbgaVRXcou&open=AZ0q1WqJjqmbgaVRXcou&pullRequest=14
selected_releases = []
for release in releases:
# Ignore draft releases:
if release.draft:
continue
if release.prelease and not include_prerelease:
continue
# Convert the published_at to datetime object
if not isinstance(release.published_at, datetime):
if sys.version_info.major >= 3 and sys.version_info.minor < 11:
Expand All @@ -118,7 +123,8 @@
release_template: str | None = RELEASE_TEMPLATE,
github_api_url: str | None = None,
match: str | None = None,
autoprocess: bool | None = True
autoprocess: bool | None = True,
include_prerelease: bool | None = False
):
"""Get the releases from github as a list of rendered markdown strings."""
if github_api_url is not None:
Expand All @@ -130,7 +136,7 @@
releases += page
logger.info(f'Processing releases from github, {len(releases)} found')
jinja_environment = JINJA_ENVIRONMENT_FACTORY.environment
selected_releases = _process_releases(releases, match=match, autoprocess=autoprocess)
selected_releases = _process_releases(releases, match=match, autoprocess=autoprocess, include_prerelease=include_prerelease)
if release_template is None:
release_template = RELEASE_TEMPLATE
logger.info(f'Rendering releases from github, {len(releases)} selected')
Expand Down
2 changes: 2 additions & 0 deletions src/mkdocs_github_changelog/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class PluginConfig(Config):
"""Regex string for matching the rleease name."""
autoprocess = opt.Type(bool, default=True)
"""Autoprocess the release bodies for issue and username links."""
include_prereleases = opt.Type(bool, default=False)
"""Include prereleases."""
enabled = opt.Type(bool, default=True)
"""Enable or disable the plugin."""

Expand Down