Skip to content

Instantly share code, notes, and snippets.

@taktoa
Last active January 3, 2017 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taktoa/2ee1253020d81341f7d4377771c418b7 to your computer and use it in GitHub Desktop.
Save taktoa/2ee1253020d81341f7d4377771c418b7 to your computer and use it in GitHub Desktop.
Generate QDocIndex XML from a C++ project with the generateXML function defined in `generate-xml.bash`. Run `example-qdocindex-usage.bash` to see the output for qtbase with the given `index.qdocconf` (which currently needs to be modified for other C++ projects).
#!/usr/bin/env bash
# Download this gist to get index.qdocconf and generate-xml.bash
git clone https://gist.github.com/taktoa/2ee1253020d81341f7d4377771c418b7 gist
source ./gist/generate-xml.bash
move ./gist/index.qdocconf .
rmDir ./gist
# Make a folder called "qtbase" containing a source checkout of qtbase
export QT_VERSION="5.6.1-1"
curl "https://github.com/qt/qtbase/archive/v${QT_VERSION}.tar.gz" > qtbase.tgz
tar -xf qtbase.tgz 1>&2
move "qtbase-${QT_VERSION}" qtbase
# Run generateXML
generateXML ./qtbase ./index.qdocconf > index.xml
# Clean up
rmDir ./qtbase
rmFile ./index.qdocconf
source libtaktoa.bash
function generateXML () {
(( $# == 2 )) || { fail "generateXML: wrong number of args"; return 1; }
REPOROOT="$(readlink -f "${1}")"
QDOCCONF="$(readlink -f "${2}")"
test -d "${REPOROOT}" || {
fail "generateXML: ${REPOROOT} is not a directory"; return 2;
}
test -f "${QDOCCONF}" || {
fail "generateXML: ${QDOCCONF} is not a file"; return 3;
}
test -r "${QDOCCONF}" || {
fail "generateXML: ${QDOCCONF} is not readable"; return 4;
}
# Note: a lot of this is specific to qtbase and the contents of the provided
# index.qdocconf file, and should be made more general.
OLD_WD="$(pwd)"
copy "${QDOCCONF}" "${REPOROOT}/src/"
cd "${REPOROOT}"
makeDir "${REPOROOT}" temp
cd src
qdoc --prepare --log-progress "${QDOCCONF}"
cd ..
cat temp/.index
rmDir temp
cd "${OLD_WD}"
return 0
}
headers.fileextensions = "*.ch *.h *.h++ *.hh *.hpp *.hxx"
sources.fileextensions = "*.c++ *.cc *.cpp *.cxx *.mm *.qml *.qdoc"
depends = activeqt qtdbus qtgui \
qtwidgets qtnetwork \
qtdoc qtmacextras \
qtquick qtlinguist \
qtdesigner qtconcurrent \
qtxml qmake qtwinextras \
qtqml
outputdir = ../temp
sourcedirs = ./concurrent \
./corelib \
./dbus \
./gui \
./network \
./opengl \
./platformheaders \
./printsupport \
./sql \
./testlib \
./widgets \
./xml
headerdirs = ./concurrent \
./corelib \
./dbus \
./gui \
./network \
./opengl \
./platformheaders \
./printsupport \
./sql \
./testlib \
./widgets \
./xml
generateindex = true
function fail () { printf "$@" 1>&2; }
function move () {
{ (( $# == 2 )) || { fail "move: wrong number of args"; return 1; }
test -r "$1" || { fail "move: not readable: $1"; return 2; }
test -w "$1" || { fail "move: not writable: $1"; return 3; }
mv -v "$1" "$2"
} 1>&2
}
function copy () {
{ (( $# == 2 )) || { fail "copy: wrong number of args"; return 1; }
test -r "$1" || { fail "copy: not readable: $1"; return 2; }
cp -v -R "$1" "$2"
} 1>&2
}
function rmFile () {
{ (( $# == 1 )) || { fail "rmFile: wrong number of args"; return 1; }
test -f "$1" || { fail "rmFile: not a file: $1"; return 2; }
test -w "$1" || { fail "rmFile: not writable: $1"; return 3; }
rm -v "$1"
} 1>&2
}
function rmDir () {
{ (( $# == 1 )) || { fail "rmDir: wrong number of args"; return 1; }
test -d "$1" || { fail "rmDir: not a directory: $1"; return 2; }
test -w "$1" || { fail "rmDir: not writable: $1"; return 3; }
rm -rfv "$1"
} 1>&2
}
function makeDir () {
{ (( $# == 2 )) || { fail "makeDir: wrong number of args"; return 1; }
test -d "$1" || { fail "makeDir: not a directory: $1"; return 2; }
test -w "$1" || { fail "makeDir: not writable: $1"; return 3; }
test -e "$1/$2" || { fail "makeDir: already exists: $1/$2"; return 4; }
mkdir -v "$1/$2"
} 1>&2
}

Copyright © 2016 Remy Goldschmidt <taktoa@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment