mirror of
https://github.com/TinyTapeout/tt-support-tools.git
synced 2026-11-03 04:36:09 +01:00
feat(datasheet): use mustache for doc_template
This commit is contained in:
@@ -1,19 +0,0 @@
|
|||||||
---
|
|
||||||
title: |
|
|
||||||
{{width=15cm}}
|
|
||||||
{name} Datasheet
|
|
||||||
subtitle: Project Repository [{repo}]({repo})
|
|
||||||
documentclass: scrartcl
|
|
||||||
date: \today{{}}
|
|
||||||
geometry: "left=2cm,right=2cm,top=2cm,bottom=2.5cm"
|
|
||||||
fontsize: 14pt
|
|
||||||
mainfont: Latin Modern Sans
|
|
||||||
header-includes:
|
|
||||||
- \hypersetup{{colorlinks=true,
|
|
||||||
urlcolor=blue,
|
|
||||||
linkcolor=[rgb]{{0,0,0.5}},
|
|
||||||
allbordercolors={{0 0 0}},
|
|
||||||
pdfborderstyle={{/S/U/W 1}}}}
|
|
||||||
---
|
|
||||||
|
|
||||||
\pagebreak
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
title: |
|
||||||
|
{width=15cm}
|
||||||
|
{{name}} Datasheet
|
||||||
|
subtitle: Project Repository [{{repo}}]({{repo}})
|
||||||
|
documentclass: scrartcl
|
||||||
|
date: \today{}
|
||||||
|
geometry: "left=2cm,right=2cm,top=2cm,bottom=2.5cm"
|
||||||
|
fontsize: 14pt
|
||||||
|
mainfont: Latin Modern Sans
|
||||||
|
header-includes:
|
||||||
|
- \hypersetup{colorlinks=true,
|
||||||
|
urlcolor=blue,
|
||||||
|
linkcolor=[rgb]{0,0,0.5},
|
||||||
|
allbordercolors={0 0 0},
|
||||||
|
pdfborderstyle={/S/U/W 1} }
|
||||||
|
---
|
||||||
|
|
||||||
|
\pagebreak
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
## {title} [{mux_address}]
|
|
||||||
|
|
||||||
* Author: {author}
|
|
||||||
* Description: {description}
|
|
||||||
* [GitHub repository](__git_url__)
|
|
||||||
* {project_type} project
|
|
||||||
* Mux address: {mux_address}
|
|
||||||
* [Extra docs](__doc_link__)
|
|
||||||
* Clock: {clock_hz} Hz
|
|
||||||
|
|
||||||
{user_docs}
|
|
||||||
|
|
||||||
### Pinout
|
|
||||||
|
|
||||||
| # | 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]} |
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
## {{title}} [{{mux_address}}]
|
||||||
|
|
||||||
|
* Author: {{author}}
|
||||||
|
* Description: {{&description}}
|
||||||
|
* [GitHub repository]({{git_url}})
|
||||||
|
* {{project_type}} project
|
||||||
|
* Mux address: {{mux_address}}
|
||||||
|
* [Extra docs]({{doc_link}})
|
||||||
|
* Clock: {{clock_hz}} Hz
|
||||||
|
|
||||||
|
{{&user_docs}}
|
||||||
|
|
||||||
|
### Pinout
|
||||||
|
|
||||||
|
| # | Input | Output | Bidirectional |
|
||||||
|
| ------------- | -------- | -------- | --------------- |
|
||||||
|
{{#pins}}
|
||||||
|
| {{pin_index}} | {{&ui}} | {{&uo}} | {{&uio[0]}} |
|
||||||
|
{{/pins}}
|
||||||
+28
-7
@@ -4,6 +4,7 @@ import shutil
|
|||||||
import subprocess
|
import subprocess
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
|
import chevron
|
||||||
import frontmatter # type: ignore
|
import frontmatter # type: ignore
|
||||||
import git # type: ignore
|
import git # type: ignore
|
||||||
|
|
||||||
@@ -60,9 +61,9 @@ class Docs:
|
|||||||
return doc.content + "\n"
|
return doc.content + "\n"
|
||||||
|
|
||||||
def write_datasheet(self, markdown_file: str, pdf_file: Optional[str] = None):
|
def write_datasheet(self, markdown_file: str, pdf_file: Optional[str] = None):
|
||||||
doc_header = self.load_doc_template("doc_header.md")
|
doc_header = self.load_doc_template("doc_header.md.mustache")
|
||||||
doc_chip_map = self.load_doc_template("../../docs/chip_map.md")
|
doc_chip_map = self.load_doc_template("../../docs/chip_map.md")
|
||||||
doc_template = self.load_doc_template("doc_template.md")
|
doc_template = self.load_doc_template("doc_template.md.mustache")
|
||||||
doc_pinout = self.load_doc_template("PINOUT.md")
|
doc_pinout = self.load_doc_template("PINOUT.md")
|
||||||
doc_info = self.load_doc_template("../../tt-multiplexer/docs/INFO.md")
|
doc_info = self.load_doc_template("../../tt-multiplexer/docs/INFO.md")
|
||||||
doc_credits = self.load_doc_template("CREDITS.md")
|
doc_credits = self.load_doc_template("CREDITS.md")
|
||||||
@@ -70,7 +71,13 @@ class Docs:
|
|||||||
with open(markdown_file, "w") as fh:
|
with open(markdown_file, "w") as fh:
|
||||||
repo = git.Repo(".")
|
repo = git.Repo(".")
|
||||||
fh.write(
|
fh.write(
|
||||||
doc_header.format(name=self.config["name"], repo=get_first_remote(repo))
|
chevron.render(
|
||||||
|
doc_header,
|
||||||
|
{
|
||||||
|
"name": self.config["name"],
|
||||||
|
"repo": get_first_remote(repo),
|
||||||
|
},
|
||||||
|
)
|
||||||
)
|
)
|
||||||
fh.write(doc_chip_map)
|
fh.write(doc_chip_map)
|
||||||
fh.write("# Projects\n")
|
fh.write("# Projects\n")
|
||||||
@@ -79,10 +86,24 @@ class Docs:
|
|||||||
|
|
||||||
for project in self.projects:
|
for project in self.projects:
|
||||||
yaml_data = project.get_project_docs_dict()
|
yaml_data = project.get_project_docs_dict()
|
||||||
yaml_data["user_docs"] = rewrite_image_paths(
|
yaml_data.update(
|
||||||
yaml_data["user_docs"], f"projects/{project.get_macro_name()}/docs"
|
{
|
||||||
|
"user_docs": rewrite_image_paths(
|
||||||
|
yaml_data["user_docs"],
|
||||||
|
f"projects/{project.get_macro_name()}/docs",
|
||||||
|
),
|
||||||
|
"mux_address": project.mux_address,
|
||||||
|
"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)
|
||||||
|
],
|
||||||
|
}
|
||||||
)
|
)
|
||||||
yaml_data["mux_address"] = project.mux_address
|
|
||||||
|
|
||||||
logging.info(f"building datasheet for {project}")
|
logging.info(f"building datasheet for {project}")
|
||||||
|
|
||||||
@@ -103,7 +124,7 @@ class Docs:
|
|||||||
|
|
||||||
# now build the doc & print it
|
# now build the doc & print it
|
||||||
try:
|
try:
|
||||||
doc = doc_template.format(**yaml_data)
|
doc = chevron.render(doc_template, yaml_data)
|
||||||
fh.write(doc)
|
fh.write(doc)
|
||||||
fh.write("\n\\clearpage\n")
|
fh.write("\n\\clearpage\n")
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
|||||||
Reference in New Issue
Block a user