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 11from datetime import datetime
2+ import yaml
3+ from docutils import nodes
24
35# General configuration
46project = "Eclipse OpenBSW Documentation"
3234 "doc/**" ,
3335]
3436exclude_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