Skip to content

Commit

Permalink
use chevron for hugo_template.md
Browse files Browse the repository at this point in the history
  • Loading branch information
htfab committed May 6, 2024
1 parent 9b807d6 commit 4513d63
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/doc_template.md.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
| # | Input | Output | Bidirectional |
| ------------- | -------- | -------- | --------------- |
{{#pins}}
| {{pin_index}} | {{&ui}} | {{&uo}} | {{uio[0]}} |
| {{pin_index}} | {{&ui}} | {{&uo}} | {{&uio[0]}} |
{{/pins}}

{{#is_analog}}
Expand Down
39 changes: 39 additions & 0 deletions docs/hugo_template.md.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
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}}

{{#is_analog}}
### Analog pins

| `ua`# | `analog`# | Description |
| ------------ | ---------------- | ------------------- |
{{#analog_pins}}
| {{ua_index}} | {{analog_index}} | {{&desc}} |
{{/analog_pins}}
{{/is_analog}}

### Chip location

{{#hugo_tag}} shuttle-map "{{shuttle_id}}" "{{mux_address}}" {{/hugo_tag}}
50 changes: 36 additions & 14 deletions documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ def build_hugo_content(self, hugo_root: str) -> None:
os.makedirs(hugo_root)
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()

with open(
Expand Down Expand Up @@ -194,22 +196,42 @@ def build_hugo_content(self, hugo_root: str) -> None:
os.makedirs(project_dir)
os.makedirs(project_image_dir)
yaml_data = project.get_project_docs_dict()
yaml_data["mux_address"] = project.mux_address
yaml_data["index"] = project.index
yaml_data["weight"] = project.index + 1
yaml_data["git_action"] = project.get_workflow_url_when_submitted()
yaml_data["shuttle_id"] = self.config["id"]
yaml_data["user_docs"] = rewrite_image_paths_for_website(
yaml_data["user_docs"],
os.path.join(project.src_dir, "docs"),
project_image_dir,
yaml_data.update(
{
"mux_address": project.mux_address,
"index": project.index,
"weight": project.index,
"git_action": project.get_workflow_url_when_submitted(),
"shuttle_id": self.config["id"],
"user_docs": rewrite_image_paths_for_website(
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)
],
"analog_pins": [
{
"ua_index": str(i),
"analog_index": str(project.analog_pins[i]),
"desc": desc,
}
for i, desc in enumerate(project.info.pinout.ua)
],
"is_analog": bool(project.info.pinout.ua),
"hugo_tag": lambda text, render: "{{<" + render(text) + ">}}",
}
)
yaml_data["analog_pins"] = (project.analog_pins or ()) + (
"unavailable",
) * 6

logging.info("doc_template: " + doc_template)
logging.info("yaml_data: " + str(yaml_data))
doc = doc_template.format(**yaml_data)
doc = chevron.render(doc_template, yaml_data)
with open(os.path.join(project_dir, "_index.md"), "w") as pfh:
pfh.write(doc)

0 comments on commit 4513d63

Please sign in to comment.