diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..c7bcf91 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,108 @@ +name: Build-Documentation + +on: + # Trigger the workflow every night + schedule: + - cron: '0 1 * * *' + + # Trigger on push to master and for pull requests targetting master + push: + branches: [ master ] + + pull_request: + branches: [ master ] + + # Trigger manually from the Actions tab + workflow_dispatch: + +jobs: + build-documentation: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + steps: + - name: Check-out the repository under $GITHUB_WORKSPACE + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install prerequisites from the README + run: sudo apt install python qttools5-dev-tools wkhtmltopdf python-pypdf2 inkscape + + - name: Print versions + run: | + python2 --version || true + wkhtmltopdf --version --version || true + qhelpgenerator --qt=qt4 --version || true + + # GitHub Actions currently uses 18.04 as of 02021-01-31, but will likely update in the future + - name: Try to install prerequisites for Ubuntu 20.04 from the README + run: sudo apt install qhelpgenerator-qt5 || true + + - name: Install prerequisites for testing + run: sudo apt install xvfb + +# - name: Remove existing downloads (for now, because the update.py script seems to not work well) +# run: | +# rm -rf localwiki revisions.txt updates.txt wikifiles.txt +# mkdir localwiki +# touch revisions.txt updates.txt wikifiles.txt + + - name: Build an index file containing a list of all the files to download + run: python2 ./buildwikiindex.py + + - name: Download wiki pages + # Redirect log because it seems we exceed the amount of data GitHub is willing + # to show in the interacive logs and there seems to be no UI to access the raw + # logs at this time + #run: python2 ./downloadwiki.py > ./downloadwiki.py.log + run: python2 ./downloadwiki.py + + - name: Create a list of revision IDs for each page + run: python2 ./update.py + + - name: Get a list of pages that have changed + run: python2 ./update.py + + - name: Download the changed pages (and all their dependencies) again + run: python2 ./update.py + + - name: Generate freecad.qhc and freecad.qch files + run: python2 ./buildqhelp.py --non-interactive + + - name: Generate freecad.pdf + run: python2 ./buildpdf.py + + - name: Split the generated freecad.qch into parts that are smaller than 50Mb (github limit) + run: split -d --byte=49M localwiki/freecad.qch localwiki/freecad.qch.part + + - name: Reassemble the previously-split freecad.qch + run: cat localwiki/freecad.qch.part* >> test.qch + + - name: Check that the reassembled test.qch is identical to localwiki/freecad.qch + run: diff -q test.qch localwiki/freecad.qch + + - name: Try to open the .qch file + run: | + xvfb-run assistant -collectionFile localwiki/freecad.qhc & + sleep 5 + killall assistant + + - name: Upload freecad.qch + uses: actions/upload-artifact@v2 + with: + name: freecad.qch + path: localwiki/freecad.qch + + - name: Upload freecad.qhc + uses: actions/upload-artifact@v2 + with: + name: freecad.qhc + path: localwiki/freecad.qhc + + - name: Upload freecad.pdf + uses: actions/upload-artifact@v2 + with: + name: freecad.pdf + path: localwiki/freecad.pdf + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0491981 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/*.pyc +/__pycache__ diff --git a/buildpdf.py b/buildpdf.py index 0d987a3..1d4f595 100755 --- a/buildpdf.py +++ b/buildpdf.py @@ -472,7 +472,7 @@ def joinpdf(): result = PdfFileWriter() createCover() - inputfile = PdfFileReader(open(FOLDER+os.sep+'Cover.pdf','rb')) + inputfile = PdfFileReader(open(os.path.join(FOLDER,'Cover.pdf'),'rb')) result.addPage(inputfile.getPage(0)) count = 1 @@ -547,11 +547,14 @@ def createCover(): "downloads and creates a cover page" if VERBOSE: print("fetching " + COVER) data = (urlopen(COVER).read()) - path = FOLDER + os.sep + "Cover.svg" + path = os.path.join(FOLDER, "Cover.svg") fil = open(path,'wb') fil.write(data) fil.close() - os.system('inkscape --export-pdf='+FOLDER+os.sep+'Cover.pdf'+' '+FOLDER+os.sep+'Cover.svg') + if os.system('inkscape --export-pdf='+os.path.join(FOLDER,'Cover.pdf')+' '+os.path.join(FOLDER,'Cover.svg')) == 0: + return + else: + raise Exception('Conversion of Cover.svg to Cover.pdf failed. Is Inkscape installed?') if __name__ == "__main__": diff --git a/buildqhelp.py b/buildqhelp.py index 177d4e1..66191a6 100755 --- a/buildqhelp.py +++ b/buildqhelp.py @@ -39,8 +39,8 @@ from urllib2 import urlopen, HTTPError FOLDER = "./localwiki" INDEX = "Online_Help_Toc" # the start page from where to crawl the wiki VERBOSE = True # to display what's going on. Otherwise, runs totally silent. -QHELPCOMPILER = 'qhelpgenerator' -QCOLLECTIOMGENERATOR = 'qcollectiongenerator' +QHELPCOMPILER = 'qhelpgenerator -qt=qt5' +QCOLLECTIOMGENERATOR = 'qcollectiongenerator -qt=qt5' RELEASE = '0.17' # END CONFIGURATION ############################################## @@ -68,7 +68,15 @@ def crawl(): print("Error at compiling") return 1 if VERBOSE: print("All done!") - i=raw_input("Copy the files to their correct location in the source tree? y/n (default=no) ") + if "--yes-copy" in sys.argv: + i="yes" + elif "--no-copy" in sys.argv: + i="no" + else: + try: + i=raw_input("Copy the files to their correct location in the source tree? y/n (default=no) ") + except: + i="no" if i.upper() in ["Y","YES"]: shutil.copy("localwiki/freecad.qch","../../Doc/freecad.qch") shutil.copy("localwiki/freecad.qhc","../../Doc/freecad.qhc") @@ -82,6 +90,9 @@ def compile(qhpfile): if not os.system(QHELPCOMPILER + ' '+qhpfile+' -o '+qchfile): if VERBOSE: print("Successfully created",qchfile) return 0 + else: + os.system('cat -v ' + qhpfile) + raise "Error during generation of freecad.qch" def generate(qhcpfile): "generates qassistant-specific settings like icon, title, ..." @@ -96,6 +107,9 @@ def generate(qhcpfile): if not os.system(QCOLLECTIOMGENERATOR+' '+qhcpfile+' -o '+qhcfile): if VERBOSE: print("Successfully created ",qhcfile) return 0 + else: + os.system('cat -v ' + qhcpfile) + raise "Error during generation of freecad.qhc" def createCollProjectFile(): qprojectfile = ''' @@ -234,5 +248,5 @@ def buildtoc(): return qfilename if __name__ == "__main__": - crawl() + exit(crawl())