mirror of
https://github.com/TinyTapeout/tt-support-tools.git
synced 2026-11-03 12:46:08 +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 typing
|
||||||
|
|
||||||
import cairosvg # type: ignore
|
import cairosvg # type: ignore
|
||||||
|
import chevron
|
||||||
import gdstk # type: ignore
|
import gdstk # type: ignore
|
||||||
import yaml
|
import yaml
|
||||||
from git.repo import Repo
|
from git.repo import Repo
|
||||||
@@ -526,15 +527,25 @@ class Project:
|
|||||||
# use pandoc to create a single page PDF preview
|
# use pandoc to create a single page PDF preview
|
||||||
def create_pdf(self):
|
def create_pdf(self):
|
||||||
template_args = copy.deepcopy(self.info.__dict__)
|
template_args = copy.deepcopy(self.info.__dict__)
|
||||||
template_args["ui"] = self.info.pinout.ui
|
template_args.update(
|
||||||
template_args["uo"] = self.info.pinout.uo
|
{
|
||||||
template_args["uio"] = self.info.pinout.uio
|
"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")
|
logging.info("Creating PDF")
|
||||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
with open(os.path.join(script_dir, "docs/project_header.md")) as fh:
|
with open(os.path.join(script_dir, "docs/project_header.md")) as fh:
|
||||||
doc_header = fh.read()
|
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()
|
doc_template = fh.read()
|
||||||
info_md = os.path.join(self.local_dir, "docs/info.md")
|
info_md = os.path.join(self.local_dir, "docs/info.md")
|
||||||
with open(info_md) as fh:
|
with open(info_md) as fh:
|
||||||
@@ -545,7 +556,7 @@ class Project:
|
|||||||
|
|
||||||
# now build the doc & print it
|
# now build the doc & print it
|
||||||
try:
|
try:
|
||||||
doc = doc_template.format(**template_args)
|
doc = chevron.render(doc_template, template_args)
|
||||||
fh.write(doc)
|
fh.write(doc)
|
||||||
fh.write("\n\\pagebreak\n")
|
fh.write("\n\\pagebreak\n")
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ CairoSVG==2.7.0
|
|||||||
certifi==2023.5.7
|
certifi==2023.5.7
|
||||||
cffi==1.15.1
|
cffi==1.15.1
|
||||||
charset-normalizer==3.1.0
|
charset-normalizer==3.1.0
|
||||||
|
chevron==0.14.0
|
||||||
click==8.1.3
|
click==8.1.3
|
||||||
cssselect2==0.7.0
|
cssselect2==0.7.0
|
||||||
defusedxml==0.7.1
|
defusedxml==0.7.1
|
||||||
|
|||||||
Reference in New Issue
Block a user