Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
windelbouwman committed Oct 3, 2014
1 parent ce65a60 commit f3cc3ae
Show file tree
Hide file tree
Showing 15 changed files with 361 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

src
docs
build

10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 0 additions & 4 deletions README.md

This file was deleted.

20 changes: 20 additions & 0 deletions gen_django.sh
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions gen_matplotlib.sh
Original file line number Diff line number Diff line change
@@ -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

18 changes: 18 additions & 0 deletions gen_numpy.sh
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions gen_pyserial.sh
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions gen_python.sh
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions gen_scipy.sh
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions gen_sphinx.sh
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions gen_tox.sh
Original file line number Diff line number Diff line change
@@ -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
57 changes: 57 additions & 0 deletions make_docs.sh
Original file line number Diff line number Diff line change
@@ -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
<?xml version="1.0" encoding="utf-8" ?>
<QHelpCollectionProject version="1.0">
<docFiles>
<register>
EOF

find docs -name \*.qch | while read line; do
echo "Adding qch file $line"
echo "<file>$line</file>" >> ${PROJ_FILE}
done

cat >> ${PROJ_FILE} << EOF
</register>
</docFiles>
</QHelpCollectionProject>
EOF

# TODO: adjust qhcp according to results..
qcollectiongenerator ${PROJ_FILE} -o docs/docs.qhc

rm ${PROJ_FILE}

zip -r docs.zip docs

85 changes: 85 additions & 0 deletions qchviewer.py
Original file line number Diff line number Diff line change
@@ -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()
35 changes: 35 additions & 0 deletions readme.rst
Original file line number Diff line number Diff line change
@@ -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

20 changes: 20 additions & 0 deletions todo_sympy.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f3cc3ae

Please sign in to comment.