feat(datasheet): use mustache for hugo_template

This commit is contained in:
htfab
2024-05-07 08:47:00 +03:00
committed by Uri Shaked
parent ce9f174c87
commit 6ac178db11
4 changed files with 64 additions and 51 deletions
@@ -1,10 +1,10 @@
--- ---
title: "{shuttle_name}" title: "{{shuttle_name}}"
weight: 50 weight: 50
description: {project_count} designs, closed {end_date} description: {{project_count}} designs, closed {{end_date}}
--- ---
{{{{% toc %}}}} {{#hugo}}% toc %{{/hugo}}
# Design details # Design details
@@ -22,5 +22,5 @@ description: {project_count} designs, closed {end_date}
# Chip map # Chip map
{{{{< shuttle-map "{shuttle_id}" >}}}} {{#hugo}}< shuttle-map "{shuttle_id}" >{{/hugo}}
-34
View File
@@ -1,34 +0,0 @@
---
hidden: true
title: "{mux_address} {title}"
weight: {weight}
---
## {mux_address} : {title}
* Author: {author}
* Description: {description}
* [GitHub repository]({git_url})
* [GDS submitted]({git_action})
* {project_type} project
* [Extra docs]({doc_link})
* Clock: {clock_hz} Hz
{user_docs}
### IO
| # | Input | Output | Bidirectional |
| - | -------------- | -------------- | --------------- |
| 0 | {pinout.ui[0]} | {pinout.uo[0]} | {pinout.uio[0]} |
| 1 | {pinout.ui[1]} | {pinout.uo[1]} | {pinout.uio[1]} |
| 2 | {pinout.ui[2]} | {pinout.uo[2]} | {pinout.uio[2]} |
| 3 | {pinout.ui[3]} | {pinout.uo[3]} | {pinout.uio[3]} |
| 4 | {pinout.ui[4]} | {pinout.uo[4]} | {pinout.uio[4]} |
| 5 | {pinout.ui[5]} | {pinout.uo[5]} | {pinout.uio[5]} |
| 6 | {pinout.ui[6]} | {pinout.uo[6]} | {pinout.uio[6]} |
| 7 | {pinout.ui[7]} | {pinout.uo[7]} | {pinout.uio[7]} |
### Chip location
{{{{< shuttle-map "{shuttle_id}" "{mux_address}" >}}}}
+29
View File
@@ -0,0 +1,29 @@
---
hidden: true
title: "{{mux_address}} {{title}}"
weight: {{weight}}
---
## {{mux_address}} : {{title}}
* Author: {{author}}
* Description: {{&description}}
* [GitHub repository]({{git_url}})
* [GDS submitted]({{git_action}})
* {{project_type}} project
* [Extra docs]({{doc_link}})
* Clock: {{clock_hz}} Hz
{{&user_docs}}
### IO
| # | Input | Output | Bidirectional |
| ------------- | -------- | -------- | --------------- |
{{#pins}}
| {{pin_index}} | {{&ui}} | {{&uo}} | {{&uio[0]}} |
{{/pins}}
### Chip location
{{#hugo}}< shuttle-map "{{shuttle_id}}" "{{mux_address}}" >{{/hugo}}
+31 -13
View File
@@ -152,11 +152,13 @@ class Docs:
os.makedirs(hugo_root) os.makedirs(hugo_root)
os.makedirs(hugo_images) os.makedirs(hugo_images)
with open(os.path.join(self.script_dir, "docs", "hugo_template.md")) as fh: with open(
os.path.join(self.script_dir, "docs", "hugo_template.md.mustache")
) as fh:
doc_template = fh.read() doc_template = fh.read()
with open( with open(
os.path.join(self.script_dir, "docs", "hugo_index_template.md") os.path.join(self.script_dir, "docs", "hugo_index_template.md.mustache")
) as fh: ) as fh:
index_template = fh.read() index_template = fh.read()
@@ -169,6 +171,7 @@ class Docs:
# index page # index page
logging.info("building pages") logging.info("building pages")
hugo_tag = {"hugo": lambda text, render: "{{" + render(text) + "}}"}
shuttle_info = { shuttle_info = {
"shuttle_name": self.config["name"], "shuttle_name": self.config["name"],
"shuttle_id": self.config["id"], "shuttle_id": self.config["id"],
@@ -176,7 +179,8 @@ class Docs:
"end_date": self.config["end_date"], "end_date": self.config["end_date"],
} }
with open(os.path.join(hugo_root, "_index.md"), "w") as fh: with open(os.path.join(hugo_root, "_index.md"), "w") as fh:
fh.write(index_template.format(**shuttle_info)) shuttle_info.update(hugo_tag)
fh.write(chevron.render(index_template, shuttle_info))
fh.write("# All projects\n") fh.write("# All projects\n")
fh.write("| Index | Title | Author |\n") fh.write("| Index | Title | Author |\n")
fh.write("| ----- | ----- | -------|\n") fh.write("| ----- | ----- | -------|\n")
@@ -190,17 +194,31 @@ class Docs:
os.makedirs(project_dir) os.makedirs(project_dir)
os.makedirs(project_image_dir) os.makedirs(project_image_dir)
yaml_data = project.get_project_docs_dict() yaml_data = project.get_project_docs_dict()
yaml_data["mux_address"] = project.mux_address yaml_data.update(
yaml_data["index"] = project.index {
yaml_data["weight"] = project.index + 1 "mux_address": project.mux_address,
yaml_data["git_action"] = project.get_workflow_url_when_submitted() "index": project.index,
yaml_data["shuttle_id"] = self.config["id"] "weight": project.index,
yaml_data["user_docs"] = rewrite_image_paths_for_website( "git_action": project.get_workflow_url_when_submitted(),
yaml_data["user_docs"], "shuttle_id": self.config["id"],
os.path.join(project.src_dir, "docs"), "user_docs": rewrite_image_paths_for_website(
project_image_dir, yaml_data["user_docs"],
os.path.join(project.src_dir, "docs"),
project_image_dir,
),
"pins": [
{
"pin_index": str(i),
"ui": project.info.pinout.ui[i],
"uo": project.info.pinout.uo[i],
"uio": project.info.pinout.uio[i],
}
for i in range(8)
],
}
) )
doc = doc_template.format(**yaml_data) yaml_data.update(hugo_tag)
doc = chevron.render(doc_template, yaml_data)
with open(os.path.join(project_dir, "_index.md"), "w") as pfh: with open(os.path.join(project_dir, "_index.md"), "w") as pfh:
pfh.write(doc) pfh.write(doc)