From b4a105635d85152f21f13aac4dba12a1aaf35e9e Mon Sep 17 00:00:00 2001 From: Romain Deville <code@romaindeville.fr> Date: Thu, 29 Apr 2021 13:00:02 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Improve=20handling=20of=20copyright?= =?UTF-8?q?=20in=20plugins.py=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/_data/plugins.py | 14 ++++++++++++-- templates/docs/_data/plugins.py | 14 ++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/docs/_data/plugins.py b/docs/_data/plugins.py index 05c3aea..cbac051 100644 --- a/docs/_data/plugins.py +++ b/docs/_data/plugins.py @@ -401,9 +401,19 @@ def set_copyright(env: dict, git_repo: git.Repo) -> None: first_year = time.strftime("%Y", time.localtime()) curr_year = time.strftime("%Y", time.localtime()) + if first_year == curr_year: + env.variables[ + "date_copyright" + ] = f"Copyright © {curr_year}" + else: + env.variables[ + "date_copyright" + ] = f"Copyright © {curr_year} - {curr_year}" + env.conf[ "copyright" - ] = f"Copyright © {first_year} - {curr_year} {env.variables['copyright']}" + ] = f"{env.variables['date_copyright']} {env.variables['copyright']}" + def set_repo_name(env: dict, repo_slug: str) -> None: @@ -844,7 +854,7 @@ def update_version(env: dict) -> None: } ) last_minor = minor - last_patch = 0 + last_patch = -1 if patch > last_patch: last_patch = patch mike_version.append( diff --git a/templates/docs/_data/plugins.py b/templates/docs/_data/plugins.py index cae7a4e..cbac051 100644 --- a/templates/docs/_data/plugins.py +++ b/templates/docs/_data/plugins.py @@ -401,13 +401,19 @@ def set_copyright(env: dict, git_repo: git.Repo) -> None: first_year = time.strftime("%Y", time.localtime()) curr_year = time.strftime("%Y", time.localtime()) + if first_year == curr_year: + env.variables[ + "date_copyright" + ] = f"Copyright © {curr_year}" + else: + env.variables[ + "date_copyright" + ] = f"Copyright © {curr_year} - {curr_year}" + env.conf[ "copyright" - ] = f"Copyright © {first_year} - {curr_year} {env.variables['copyright']}" + ] = f"{env.variables['date_copyright']} {env.variables['copyright']}" - env.variables[ - "full_copyright" - ] = f"Copyright © {first_year} - {curr_year} {env.variables['copyright']}" def set_repo_name(env: dict, repo_slug: str) -> None: -- GitLab