From 6034820170dc4e0f86ac189f9d0f0966da2a4690 Mon Sep 17 00:00:00 2001 From: Uri Shaked Date: Sun, 30 Jul 2023 09:40:16 +0300 Subject: [PATCH] fix(datasheet): use shuttle name from config also, dynamically figure out the repo URL (instead of using an hardcoded value) --- configure.py | 2 +- docs/doc_header.md | 14 +++++++------- documentation.py | 8 ++++++-- git_utils.py | 7 ++++++- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/configure.py b/configure.py index 3bb61e1..1aeb78a 100755 --- a/configure.py +++ b/configure.py @@ -205,7 +205,7 @@ if __name__ == '__main__': else: modules_yaml_name = "modules.yaml" - docs = Docs(projects.projects, args=args) + docs = Docs(config, projects.projects, args=args) caravel = CaravelConfig(config, projects.projects, modules_yaml_name) rom = ROMFile(config, projects.projects) diff --git a/docs/doc_header.md b/docs/doc_header.md index d5d2574..03b96ad 100644 --- a/docs/doc_header.md +++ b/docs/doc_header.md @@ -1,17 +1,17 @@ --- title: | - ![](pics/ttlogo.png){width=15cm} - Tiny Tapeout 03 Datasheet -subtitle: Project Repository [https://github.com/TinyTapeout/tinytapeout-03](https://github.com/TinyTapeout/tinytapeout-03) + ![](pics/ttlogo.png){{width=15cm}} + {name} Datasheet +subtitle: Project Repository [{repo}]({repo}) documentclass: scrartcl -date: \today{} +date: \today{{}} geometry: "left=2cm,right=2cm,top=2cm,bottom=2.5cm" fontsize: 14pt mainfont: Latin Modern Sans header-includes: -- \hypersetup{colorlinks=false, - allbordercolors={0 0 0}, - pdfborderstyle={/S/U/W 1}} +- \hypersetup{{colorlinks=false, + allbordercolors={{0 0 0}}, + pdfborderstyle={{/S/U/W 1}}}} --- \pagebreak diff --git a/documentation.py b/documentation.py index c87c914..22a6000 100644 --- a/documentation.py +++ b/documentation.py @@ -3,11 +3,14 @@ import logging import subprocess import shutil import json +from git_utils import get_first_remote +import git class Docs(): - def __init__(self, projects, args): + def __init__(self, config, projects, args): + self.config = config self.projects = projects self.args = args self.script_dir = os.path.dirname(os.path.realpath(__file__)) @@ -64,7 +67,8 @@ class Docs(): doc_credits = fh.read() with open(self.args.dump_markdown, 'w') as fh: - fh.write(doc_header) + repo = git.Repo(".") + fh.write(doc_header.format(name=self.config['name'], repo=get_first_remote(repo))) self.projects.sort(key=lambda x: x.mux_address) diff --git a/git_utils.py b/git_utils.py index 8bc3fdf..44f93c7 100644 --- a/git_utils.py +++ b/git_utils.py @@ -2,6 +2,7 @@ import base64 from urllib.parse import urlparse import logging import requests +import git import os import errno @@ -70,7 +71,7 @@ def split_git_url(url): -def get_latest_action_url(url, directory): +def get_latest_action_url(url): logging.debug(url) user_name, repo = split_git_url(url) @@ -99,3 +100,7 @@ def get_latest_action_url(url, directory): page_url = get_most_recent_action_page(commits, runs['workflow_runs']) return page_url + + +def get_first_remote(repo: git.Repo) -> str: + return list(repo.remotes[0].urls)[0]