Commit 60cec5b1 authored by Shubham  .'s avatar Shubham .
Browse files

Fix the python script named qthelp-generator.py

parent 8479a1fd
### Steps to generate `qhp` and `qhcp`
Copy the file named `qthelp_generator.py` to the location where the `Python` HTML files exists. Then simply run the command `python qthelp_generator.py`. This script does the task of extracting the keywords from `index.hhk` and generation of QtHelp files named `qhp` and `qhcp`.
Copy the file named `qthelp_generator.py` to the location where the `Python` HTML files exists. Then simply run the command `python qthelp_generator.py`. This script does the task of extracting the keywords from `python-3.8.4-docs-html/genindex-_.html` and `genindex-all.html` and generation of QtHelp files named `qhp` and `qhcp`.
NOTE: Copy the script named `qthelp_generator.py` inside the directory `python-3.8.4-docs-html`. Official python documentation can be downloaded from https://docs.python.org/3/download.html.
### Creation of `qhc` and `qch`
......
......@@ -22,13 +22,15 @@
# and then generate QtHelp files using the keywords generated
import os
#index = open('./index.hhk', 'r')
from bs4 import BeautifulSoup
# QtHelp files
qhp = open('./help.qhp', 'w')
qhcp = open('./help.qhcp', 'w')
index = open("genindex-all.html", "r")
index2 = open("genindex-_.html", "r")
#######################################
#code for generation of QtHelp files##
######################################
......@@ -75,8 +77,30 @@ qhp.writelines("""<?xml version="1.0" encoding="UTF-8"?>
</toc>\n
<keywords>""")
## write code for the keywords section
# code to write keywords to qhp file
html = index.read()
soup = BeautifulSoup(html, features='html.parser')
for i in soup.find_all('a'):
keyword = i.text
link = i['href']
line = '<keyword name = "{}" ref = "{}"/>\n'.format(keyword, link)
## replace the characters which produces error while qhcp file
line = line.replace("<", "").replace("&", "")
qhp.write(line)
html2 = index2.read()
soup2 = BeautifulSoup(html, features='html.parser')
for i in soup2.find_all('a'):
keyword = i.text
link = i['href']
line = '<keyword name = "{}" ref = "{}"/>\n'.format(keyword, link)
## replace the characters which produces error while qhcp file
line = line.replace("<", "").replace("&", "")
qhp.write(line)
# write the tail
qhp.writelines("""</keywords>
......@@ -127,6 +151,7 @@ qhcp.writelines("""<?xml version="1.0" encoding="utf-8" ?>
stream = os.popen('qhelpgenerator help.qhcp -o help.qhc')
#index.close()
qhp.close()
qhcp.close()
index.close()
index2.close()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment