mirror of
https://github.com/TinyTapeout/tt-support-tools.git
synced 2026-11-03 04:36:09 +01:00
feat(datasheet): use mustache for project_preview
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
# {title}
|
||||
|
||||
* Author: {author}
|
||||
* Description: {description}
|
||||
* Language: {language}
|
||||
|
||||
{info}
|
||||
|
||||
## Pinout
|
||||
|
||||
| # | Input | Output | Bidirectional |
|
||||
|---|--------------|--------------|--------------------|
|
||||
| 0 | {ui[0]} | {uo[0]} | {uio[0]} |
|
||||
| 1 | {ui[1]} | {uo[1]} | {uio[1]} |
|
||||
| 2 | {ui[2]} | {uo[2]} | {uio[2]} |
|
||||
| 3 | {ui[3]} | {uo[3]} | {uio[3]} |
|
||||
| 4 | {ui[4]} | {uo[4]} | {uio[4]} |
|
||||
| 5 | {ui[5]} | {uo[5]} | {uio[5]} |
|
||||
| 6 | {ui[6]} | {uo[6]} | {uio[6]} |
|
||||
| 7 | {ui[7]} | {uo[7]} | {uio[7]} |
|
||||
@@ -0,0 +1,15 @@
|
||||
# {{title}}
|
||||
|
||||
* Author: {{author}}
|
||||
* Description: {{&description}}
|
||||
* Language: {{language}}
|
||||
|
||||
{{&info}}
|
||||
|
||||
## Pinout
|
||||
|
||||
| # | Input | Output | Bidirectional |
|
||||
|---------------|----------|----------|----------------|
|
||||
{{#pins}}
|
||||
| {{pin_index}} | {{&ui}} | {{&uo}} | {{&uio}} |
|
||||
{{/pins}}
|
||||
+16
-5
@@ -10,6 +10,7 @@ import subprocess
|
||||
import typing
|
||||
|
||||
import cairosvg # type: ignore
|
||||
import chevron
|
||||
import gdstk # type: ignore
|
||||
import yaml
|
||||
from git.repo import Repo
|
||||
@@ -571,14 +572,24 @@ class Project:
|
||||
# use pandoc to create a single page PDF preview
|
||||
def create_pdf(self):
|
||||
template_args = copy.deepcopy(self.info.__dict__)
|
||||
template_args["ui"] = self.info.pinout.ui
|
||||
template_args["uo"] = self.info.pinout.uo
|
||||
template_args["uio"] = self.info.pinout.uio
|
||||
template_args.update(
|
||||
{
|
||||
"pins": [
|
||||
{
|
||||
"pin_index": str(i),
|
||||
"ui": self.info.pinout.ui[i],
|
||||
"uo": self.info.pinout.uo[i],
|
||||
"uio": self.info.pinout.uio[i],
|
||||
}
|
||||
for i in range(8)
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
logging.info("Creating PDF")
|
||||
with open(os.path.join(SCRIPT_DIR, "docs/project_header.md")) as fh:
|
||||
doc_header = fh.read()
|
||||
with open(os.path.join(SCRIPT_DIR, "docs/project_preview.md")) as fh:
|
||||
with open(os.path.join(SCRIPT_DIR, "docs/project_preview.md.mustache")) as fh:
|
||||
doc_template = fh.read()
|
||||
info_md = os.path.join(self.local_dir, "docs/info.md")
|
||||
with open(info_md) as fh:
|
||||
@@ -589,7 +600,7 @@ class Project:
|
||||
|
||||
# now build the doc & print it
|
||||
try:
|
||||
doc = doc_template.format(**template_args)
|
||||
doc = chevron.render(doc_template, template_args)
|
||||
fh.write(doc)
|
||||
fh.write("\n\\pagebreak\n")
|
||||
except IndexError:
|
||||
|
||||
@@ -4,6 +4,7 @@ CairoSVG==2.7.0
|
||||
certifi==2023.5.7
|
||||
cffi==1.15.1
|
||||
charset-normalizer==3.1.0
|
||||
chevron==0.14.0
|
||||
click==8.1.3
|
||||
cssselect2==0.7.0
|
||||
defusedxml==0.7.1
|
||||
|
||||
Reference in New Issue
Block a user