API

db2qthelp - a DocBook book to QtHelp project converter

Db2QtHelp

__init__(qt_path, xsltproc_path, css_definition, qhp_template)

Contructor

Parameters:
  • qt_path (str) –

    Path to the Qt binaries

  • xsltproc_path (str) –

    Path to the xsltproc binary

  • css_definition (str) –

    CSS definition to use

  • qhp_template (str) –

    Template for the .qhp file

_get_id(html)

Return the docbook ID of the current section.

The value of the first a-element's name attribute is assumed to be the docbook ID.

Parameters:
  • html (str) –

    The HTML snippet to get the next docbook ID from

Returns:
  • str

    The next ID found in the snippet

_get_name(html)

Return the name of the current section.

Parameters:
  • html (str) –

    The HTML snippet to get the next name from

Returns:
  • str

    The next name found in the snippet

_get_title(html)

Return the name of the current section.

Parameters:
  • html (str) –

    The HTML snippet to get the next name from

Returns:
  • str

    The next name found in the snippet

Extracts references to images; patches links to point to main document folder

Parameters:
  • doc (str) –

    The HTML document to process

  • app_name (str) –

    The application name

  • files (Set[str]) –

    The container to store links into

Returns:
  • str

    The changed document

_write_sections_recursive(html, dst_folder, pages, level)

Writes the given section and it's sub-sections recursively.

The id and the name of the section are retrieved, first.

Then, the toc HTML file is extended and the reference to this section is appended to the returned toc. Keywords are extended by the section's name.

The section is then split along the '<div class="sect<INDENT>">' elements which are processed recursively.

The (recursively) collected keywords and toc are returned.

Parameters:
  • html (str) –

    The (string) content of the DocBook book section or appendix

  • dst_folder (str) –

    The folder to write the section into

  • pages (List[Tuple[str, str]]) –

    The list of HTML sections to fill

  • level (int) –

    intendation level

_process_single(source, dst_folder, pages, files, app_name)

Processes a single (not chunked) HTML document generated by docbook

Parameters:
  • source (str) –

    The HTML document to process

  • dst_folder (str) –

    The folder to write the section into

  • pages (List[Tuple[str, str]]) –

    The list of HTML sections to fill

  • files (Set[str]) –

    The set of referenced files (images) to fill

  • app_name (str) –

    The application name

_generate_html(source, folder)

Generates a chunked HTML document from the source docbook document

Parameters:
  • source (str) –

    The XML DocBook document to process

  • folder (str) –

    A (temporary) folder to store the xsltproc output to

_process_chunked(folder, pages, files, app_name, dst_folder)

Processes a the set of HTML documents generated by chunking docbook

Parameters:
  • folder (str) –

    A (temporary) folder to store the xsltproc output to

  • pages (List[Tuple[str, str]]) –

    The list of HTML sections to fill

  • files (Set[str]) –

    The set of referenced files (images) to fill

  • app_name (str) –

    The application name

_copy_files(files, source, dst_folder)

Copies referenced files into the destination folder

Parameters:
  • files (Set[str]) –

    The files to compy

  • source (str) –

    The origin folder

  • dst_folder (str) –

    The destination folder

build_toc_sections(pages)

Generates a hierarchical list of pages to be embedded in the toc-section of the qhp-file.

Parameters:
  • pages (List[Tuple[str, str, List[int]]]) –

    The sorted list of pages

Returns:
  • str

    The pages formatted as toc-sections

process(source, dst_folder, app_name)

Performs the conversion

Parameters:
  • source (str) –

    The input file or folder

  • dst_folder (str) –

    The destination folder (where the documentation is built)

  • app_name (str) –

    The name of the application

main(arguments=None)

The main method using parameter from the command line.

Parameters:
  • arguments (List[str], default: None ) –

    A list of command line arguments.

Returns:
  • int

    The exit code (0 for success).

script_run()

Execute from command line.