Skip to content

Commit ed362a6

Browse files
SuhashiniNaikmarcmo
authored andcommitted
Fix broken toolchain URL with versioned gcc-arm-none-eabi 10.3-2021.10 link
- Reads from properties.yaml - Makes changes during sphinx generation process
1 parent 37a1388 commit ed362a6

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

doc/conf.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from datetime import datetime
2+
import yaml
3+
from docutils import nodes
24

35
# General configuration
46
project = "Eclipse OpenBSW Documentation"
@@ -32,3 +34,28 @@
3234
"doc/**",
3335
]
3436
exclude_patterns = []
37+
38+
def replace_placeholders(app, doctree, docname):
39+
with open("properties.yaml", "r") as f:
40+
props = yaml.safe_load(f)
41+
42+
gcc_arm = props["tool"].get("gcc-arm-none-eabi", "x.x")
43+
ubuntu_version = props["tool"].get("ubuntu_version", "x.x")
44+
45+
for node in doctree.traverse(nodes.Text):
46+
text = node.astext()
47+
new_text = text
48+
49+
if "gcc-arm-none-eabi" in text and "x.x" in text:
50+
new_text = new_text.replace("x.x", gcc_arm)
51+
52+
elif "Ubuntu-x.x" in text:
53+
new_text = new_text.replace("x.x", ubuntu_version)
54+
55+
if new_text != text:
56+
node.parent.replace(node, nodes.Text(new_text))
57+
58+
59+
def setup(app):
60+
# Doctree-resolved is a single event that is emitted when the document tree has been fully resolved
61+
app.connect("doctree-resolved", replace_placeholders)

0 commit comments

Comments
 (0)