From aa62bcc4f6aa42499febeb00e0502cefa4086eb9 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Thu, 7 Dec 2023 11:46:44 +0100 Subject: [PATCH] Merge latests changes from Insiders --- material/plugins/blog/plugin.py | 13 -- material/plugins/group/plugin.py | 4 +- material/templates/partials/source-file.html | 136 ++++++++------ src/plugins/blog/plugin.py | 13 -- src/plugins/group/plugin.py | 4 +- src/templates/partials/source-file.html | 178 ++++++++++++------- 6 files changed, 194 insertions(+), 154 deletions(-) diff --git a/material/plugins/blog/plugin.py b/material/plugins/blog/plugin.py index 4c0f4e7ec0a..472c1aa7c84 100644 --- a/material/plugins/blog/plugin.py +++ b/material/plugins/blog/plugin.py @@ -477,19 +477,6 @@ def _resolve_authors(self, config: MkDocsConfig): # Validate authors and throw if errors occurred errors, warnings = config.validate() - if not config.authors and warnings: - log.warning( - f"Action required: the format of the authors file changed.\n" - f"All authors must now be located under the 'authors' key.\n" - f"Please adjust '{file}' to match:\n" - f"\n" - f"authors:\n" - f" squidfunk:\n" - f" avatar: https://avatars.githubusercontent.com/u/932156\n" - f" description: Creator\n" - f" name: Martin Donath\n" - f"\n" - ) for _, w in warnings: log.warning(w) for _, e in errors: diff --git a/material/plugins/group/plugin.py b/material/plugins/group/plugin.py index b2b334d99a0..e3f4df85d38 100644 --- a/material/plugins/group/plugin.py +++ b/material/plugins/group/plugin.py @@ -53,8 +53,8 @@ def on_startup(self, *, command, dirty): # little hacky, but has huge potential making plugin configuration easier. # There's one little caveat: the `__init__` and `on_startup` methods of the # plugins that are part of the group are called after all other plugins, so - # the `event_priority` decorator for `on_startup` events and is effectively - # useless. However, the `on_startup` event is only intended to set up the + # the `event_priority` decorator for `on_startup` methods is effectively + # useless. However, the `on_startup` method is only intended to set up the # plugin and doesn't receive anything else than the invoked command and # whether we're running a dirty build, so there should be no problems. @event_priority(150) diff --git a/material/templates/partials/source-file.html b/material/templates/partials/source-file.html index becac5dedf4..ea24d77aff3 100644 --- a/material/templates/partials/source-file.html +++ b/material/templates/partials/source-file.html @@ -1,6 +1,82 @@ {#- This file was automatically generated - do not edit -#} +{% macro render_updated(date) %} + + + {% include ".icons/material/clock-edit-outline.svg" %} + + {{ date }} + +{% endmacro %} +{% macro render_created(date) %} + + + {% include ".icons/material/clock-plus-outline.svg" %} + + {{ date }} + +{% endmacro %} +{% macro render_authors(authors) %} + + + {% if authors | length == 1 %} + {% include ".icons/material/account.svg" %} + {% else %} + {% include ".icons/material/account-group.svg" %} + {% endif %} + + + +{% endmacro %} +{% macro render_committers_github(title) %} + + {% include ".icons/material/github.svg" %} + + {{ title }} +{% endmacro %} +{% macro render_committers_gitlab(title) %} + + {% include ".icons/material/gitlab.svg" %} + + {{ title }} +{% endmacro %} +{% macro render_committers(authors) %} + + {% if committers_source == "gitlab" %} + {{ render_committers_gitlab("GitLab") }} + {% else %} + {{ render_committers_github("GitHub") }} + {% endif %} + + +{% endmacro %} {% if page.meta %} {% if page.meta.git_revision_date_localized %} {% set updated = page.meta.git_revision_date_localized %} @@ -14,68 +90,16 @@ {% if updated or created or git_info or committers %} {% endif %} diff --git a/src/plugins/blog/plugin.py b/src/plugins/blog/plugin.py index 4c0f4e7ec0a..472c1aa7c84 100644 --- a/src/plugins/blog/plugin.py +++ b/src/plugins/blog/plugin.py @@ -477,19 +477,6 @@ def _resolve_authors(self, config: MkDocsConfig): # Validate authors and throw if errors occurred errors, warnings = config.validate() - if not config.authors and warnings: - log.warning( - f"Action required: the format of the authors file changed.\n" - f"All authors must now be located under the 'authors' key.\n" - f"Please adjust '{file}' to match:\n" - f"\n" - f"authors:\n" - f" squidfunk:\n" - f" avatar: https://avatars.githubusercontent.com/u/932156\n" - f" description: Creator\n" - f" name: Martin Donath\n" - f"\n" - ) for _, w in warnings: log.warning(w) for _, e in errors: diff --git a/src/plugins/group/plugin.py b/src/plugins/group/plugin.py index b2b334d99a0..e3f4df85d38 100644 --- a/src/plugins/group/plugin.py +++ b/src/plugins/group/plugin.py @@ -53,8 +53,8 @@ def on_startup(self, *, command, dirty): # little hacky, but has huge potential making plugin configuration easier. # There's one little caveat: the `__init__` and `on_startup` methods of the # plugins that are part of the group are called after all other plugins, so - # the `event_priority` decorator for `on_startup` events and is effectively - # useless. However, the `on_startup` event is only intended to set up the + # the `event_priority` decorator for `on_startup` methods is effectively + # useless. However, the `on_startup` method is only intended to set up the # plugin and doesn't receive anything else than the invoked command and # whether we're running a dirty build, so there should be no problems. @event_priority(150) diff --git a/src/templates/partials/source-file.html b/src/templates/partials/source-file.html index f85e5b2369e..d2de99c9c8e 100644 --- a/src/templates/partials/source-file.html +++ b/src/templates/partials/source-file.html @@ -20,6 +20,112 @@ IN THE SOFTWARE. --> + +{% macro render_updated(date) %} + + + {% include ".icons/material/clock-edit-outline.svg" %} + + {{ date }} + +{% endmacro %} + + +{% macro render_created(date) %} + + + {% include ".icons/material/clock-plus-outline.svg" %} + + {{ date }} + +{% endmacro %} + + + + +{% macro render_authors(authors) %} + + + {% if authors | length == 1 %} + {% include ".icons/material/account.svg" %} + {% else %} + {% include ".icons/material/account-group.svg" %} + {% endif %} + + + +{% endmacro %} + + + + +{% macro render_committers_github(title) %} + + {% include ".icons/material/github.svg" %} + + {{ title }} +{% endmacro %} + + +{% macro render_committers_gitlab(title) %} + + {% include ".icons/material/gitlab.svg" %} + + {{ title }} +{% endmacro %} + + +{% macro render_committers(authors) %} + + {% if committers_source == "gitlab" %} + {{ render_committers_gitlab("GitLab") }} + {% else %} + {{ render_committers_github("GitHub") }} + {% endif %} + + +{% endmacro %} + + + {% if page.meta %} {% if page.meta.git_revision_date_localized %} @@ -40,86 +146,22 @@ {% if updated %} - - - {% include ".icons/material/clock-edit-outline.svg" %} - - {{ updated }} - + {{ render_updated(updated) }} {% endif %} {% if created %} - - - {% include ".icons/material/clock-plus-outline.svg" %} - - {{ created }} - + {{ render_created(created) }} {% endif %} {% if git_info %} - {% set authors = git_info.get("page_authors") %} - - - {% if authors | length == 1 %} - {% include ".icons/material/account.svg" %} - {% else %} - {% include ".icons/material/account-group.svg" %} - {% endif %} - - - + {{ render_authors(git_info.get("page_authors")) }} {% endif %} {% if committers %} - - - {% include ".icons/material/github.svg" %} - - GitHub - - + {{ render_committers(committers) }} {% endif %} {% endif %}