File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1
1
from datetime import datetime
2
+ import yaml
3
+ from docutils import nodes
2
4
3
5
# General configuration
4
6
project = "Eclipse OpenBSW Documentation"
32
34
"doc/**" ,
33
35
]
34
36
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 )
You can’t perform that action at this time.
0 commit comments