Repository: google/cyanobyte

Issue:
Add doc generation from markdown template

Comments:

Patch:
diff --git a/cloudbuild-deploy.yaml b/cloudbuild-deploy.yaml
index 83f0570..dbb30dd 100644
--- a/cloudbuild-deploy.yaml
+++ b/cloudbuild-deploy.yaml
@@ -16,6 +16,28 @@ steps:
   args: ['-c', 'wget -O- https://github.com/gohugoio/hugo/releases/download/v${_HUGO}/hugo_extended_${_HUGO}_Linux-64bit.tar.gz | tar zx']
   id: Install Hugo manually
 
+- name: docker.io/library/python:3.7
+  entrypoint: python3
+  id: Generate Hugo-compatible Markdown for our peripherals
+  args:
+    - 'src/codegen.py'
+    - '-t'
+    - 'templates/doc.md'
+    - '-o'
+    - './docs/content/docs/Reference/Peripheral Docs'
+    - '-i'
+    - 'peripherals/ADS1015.yaml'
+    - '-i'
+    - 'peripherals/BMP280.yaml'
+    - '-i'
+    - 'peripherals/LSM303D.yaml'
+    - '-i'
+    - 'peripherals/MCP4725.yaml'
+    - '-i'
+    - 'peripherals/MCP9808.yaml'
+    - '-i'
+    - 'peripherals/TCS3472.yaml'
+
 - name: gcr.io/cloud-builders/git
   entrypoint: bash
   id: Move up content directory
diff --git a/docs/content/docs/Reference/Peripheral Docs/_index.md b/docs/content/docs/Reference/Peripheral Docs/_index.md
new file mode 100644
index 0000000..b1d2fe4
--- /dev/null
+++ b/docs/content/docs/Reference/Peripheral Docs/_index.md
@@ -0,0 +1,7 @@
+---
+title: "Auto-generated reference docs"
+linkTitle: "Auto-generated reference docs"
+weight: 1
+description: >
+  Hosted peripherals
+---
diff --git a/templates/doc.md b/templates/doc.md
index b27738e..4c880b6 100644
--- a/templates/doc.md
+++ b/templates/doc.md
@@ -1,5 +1,10 @@
-# {{ info.title }}
-{{ info.description }}
+---
+title: "{{info.title}}"
+linkTitle: "{{info.title}}"
+weight: 4
+description: >
+  {{info.description}}
+---
 
 ## Registers
 {% for register in registers %}
@@ -17,4 +22,4 @@ _{{ info.title }} version {{ info.version }}_
 
 _Based on Cyanobyte spec version {{cyanobyte}}_
 
-_Generated from Cyanobyte Codegen version {{ version }}_
\ No newline at end of file
+_Generated from Cyanobyte Codegen version {{ version }}_


Test patch:
diff --git a/test/sampleData/markdown/ADS1015.md b/test/sampleData/markdown/ADS1015.md
index b188fd7..eb84995 100644
--- a/test/sampleData/markdown/ADS1015.md
+++ b/test/sampleData/markdown/ADS1015.md
@@ -1,5 +1,10 @@
-# ADS1015
-Texas Instruments Analog-Digital Converter
+---
+title: "ADS1015"
+linkTitle: "ADS1015"
+weight: 4
+description: >
+  Texas Instruments Analog-Digital Converter
+---
 
 ## Registers
 
diff --git a/test/sampleData/markdown/BMP280.md b/test/sampleData/markdown/BMP280.md
index 000fa87..85b7389 100644
--- a/test/sampleData/markdown/BMP280.md
+++ b/test/sampleData/markdown/BMP280.md
@@ -1,5 +1,10 @@
-# BMP280
-Bosch Digital Pressure Sensor
+---
+title: "BMP280"
+linkTitle: "BMP280"
+weight: 4
+description: >
+  Bosch Digital Pressure Sensor
+---
 
 ## Registers
 
diff --git a/test/sampleData/markdown/LSM303D.md b/test/sampleData/markdown/LSM303D.md
index 8f7b201..67711b9 100644
--- a/test/sampleData/markdown/LSM303D.md
+++ b/test/sampleData/markdown/LSM303D.md
@@ -1,5 +1,10 @@
-# LSM303D
-STMicroelectronics accelerometer and magnetometer
+---
+title: "LSM303D"
+linkTitle: "LSM303D"
+weight: 4
+description: >
+  STMicroelectronics accelerometer and magnetometer
+---
 
 ## Registers
 
diff --git a/test/sampleData/markdown/MCP4725.md b/test/sampleData/markdown/MCP4725.md
index d4bbc26..2c9f700 100644
--- a/test/sampleData/markdown/MCP4725.md
+++ b/test/sampleData/markdown/MCP4725.md
@@ -1,5 +1,10 @@
-# MCP4725
-Microchip 4725 Digital-to-Analog Converter
+---
+title: "MCP4725"
+linkTitle: "MCP4725"
+weight: 4
+description: >
+  Microchip 4725 Digital-to-Analog Converter
+---
 
 ## Registers
 
diff --git a/test/sampleData/markdown/MCP9808.md b/test/sampleData/markdown/MCP9808.md
index f923450..6d879e1 100644
--- a/test/sampleData/markdown/MCP9808.md
+++ b/test/sampleData/markdown/MCP9808.md
@@ -1,5 +1,10 @@
-# MCP9808
-This is a test description
+---
+title: "MCP9808"
+linkTitle: "MCP9808"
+weight: 4
+description: >
+  This is a test description
+---
 
 ## Registers
 
diff --git a/test/sampleData/markdown/TCS3472.md b/test/sampleData/markdown/TCS3472.md
index 26907e5..1d80532 100644
--- a/test/sampleData/markdown/TCS3472.md
+++ b/test/sampleData/markdown/TCS3472.md
@@ -1,5 +1,10 @@
-# TCS3472
-Color Light-to-Digital Converter with IR Filter
+---
+title: "TCS3472"
+linkTitle: "TCS3472"
+weight: 4
+description: >
+  Color Light-to-Digital Converter with IR Filter
+---
 
 ## Registers