Changeset 86895 in vbox
- Timestamp:
- Nov 16, 2020 4:46:13 PM (4 years ago)
- File:
-
- 1 edited
-
trunk/doc/manual/htmlhelp-qthelp.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/manual/htmlhelp-qthelp.py
r86707 r86895 12 12 import codecs 13 13 import logging 14 from HTMLParser import HTMLParser 14 15 15 16 __copyright__ = \ … … 29 30 # number of opened and not yet closed section tags of toc section 30 31 open_section_tags = 0 32 33 html_files = [] 34 35 class html_parser(HTMLParser): 36 def __init__(self): 37 HTMLParser.__init__(self) 38 self.a_tag=[] 39 40 def handle_starttag(self, tag, attributes): 41 if tag != 'div' and tag != 'a': 42 return 43 if tag == 'a': 44 for a in attributes: 45 if a[0] == 'name': 46 self.a_tag.append(a[1]) 47 48 # use html_parser stuff to collect <a name tags 49 def create_keywords_section(folder): 50 keywords_section_lines = ['<keywords>'] 51 for html_file_name in html_files: 52 full_html_path = os.path.join(folder, html_file_name) 53 file_content = open(full_html_path, 'r').read() 54 parser = html_parser() 55 parser.feed(file_content) 56 for k in parser.a_tag: 57 line = '<keyword name="' + k + '" id="' + k + '" ref="' + html_file_name + '#' + k + '"/>' 58 keywords_section_lines.append(line); 59 keywords_section_lines.append('</keywords>') 60 return keywords_section_lines 31 61 32 62 # find the png files under /images folder and create a part of the … … 49 79 # open htmlhelp.hhp files and read the list of html files from there 50 80 def create_html_list(folder): 81 global html_files 51 82 file_name = 'htmlhelp.hhp' 52 html_file s_list= []83 html_file_lines = [] 53 84 if not file_name in os.listdir(folder): 54 85 logging.error('Could not find the file "%s" in "%s"', file_name, folder) 55 return html_file s_list86 return html_file_lines 56 87 full_path = os.path.join(folder, 'htmlhelp.hhp') 57 88 file = open(full_path, "r") … … 67 98 continue 68 99 if '.html' in line: 69 html_files_list.append('<file>' + line.strip('\n') + '</file>') 70 return html_files_list 100 html_file_lines.append('<file>' + line.strip('\n') + '</file>') 101 html_files.append(line.strip('\n')) 102 return html_file_lines 71 103 72 104 … … 142 174 return result 143 175 144 # parse toc.hhc file. assuming all the relevant information s176 # parse toc.hhc file. assuming all the relevant information 145 177 # is stored in tags and attributes. data "whatever is outside of 146 178 # <... > pairs is filtered out. we also assume < ..> are not nested 147 179 # and each < matches to a > 148 def parse_toc(folder):180 def create_toc(folder): 149 181 toc_file = 'toc.hhc' 150 182 content = [x[2] for x in os.walk(folder)] … … 224 256 '<virtualFolder>doc</virtualFolder>', \ 225 257 '<filterSection>'] 226 out_xml_lines += parse_toc(helphtmlfolder) + create_files_section(helphtmlfolder) 258 out_xml_lines += create_toc(helphtmlfolder) + create_files_section(helphtmlfolder) 259 out_xml_lines += create_keywords_section(helphtmlfolder) 227 260 out_xml_lines += ['</filterSection>', '</QtHelpProject>'] 228 261
Note:
See TracChangeset
for help on using the changeset viewer.

