├── LICENSE ├── README.md ├── get_qt_docs.py └── .github └── workflows └── qt_autobuild.yml /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 vzhd1701 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # qt-documentation-chm-autoupdated 2 | [![Qt Docs Version](https://img.shields.io/github/v/release/vzhd1701/qt-documentation-chm-autoupdated?color=%230F&label=Qt%20Docs)](https://github.com/vzhd1701/qt-documentation-chm-autoupdated/releases/latest) 3 | [![Qt Docs autobuild](https://github.com/vzhd1701/qt-documentation-chm-autoupdated/actions/workflows/qt_autobuild.yml/badge.svg)](https://github.com/vzhd1701/qt-documentation-chm-autoupdated/actions/workflows/qt_autobuild.yml) 4 | 5 | [**Download Qt Documentation CHM 6.4.2**](https://github.com/vzhd1701/qt-documentation-chm-autoupdated/releases/latest) 6 | 7 | This repository will be automatically updated after each official Qt release. 8 | 9 | ## Workflow 10 | 11 | The basic idea is to use CI to download latest Qt Docs pre-built in HTML format from the [official SDK repository](https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/) (*_src_doc_examples directories), convert them into CHM project using [qt-documentation-chm](https://github.com/vzhd1701/qt-documentation-chm), compile CHM file with Microsoft® HTML Help Compiler from [HTML Help Workshop](https://docs.microsoft.com/en-us/previous-versions/windows/desktop/htmlhelp/microsoft-html-help-downloads) and upload it as a new release for this repository. 12 | 13 | ## Helper scripts 14 | 15 | ### build_docs.sh 16 | 17 | Builds the CHM file from the documentation of select Qt release 18 | 19 | ### get_qt_docs.py 20 | 21 | ``` 22 | usage: get_qt_docs.py [-h] (--latest-version | --docs-latest | --docs VERSION) 23 | 24 | optional arguments: 25 | -h, --help show this help message and exit 26 | --latest-version get latest Qt version number 27 | --docs-latest get list of URLs for latest version of Qt documentation archives 28 | --docs VERSION get list of URLs for selected version of Qt documentation archives 29 | ``` 30 | -------------------------------------------------------------------------------- /get_qt_docs.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import re 3 | import urllib 4 | 5 | import bs4 6 | 7 | 8 | def get_last_version(): 9 | qt_release_repo = "https://download.qt.io/official_releases/qt/" 10 | 11 | with urllib.request.urlopen(qt_release_repo) as p: 12 | page = bs4.BeautifulSoup(p.read(), 'html5lib') 13 | 14 | major_version_dir = page.find('table').find_all('tr')[3].find('a').get('href') 15 | major_version_dir_url = urllib.parse.urljoin(qt_release_repo, major_version_dir) 16 | 17 | with urllib.request.urlopen(major_version_dir_url) as p: 18 | page = bs4.BeautifulSoup(p.read(), 'html5lib') 19 | 20 | latest_version = page.find('table').find_all('tr')[3].find('a').text[:-1] 21 | 22 | return latest_version 23 | 24 | def get_docs_urls(qt_version): 25 | qt_version_flat = qt_version.replace('.', '') 26 | qt_version_major = qt_version_flat[0] 27 | qt_docs_repo_root = f"https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt{qt_version_major}_{qt_version_flat}_src_doc_examples" 28 | qt_docs_repo_xml = f"{qt_docs_repo_root}/Updates.xml" 29 | 30 | try: 31 | with urllib.request.urlopen(qt_docs_repo_xml) as p: 32 | page = bs4.BeautifulSoup(p.read(), 'xml') 33 | except urllib.error.HTTPError as e: 34 | if e.code == 404: 35 | raise ValueError(f"Documentation repository XML for Qt v.{qt_version} not found!") from e 36 | 37 | packages = [p.parent for p in page.find_all("Name", text=re.compile("^qt\..*?\.doc(\..*)?$"))] 38 | 39 | docs_urls = [] 40 | for package in packages: 41 | package_name = package.find("Name").text 42 | package_version = package.find("Version").text 43 | package_archives = [p.strip() for p in package.find("DownloadableArchives").text.split(",") if p.strip()] 44 | 45 | for archive_name in package_archives: 46 | docs_urls.append(f"{qt_docs_repo_root}/{package_name}/{package_version}{archive_name}") 47 | 48 | if not docs_urls: 49 | raise RuntimeError(f"No documentation archives for Qt v.{qt_version} found!") 50 | 51 | return docs_urls 52 | 53 | if __name__ == '__main__': 54 | parser = argparse.ArgumentParser() 55 | group = parser.add_mutually_exclusive_group(required=True) 56 | group.add_argument('--latest-version', action='store_true', help="get latest Qt version number") 57 | group.add_argument('--docs-latest', action='store_true', help="get list of URLs for latest version of Qt documentation archives") 58 | group.add_argument('--docs', metavar='VERSION', help="get list of URLs for selected version of Qt documentation archives") 59 | args = vars(parser.parse_args()) 60 | 61 | if args['latest_version']: 62 | print(get_last_version()) 63 | if args['docs_latest']: 64 | version = get_last_version() 65 | docs_urls = get_docs_urls(version) 66 | 67 | for url in docs_urls: 68 | print(url) 69 | if args['docs']: 70 | docs_urls = get_docs_urls(args['docs']) 71 | 72 | for url in docs_urls: 73 | print(url) 74 | -------------------------------------------------------------------------------- /.github/workflows/qt_autobuild.yml: -------------------------------------------------------------------------------- 1 | name: Qt Docs autobuild 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: '0 5 * * *' 7 | 8 | jobs: 9 | check_version: 10 | runs-on: ubuntu-latest 11 | outputs: 12 | version_current: ${{ steps.previoustag.outputs.tag }} 13 | version_new: ${{ steps.version_new.outputs.version }} 14 | steps: 15 | - name: Checkout repository 16 | uses: actions/checkout@v2 17 | with: 18 | fetch-depth: 0 19 | 20 | - name: 'Get Previous tag' 21 | id: previoustag 22 | uses: "WyriHaximus/github-action-get-previous-tag@v1" 23 | 24 | - name: Set up Python 25 | uses: actions/setup-python@v2 26 | with: 27 | python-version: 3.8 28 | 29 | - name: Install dependencies 30 | run: | 31 | python -m pip install --upgrade pip 32 | pip install html5lib beautifulsoup4 33 | 34 | - name: Get latest Qt version 35 | id: version_new 36 | run: echo "::set-output name=version::$(python get_qt_docs.py --latest-version)" 37 | 38 | - name: Sanity check, check if latest version > current 39 | if: steps.version_new.outputs.version != steps.previoustag.outputs.tag 40 | run: | 41 | function ver { printf "%03d%03d%03d%03d" $(echo "$1" | tr '.' ' '); } 42 | [ $(ver ${{ steps.version_new.outputs.version }}) -gt $(ver ${{ steps.previoustag.outputs.tag }}) ] 43 | 44 | build: 45 | needs: check_version 46 | if: needs.check_version.outputs.version_current != needs.check_version.outputs.version_new 47 | runs-on: windows-latest 48 | env: 49 | VERSION_CURRENT: ${{ needs.check_version.outputs.version_current }} 50 | VERSION_NEW: ${{ needs.check_version.outputs.version_new }} 51 | steps: 52 | - name: Checkout repository 53 | uses: actions/checkout@v2 54 | 55 | - name: Checkout qt-documentation-chm 56 | uses: actions/checkout@v2 57 | with: 58 | repository: vzhd1701/qt-documentation-chm 59 | path: qt-documentation-chm 60 | 61 | - name: Set up Python 62 | uses: actions/setup-python@v2 63 | with: 64 | python-version: 3.8 65 | 66 | - name: Install dependencies 67 | run: | 68 | python -m pip install --upgrade pip 69 | pip install lxml path html5lib bs4 libsass 70 | choco install aria2 wget 71 | 72 | - name: Build Qt docs 73 | run: bash build_docs.sh ${{ env.VERSION_NEW }} 74 | 75 | - name: Update Qt version in readme 76 | run: sed -i "s/^\[\*\*Download Qt Documentation CHM.*\*\*\]/[**Download Qt Documentation CHM ${{ env.VERSION_NEW }}**]/" README.md 77 | 78 | - name: Commit changes & create tag 79 | uses: EndBug/add-and-commit@v7.2.0 80 | with: 81 | message: "(autoupdate) update Qt Docs version ${{ env.VERSION_CURRENT }} -> ${{ env.VERSION_NEW }}" 82 | add: "README.md" 83 | tag: ${{ env.VERSION_NEW }} 84 | 85 | - name: Create release 86 | uses: ncipollo/release-action@v1 87 | with: 88 | body: "Qt Docs ${{ env.VERSION_NEW }} CHM (update from ${{ env.VERSION_CURRENT }})" 89 | artifacts: "*.zip" 90 | tag: ${{ env.VERSION_NEW }} 91 | token: ${{ secrets.GITHUB_TOKEN }} 92 | --------------------------------------------------------------------------------