From f3cc3aeb08656d9a730f9423ca6dd487b50b12fa Mon Sep 17 00:00:00 2001 From: Windel Bouwman Date: Fri, 3 Oct 2014 09:49:53 +0200 Subject: [PATCH] Initial import --- .gitignore | 5 +++ .travis.yml | 10 ++++++ README.md | 4 --- gen_django.sh | 20 +++++++++++ gen_matplotlib.sh | 24 +++++++++++++ gen_numpy.sh | 18 ++++++++++ gen_pyserial.sh | 18 ++++++++++ gen_python.sh | 18 ++++++++++ gen_scipy.sh | 18 ++++++++++ gen_sphinx.sh | 16 +++++++++ gen_tox.sh | 17 ++++++++++ make_docs.sh | 57 +++++++++++++++++++++++++++++++ qchviewer.py | 85 +++++++++++++++++++++++++++++++++++++++++++++++ readme.rst | 35 +++++++++++++++++++ todo_sympy.sh | 20 +++++++++++ 15 files changed, 361 insertions(+), 4 deletions(-) create mode 100644 .gitignore create mode 100644 .travis.yml delete mode 100644 README.md create mode 100644 gen_django.sh create mode 100644 gen_matplotlib.sh create mode 100644 gen_numpy.sh create mode 100644 gen_pyserial.sh create mode 100644 gen_python.sh create mode 100644 gen_scipy.sh create mode 100644 gen_sphinx.sh create mode 100644 gen_tox.sh create mode 100755 make_docs.sh create mode 100644 qchviewer.py create mode 100644 readme.rst create mode 100644 todo_sympy.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2835842 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ + +src +docs +build + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e6b76ba --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ + +install: + - sudo apt-get update + - sudo apt-get install qt4-dev-tools python-numpy python-scipy + - sudo apt-het install python-sphinx python-matplotlib zip + - sudo apt-get install python-sympy python-qt4 xvfb + - pip install numpydoc +script: + - ./make_docs.sh +# - ./shoot.sh diff --git a/README.md b/README.md deleted file mode 100644 index 371430c..0000000 --- a/README.md +++ /dev/null @@ -1,4 +0,0 @@ -qthelpdocs -========== - -Qt compressed help docs of various projects using sphinx diff --git a/gen_django.sh b/gen_django.sh new file mode 100644 index 0000000..d856926 --- /dev/null +++ b/gen_django.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e + +VER=1.7 + +if [[ ! -f build/django-${VER}/docs/build/qthelp/Django.qhp ]]; then + echo "Building django docs" + if [[ ! -f src/django-${VER}.tar.gz ]]; then + echo "Downloading django" + curl -L -o src/django-${VER}.tar.gz https://github.com/django/django/archive/${VER}.tar.gz + fi + + cd build + tar xzf "../src/django-${VER}.tar.gz" + + cd django-${VER}/docs + sphinx-build -b qthelp . build/qthelp + cd ../../.. +fi diff --git a/gen_matplotlib.sh b/gen_matplotlib.sh new file mode 100644 index 0000000..2c294b5 --- /dev/null +++ b/gen_matplotlib.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -e + +if [[ ! -f build/matplotlib-1.4.0/doc/build/qthelp/Matplotlib.qhp ]]; then + echo "Building matplotlib docs" + if [[ ! -f src/matplotlib-1.4.0.tar.gz ]]; then + echo "Downloading matplotlib" + # Use -L for redirect of sourcefourge + curl -L -o src/matplotlib-1.4.0.tar.gz http://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.4.0/matplotlib-1.4.0.tar.gz + fi + cd build + tar xzf ../src/matplotlib-1.4.0.tar.gz + cd matplotlib-1.4.0/doc + + # We need to run html first! + python make.py html + + # Now we can invoke qthelp generation: + sphinx-build -b qthelp -d build/doctrees . build/qthelp + + cd ../../.. +fi + diff --git a/gen_numpy.sh b/gen_numpy.sh new file mode 100644 index 0000000..3a381c7 --- /dev/null +++ b/gen_numpy.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +NUMPYVER=1.8.2 +if [[ ! -f build/numpy-$NUMPYVER/doc/build/qthelp/NumPy.qhp ]]; then + echo "Building numpy $NUMPYVER docs" + if [[ ! -f src/numpy-${NUMPYVER}.tar.gz ]]; then + echo "Downloading numpy" + # Use -L for redirect of sourcefourge + curl -L -o src/numpy-${NUMPYVER}.tar.gz http://downloads.sourceforge.net/project/numpy/NumPy/${NUMPYVER}/numpy-${NUMPYVER}.tar.gz + fi + cd build + tar xzf ../src/numpy-${NUMPYVER}.tar.gz + cd numpy-${NUMPYVER}/doc + sphinx-build -b qthelp -d build/doctree source build/qthelp + cd ../../.. +fi diff --git a/gen_pyserial.sh b/gen_pyserial.sh new file mode 100644 index 0000000..03caabd --- /dev/null +++ b/gen_pyserial.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +if [[ ! -f build/pyserial-2.7/documentation/build/qthelp/pySerial.qhp ]]; then + echo "Building pyserial docs" + if [[ ! -f src/pyserial-2.7.tar.gz ]]; then + echo "Downloading pyserial" + curl -L -o src/pyserial-2.7.tar.gz http://downloads.sourceforge.net/project/pyserial/pyserial/2.7/pyserial-2.7.tar.gz + fi + + cd build + tar xzf ../src/pyserial-2.7.tar.gz + + cd pyserial-2.7/documentation + sphinx-build -b qthelp . build/qthelp + cd ../../.. +fi diff --git a/gen_python.sh b/gen_python.sh new file mode 100644 index 0000000..e0c17a4 --- /dev/null +++ b/gen_python.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +if [[ ! -f build/Python-3.4.1/Doc/build/qthelp/Python.qhp ]]; then + echo "Building python docs" + if [[ ! -f src/Python-3.4.1.tar.xz ]]; then + echo "Downloading python" + curl -o src/Python-3.4.1.tar.xz https://www.python.org/ftp/python/3.4.1/Python-3.4.1.tar.xz + fi + + cd build + tar xJf ../src/Python-3.4.1.tar.xz + + cd Python-3.4.1/Doc + sphinx-build -b qthelp . build/qthelp + cd ../../.. +fi diff --git a/gen_scipy.sh b/gen_scipy.sh new file mode 100644 index 0000000..470e7ef --- /dev/null +++ b/gen_scipy.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + + +if [[ ! -f build/scipy-0.14.0/doc/build/qthelp/SciPy.qhp ]]; then + echo "Building scipy docs" + if [[ ! -f src/scipy-0.14.0.tar.gz ]]; then + echo "Downloading scipy" + # Use -L for redirect of sourcefourge + curl -L -o src/scipy-0.14.0.tar.gz http://downloads.sourceforge.net/project/scipy/scipy/0.14.0/scipy-0.14.0.tar.gz + fi + cd build + tar xzf ../src/scipy-0.14.0.tar.gz + cd scipy-0.14.0/doc + sphinx-build -b qthelp -d build/doctrees source build/qthelp + cd ../../.. +fi diff --git a/gen_sphinx.sh b/gen_sphinx.sh new file mode 100644 index 0000000..1da079a --- /dev/null +++ b/gen_sphinx.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +VER=1.2.3 +if [[ ! -f build/Sphinx-$VER/doc/build/qthelp/Sphinx.qhp ]]; then + if [[ ! -f src/Sphinx-${VER}.tar.gz ]]; then + # Use -L for redirect of sourcefourge + curl -L -o src/Sphinx-${VER}.tar.gz https://pypi.python.org/packages/source/S/Sphinx/Sphinx-${VER}.tar.gz + fi + cd build + tar xzf ../src/Sphinx-${VER}.tar.gz + cd Sphinx-${VER}/doc + sphinx-build -b qthelp -d build/doctree . build/qthelp + cd ../../.. +fi diff --git a/gen_tox.sh b/gen_tox.sh new file mode 100644 index 0000000..855e448 --- /dev/null +++ b/gen_tox.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +TOOL=tox +VER=1.7.2 +if [[ ! -f build/${TOOL}-$VER/doc/build/qthelp/Tox.qhp ]]; then + if [[ ! -f src/${TOOL}-${VER}.tar.gz ]]; then + # Use -L for redirect of sourcefourge + curl -L -o src/${TOOL}-${VER}.tar.gz https://bitbucket.org/hpk42/tox/get/${VER}.tar.gz + fi + cd build + tar xzf ../src/${TOOL}-${VER}.tar.gz + cd ${TOOL}-${VER}/doc + sphinx-build -b qthelp -d build/doctree . build/qthelp + cd ../../.. +fi diff --git a/make_docs.sh b/make_docs.sh new file mode 100755 index 0000000..84b3057 --- /dev/null +++ b/make_docs.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +BASH=/bin/bash + +# Quit on error: +set -e + +echo "Doing doc building" +mkdir -p src +mkdir -p build +mkdir -p docs + +set +e + +find . -maxdepth 1 -name gen_\*.sh | while read line; do + echo "Generating using file $line" + $BASH $line +done + +set -e + +echo "Collecting docs (all qt help projects)" +find build -name \*.qhp | while read line; do + echo "Adding qt help project $line" + FILENAME=$(basename $line) + QCH_FILE="docs/${FILENAME%.*}.qch" + echo "OUTPUT: $QCH_FILE" + qhelpgenerator $line -o $QCH_FILE +done + +PROJ_FILE=docs.qhcp + +cat > ${PROJ_FILE} << EOF + + + + +EOF + +find docs -name \*.qch | while read line; do + echo "Adding qch file $line" + echo "$line" >> ${PROJ_FILE} +done + +cat >> ${PROJ_FILE} << EOF + + + +EOF + +# TODO: adjust qhcp according to results.. +qcollectiongenerator ${PROJ_FILE} -o docs/docs.qhc + +rm ${PROJ_FILE} + +zip -r docs.zip docs + diff --git a/qchviewer.py b/qchviewer.py new file mode 100644 index 0000000..a95cb1b --- /dev/null +++ b/qchviewer.py @@ -0,0 +1,85 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2013, the IEP development team +# Author: Windel Bouwman +# +# IEP is distributed under the terms of the (new) BSD License. +# The full license can be found in 'license.txt'. + +""" +Display the specified qch file in qt help engine. +""" + +from pyzolib.qt import QtCore, QtGui, QtHelp +import argparse + + +class HelpBrowser(QtGui.QTextBrowser): + """ Override textbrowser to implement load resource """ + def __init__(self, engine): + super().__init__() + self._engine = engine + + def loadResource(self, typ, url): + if url.scheme() == "qthelp": + return self._engine.fileData(url) + else: + return super().loadResource(typ, url) + + +class QchViewer(QtGui.QWidget): + """ + Show help contents and browse qt help files. + """ + def __init__(self, parent=None, collection_filename='qch_viewer_docs.qhc'): + """ + Initializes an assistance instance. + When collection_file is none, it is determined from the + appDataDir. + """ + super().__init__(parent) + self.setWindowTitle('QchViewer') + self._engine = QtHelp.QHelpEngine(collection_filename) + + # The main players: + self._content = self._engine.contentWidget() + self._helpBrowser = HelpBrowser(self._engine) + + self.splitter = QtGui.QSplitter(self) + self.splitter.addWidget(self._content) + self.splitter.addWidget(self._helpBrowser) + + layout = QtGui.QVBoxLayout(self) + layout.addWidget(self.splitter) + + # Connect clicks: + self._content.linkActivated.connect(self._helpBrowser.setSource) + + self.content_model = self._engine.contentModel() + self.content_model.contentsCreated.connect(self.select_first) + + # Important, call setup data to load the files: + self._engine.setupData() + + def select_first(self): + # Select first entry: + idx = self.content_model.index(0, 0) + selection_model = self._content.selectionModel() + selection_model.select(idx, QtGui.QItemSelectionModel.Select) + self._content.activated.emit(idx) + + def add_doc(self, doc_file): + self._engine.registerDocumentation(doc_file) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('--doc_file') + args = parser.parse_args() + app = QtGui.QApplication([]) + view = QchViewer() + view.show() + view.resize(1024, 768) + view.splitter.setSizes([200, 800]) + if args.doc_file: + view.add_doc(args.doc_file) + app.exec() diff --git a/readme.rst b/readme.rst new file mode 100644 index 0000000..e50a6da --- /dev/null +++ b/readme.rst @@ -0,0 +1,35 @@ + +Welcome to qthelp docs. + +This project aims to build documentation for use in the qt assistant using +sphinx for the following projects: + + +- Python +- Numpy +- Scipy +- Sympy +- PySerial +- Matplotlib + + +Usage +----- + +To build the docs, simply run make_docs.sh. The documentation will be +generated eventually in the docs folder. The .qch files can be included +in the qt assistant for easy browsing. + +Download +-------- + +The docs are also built by drone.io: + +https://drone.io/bitbucket.org/windel/qthelpdocs/files + + +|dronestate|_ + +.. |dronestate| image:: https://drone.io/bitbucket.org/windel/qthelpdocs/status.png +.. _dronestate: https://drone.io/bitbucket.org/windel/qthelpdocs + diff --git a/todo_sympy.sh b/todo_sympy.sh new file mode 100644 index 0000000..d3bacdd --- /dev/null +++ b/todo_sympy.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e + +VER=0.7.5 + +if [[ ! -f build/sympy-${VER}/doc/build/qthelp/SymPy.qhp ]]; then + echo "Building sympy docs" + if [[ ! -f src/sympy-${VER}.tar.gz ]]; then + echo "Downloading sympy" + curl -L -o src/sympy-${VER}.tar.gz https://github.com/sympy/sympy/releases/download/sympy-${VER}/sympy-${VER}.tar.gz + fi + + cd build + tar xzf "../src/sympy-${VER}.tar.gz" + + cd sympy-${VER}/doc + sphinx-build -b qthelp src build/qthelp + cd ../../.. +fi