Skip to content

Commit

Permalink
Code Refactor for Speed and Readability (#55)
Browse files Browse the repository at this point in the history
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
  • Loading branch information
3 people authored Jun 9, 2024
1 parent 0174fe3 commit 7a5287d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
25 changes: 12 additions & 13 deletions plugin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<div class="git-info" style="font-size: 0.8em; text-align: right; margin-bottom: 10px;"><br>'
if (self.config["add_dates"] or self.config["add_authors"]) and git_info["creation_date"]:
div = '<div class="git-info" style="font-size: 0.8em; text-align: right; margin-bottom: 10px;"><br>'

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 += "<br>"
authors_str = ", ".join([f"<a href='{a[1]}'>{a[0]}</a> ({a[2]})" for a in git_info["authors"]])
div += f"Authors: {authors_str}"
if self.config["add_authors"]:
if self.config["add_dates"]:
div += "<br>"
authors_str = ", ".join([f"<a href='{a[1]}'>{a[0]}</a> ({a[2]})" for a in git_info["authors"]])
div += f"Authors: {authors_str}"

div += "</div>"
div = BeautifulSoup(div, "html.parser")
self.insert_content(soup, div)
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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 7a5287d

Please # to comment.