3
3
import sys
4
4
import re
5
5
import os
6
- import html
6
+ # import html
7
7
from bs4 import BeautifulSoup
8
8
9
9
# walk the combined output.
@@ -18,30 +18,31 @@ def compile_id_list(xml_content):
18
18
id_list = [x ["id" ] for x in els ]
19
19
return id_list
20
20
21
- def insert_example_code_from_file (combined_content ):
22
- els = combined_content .doxygen .find_all ("programlisting" )
23
- all_examples = {}
24
- # get the examples path
25
- examples_path = re .sub (r"/scripts/.+$" , "/lib/pico-examples" , os .path .realpath (__file__ ))
26
- # get a recursive list of all files in examples
27
- for f in os .walk (examples_path ):
28
- for filename in f [2 ]:
29
- if filename in all_examples :
30
- all_examples [filename ].append (os .path .join (f [0 ], filename ))
31
- else :
32
- all_examples [filename ] = [os .path .join (f [0 ], filename )]
33
- for el in els :
34
- if el .get ("filename" ) is not None :
35
- filename = el .get ("filename" )
36
- # find the file here or in examples
37
- if filename in all_examples :
38
- with open (all_examples [filename ][0 ]) as f :
39
- example_content = f .read ()
40
- example_lines = example_content .split ("\n " )
41
- for line in example_lines :
42
- codeline = BeautifulSoup ("<codeline>" + html .escape (line )+ "</codeline>" , 'xml' )
43
- el .append (codeline )
44
- return combined_content
21
+ # Unused code - but kept in case we need it in future
22
+ #def insert_example_code_from_file(combined_content):
23
+ # els = combined_content.doxygen.find_all("programlisting")
24
+ # all_examples = {}
25
+ # # get the examples path
26
+ # examples_path = re.sub(r"/scripts/.+$", "/lib/pico-examples", os.path.realpath(__file__))
27
+ # # get a recursive list of all files in examples
28
+ # for f in os.walk(examples_path):
29
+ # for filename in f[2]:
30
+ # if filename in all_examples:
31
+ # all_examples[filename].append(os.path.join(f[0], filename))
32
+ # else:
33
+ # all_examples[filename] = [os.path.join(f[0], filename)]
34
+ # for el in els:
35
+ # if el.get("filename") is not None:
36
+ # filename = el.get("filename")
37
+ # # find the file here or in examples
38
+ # if filename in all_examples:
39
+ # with open(all_examples[filename][0]) as f:
40
+ # example_content = f.read()
41
+ # example_lines = example_content.split("\n")
42
+ # for line in example_lines:
43
+ # codeline = BeautifulSoup("<codeline>"+html.escape(line)+"</codeline>", 'xml')
44
+ # el.append(codeline)
45
+ # return combined_content
45
46
46
47
def walk_and_tag_xml_tree (el , output_contexts , all_contexts ):
47
48
"""
@@ -123,7 +124,8 @@ def postprocess_doxygen_xml_file(combined_xmlfile, xmlfiles, output_context_path
123
124
els = combined_content .doxygen .find_all (True , recursive = False )
124
125
for el in els :
125
126
walk_and_tag_xml_tree (el , output_contexts , list (output_context_paths .keys ()))
126
- combined_content = insert_example_code_from_file (combined_content )
127
+ # I think this was only needed because the PICO_EXAMPLES_PATH was wrong in the Makefile
128
+ #combined_content = insert_example_code_from_file(combined_content)
127
129
return str (combined_content )
128
130
129
131
def postprocess_doxygen_xml (xml_path ):
0 commit comments