VirtualBox

Ignore:
Timestamp:
Feb 21, 2023 3:39:02 PM (22 months ago)
Author:
vboxsync
Message:

Docs: bugref:10302. A small modification in htmlhelp-qthelp script to get TOC and list file names as command line arguments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/htmlhelp-qthelp.py

    r98103 r98678  
    1717else:
    1818    from HTMLParser import HTMLParser
     19
    1920
    2021
     
    9192    return image_files_list
    9293
    93 # open htmlhelp.hhp files and read the list of html files from there
    94 def create_html_list(folder):
     94# open files list and read the list of html files from there
     95def create_html_list(folder, list_file):
    9596    global html_files
    96     file_name = 'htmlhelp.hhp'
    9797    html_file_lines = []
    98     if not file_name in os.listdir(folder):
    99         logging.error('Could not find the file "%s" in "%s"', file_name, folder)
     98    if not list_file in os.listdir(folder):
     99        logging.error('Could not find the file "%s" in "%s"', list_file, folder)
    100100        return html_file_lines
    101     full_path = os.path.join(folder, 'htmlhelp.hhp')
     101    full_path = os.path.join(folder, list_file)
    102102    file = codecs.open(full_path, encoding='iso-8859-1')
    103103
     
    118118
    119119
    120 def create_files_section(folder):
     120def create_files_section(folder, list_file):
    121121    files_section_lines = ['<files>']
    122122    files_section_lines += create_image_list(folder)
    123     files_section_lines += create_html_list(folder)
     123    files_section_lines += create_html_list(folder, list_file)
    124124    files_section_lines.append('</files>')
    125125    return files_section_lines
     
    188188    return result
    189189
    190 # parse toc.hhc file. assuming all the relevant information
     190# parse TOC file. assuming all the relevant information
    191191# is stored in tags and attributes. whatever is outside of
    192192# <... > pairs is filtered out. we also assume < ..> are not nested
    193193# and each < matches to a >
    194 def create_toc(folder):
    195     toc_file = 'toc.hhc'
     194def create_toc(folder, toc_file):
     195    toc_string_list = []
    196196    content = [x[2] for x in os.walk(folder)]
    197197    if toc_file not in content[0]:
     
    219219    # content = re.sub(r'>.*?<', r'>\n<', content)
    220220    # lines = content.split('\n')
    221     toc_string_list = ['<toc>']
     221    toc_string_list.append('<toc>')
    222222    index = 0
    223223    for tag in tag_list:
     
    238238    helphtmlfolder = ''
    239239    output_filename = ''
     240    list_file = ''
     241    toc_file = ''
    240242    try:
    241         opts, args = getopt.getopt(sys.argv[1:],"hd:o:")
     243        opts, args = getopt.getopt(sys.argv[1:],"hd:o:f:t:")
    242244    except getopt.GetoptError as err:
    243245        print(err)
     
    248250        elif opt in ("-d"):
    249251            helphtmlfolder = arg
     252            print(helphtmlfolder)
     253        elif opt in ("-f"):
     254            list_file = arg
     255        elif opt in ("-t"):
     256            toc_file = arg
     257            print(toc_file)
    250258        elif opt in ("-o"):
    251259             output_filename = arg
     
    270278                     '<virtualFolder>doc</virtualFolder>', \
    271279                     '<filterSection>']
    272     out_xml_lines += create_toc(helphtmlfolder) + create_files_section(helphtmlfolder)
     280    out_xml_lines += create_toc(helphtmlfolder, toc_file) + create_files_section(helphtmlfolder, list_file)
    273281    out_xml_lines += create_keywords_section(helphtmlfolder)
    274282    out_xml_lines += ['</filterSection>', '</QtHelpProject>']
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette