From 7a5287d26a689b23d931d3230d183febc47d4513 Mon Sep 17 00:00:00 2001 From: Paula Derrenger <107626595+pderrenger@users.noreply.github.com> Date: Sun, 9 Jun 2024 04:33:10 +0200 Subject: [PATCH] Code Refactor for Speed and Readability (#55) Co-authored-by: Glenn Jocher Co-authored-by: UltralyticsAssistant --- plugin/main.py | 25 ++++++++++++------------- pyproject.toml | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/plugin/main.py b/plugin/main.py index 0d84dc6..5383f25 100644 --- a/plugin/main.py +++ b/plugin/main.py @@ -178,22 +178,21 @@ def on_post_page(self, output, page, config): # Add git information (dates and authors) to the footer, if enabled git_info = self.get_git_info(page.file.abs_src_path) - if self.config["add_dates"] or self.config["add_authors"]: - if git_info["creation_date"]: # otherwise page is missing git info and step should be skipped - div = '

' + if (self.config["add_dates"] or self.config["add_authors"]) and git_info["creation_date"]: + div = '

' - if self.config["add_dates"]: - div += f"Created {git_info['creation_date'][:10]}, Updated {git_info['last_modified_date'][:10]}" + if self.config["add_dates"]: + div += f"Created {git_info['creation_date'][:10]}, Updated {git_info['last_modified_date'][:10]}" - if self.config["add_authors"]: - if self.config["add_dates"]: - div += "
" - authors_str = ", ".join([f"{a[0]} ({a[2]})" for a in git_info["authors"]]) - div += f"Authors: {authors_str}" + if self.config["add_authors"]: + if self.config["add_dates"]: + div += "
" + authors_str = ", ".join([f"{a[0]} ({a[2]})" for a in git_info["authors"]]) + div += f"Authors: {authors_str}" - div += "
" - div = BeautifulSoup(div, "html.parser") - self.insert_content(soup, div) + div += "
" + div = BeautifulSoup(div, "html.parser") + self.insert_content(soup, div) # Add share buttons to the footer, if enabled if self.config["add_share_buttons"]: # Check if share buttons are enabled diff --git a/pyproject.toml b/pyproject.toml index a2c55c6..3497a68 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ build-backend = "setuptools.build_meta" [project] name = "mkdocs-ultralytics-plugin" -version = "0.0.45" +version = "0.0.46" description = "An MkDocs plugin that provides Ultralytics Docs customizations at https://docs.ultralytics.com." readme = "README.md" requires-python = ">=3.8"