From afe96d1aea5b396445e053dda51bf0dee4ba0071 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Mon, 14 May 2012 20:31:03 +0000 Subject: [PATCH] Generating documentation with gtk-doc --- Makefile | 9 ++- doc/Makefile | 40 +++++++++++ doc/gtkdoc.sh | 136 +++++++++++++++++++++++++++++++++++++ doc/gtkdoc/Makefile | 13 ++++ doc/gtkdoc/libApp-docs.xml | 38 +++++++++++ doc/gtkdoc/project.conf | 1 + doc/project.conf | 17 +++++ project.conf | 2 +- 8 files changed, 254 insertions(+), 2 deletions(-) create mode 100644 doc/Makefile create mode 100755 doc/gtkdoc.sh create mode 100644 doc/gtkdoc/Makefile create mode 100644 doc/gtkdoc/libApp-docs.xml create mode 100644 doc/gtkdoc/project.conf create mode 100644 doc/project.conf diff --git a/Makefile b/Makefile index b98a9cc..7ebcea3 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ PACKAGE = libApp VERSION = 0.1.5 -SUBDIRS = data include src tools +SUBDIRS = data doc include src tools RM ?= rm -f LN ?= ln -f TAR ?= tar -czvf @@ -25,6 +25,13 @@ dist: $(PACKAGE)-$(VERSION)/data/libApp.pc.in \ $(PACKAGE)-$(VERSION)/data/pkgconfig.sh \ $(PACKAGE)-$(VERSION)/data/project.conf \ + $(PACKAGE)-$(VERSION)/doc/Makefile \ + $(PACKAGE)-$(VERSION)/doc/GRAMMAR \ + $(PACKAGE)-$(VERSION)/doc/gtkdoc.sh \ + $(PACKAGE)-$(VERSION)/doc/project.conf \ + $(PACKAGE)-$(VERSION)/doc/gtkdoc/Makefile \ + $(PACKAGE)-$(VERSION)/doc/gtkdoc/libApp-docs.xml \ + $(PACKAGE)-$(VERSION)/doc/gtkdoc/project.conf \ $(PACKAGE)-$(VERSION)/include/Makefile \ $(PACKAGE)-$(VERSION)/include/project.conf \ $(PACKAGE)-$(VERSION)/include/System/App.h \ diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..cd3ec3e --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,40 @@ +SUBDIRS = gtkdoc +TARGETS = gtkdoc/libApp.types gtkdoc/sgml.stamp html/index.html +PREFIX = /usr/local +DESTDIR = +RM ?= rm -f +LN ?= ln -f +MKDIR ?= mkdir -p +INSTALL ?= install + + +all: subdirs $(TARGETS) + +subdirs: + @for i in $(SUBDIRS); do (cd $$i && $(MAKE)) || exit; done + +gtkdoc/libApp.types: + ./gtkdoc.sh -P "$(PREFIX)" -- "gtkdoc/libApp.types" + +gtkdoc/sgml.stamp: gtkdoc/libApp.types + ./gtkdoc.sh -P "$(PREFIX)" -- "gtkdoc/sgml.stamp" + +html/index.html: gtkdoc/libApp-docs.xml gtkdoc/sgml.stamp + ./gtkdoc.sh -P "$(PREFIX)" -- "html/index.html" + +clean: + @for i in $(SUBDIRS); do (cd $$i && $(MAKE) clean) || exit; done + $(RM) -- $(gtkdoc/libApp.types_OBJS) $(gtkdoc/sgml.stamp_OBJS) $(html/index.html_OBJS) + +distclean: + @for i in $(SUBDIRS); do (cd $$i && $(MAKE) distclean) || exit; done + $(RM) -- $(gtkdoc/libApp.types_OBJS) $(gtkdoc/sgml.stamp_OBJS) $(html/index.html_OBJS) + $(RM) -- $(TARGETS) + +install: $(TARGETS) + @for i in $(SUBDIRS); do (cd $$i && $(MAKE) install) || exit; done + +uninstall: + @for i in $(SUBDIRS); do (cd $$i && $(MAKE) uninstall) || exit; done + +.PHONY: all subdirs clean distclean install uninstall diff --git a/doc/gtkdoc.sh b/doc/gtkdoc.sh new file mode 100755 index 0000000..8e52a63 --- /dev/null +++ b/doc/gtkdoc.sh @@ -0,0 +1,136 @@ +#!/bin/sh +#$Id$ +#Copyright (c) 2012 Pierre Pronchery +# +#Redistribution and use in source and binary forms, with or without +#modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +#AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +#IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +#FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +#DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +#SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +#OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#TODO: +#- implement installing and uninstalling + + + +#variables +PREFIX="/usr/local" +. "../config.sh" +DEBUG="_debug" +GTKDOC_FIXXREF="gtkdoc-fixxref" +GTKDOC_MKDB="gtkdoc-mkdb" +GTKDOC_MKHTML="gtkdoc-mkhtml" +GTKDOC_SCAN="gtkdoc-scan" +INSTALL="install -m 0644" +MKDIR="mkdir -p" +MODULE="$PACKAGE" +RM="rm -f" +TOUCH="touch" + + +#functions +#debug +_debug() +{ + echo $@ + $@ +} + + +#usage +_usage() +{ + echo "Usage: gtkdoc.sh [-i|-u][-P prefix] target" 1>&2 + return 1 +} + + +#main +install=0 +uninstall=0 +while getopts "iuP:" "name"; do + case "$name" in + i) + uninstall=0 + install=1 + ;; + u) + install=0 + uninstall=1 + ;; + P) + PREFIX="$2" + ;; + ?) + _usage + exit $? + ;; + esac +done +shift $((OPTIND - 1)) +if [ $# -eq 0 ]; then + _usage + exit $? +fi + +[ -z "$DATADIR" ] && DATADIR="$PREFIX/share" + +while [ $# -gt 0 ]; do + target="$1" + shift + + #create + #determine the type + ext="${target##*.}" + ext="${ext#.}" + case "$ext" in + html) + $MKDIR "html" && + (cd "html" && + $DEBUG $GTKDOC_MKHTML "$MODULE" \ + "../gtkdoc/$MODULE-docs.xml") && + (cd "gtkdoc" && + $DEBUG $GTKDOC_FIXXREF \ + --module="$MODULE" \ + --module-dir="../html" \ + --html-dir="$DATADIR/doc/html/$MODULE") + ;; + stamp) + (cd "gtkdoc" && + $DEBUG $GTKDOC_MKDB \ + --module="$MODULE" \ + --output-dir="xml" \ + --output-format="xml") + ;; + types) + (cd ".." && + $DEBUG $GTKDOC_SCAN \ + --module="$MODULE" \ + --source-dir="." \ + --output-dir="doc/gtkdoc") + ;; + *) + echo "$0: $target: Unknown type" 1>&2 + exit 2 + ;; + esac + #XXX ignore errors + if [ $? -ne 0 ]; then + echo "$0: $target: Could not create documentation" 1>&2 + install=0 + fi + $TOUCH "$target" +done diff --git a/doc/gtkdoc/Makefile b/doc/gtkdoc/Makefile new file mode 100644 index 0000000..be735a4 --- /dev/null +++ b/doc/gtkdoc/Makefile @@ -0,0 +1,13 @@ + + +all: + +clean: + +distclean: clean + +install: + +uninstall: + +.PHONY: all clean distclean install uninstall diff --git a/doc/gtkdoc/libApp-docs.xml b/doc/gtkdoc/libApp-docs.xml new file mode 100644 index 0000000..845a3b4 --- /dev/null +++ b/doc/gtkdoc/libApp-docs.xml @@ -0,0 +1,38 @@ + + + + + +]> + + + libApp Reference Manual + + for libApp &version;. + The latest version of this documentation can be found on-line at + http://&server;/libApp/. + + + + + &title; + + + + + + + + API Index + + + + Index of deprecated API + + + + + diff --git a/doc/gtkdoc/project.conf b/doc/gtkdoc/project.conf new file mode 100644 index 0000000..657bffc --- /dev/null +++ b/doc/gtkdoc/project.conf @@ -0,0 +1 @@ +dist=Makefile,libApp-docs.xml diff --git a/doc/project.conf b/doc/project.conf new file mode 100644 index 0000000..9934678 --- /dev/null +++ b/doc/project.conf @@ -0,0 +1,17 @@ +subdirs=gtkdoc +targets=gtkdoc/libApp.types,gtkdoc/sgml.stamp,html/index.html +dist=Makefile,GRAMMAR,gtkdoc.sh + +[gtkdoc/libApp.types] +type=script +script=./gtkdoc.sh + +[gtkdoc/sgml.stamp] +type=script +script=./gtkdoc.sh +depends=gtkdoc/libApp.types + +[html/index.html] +type=script +script=./gtkdoc.sh +depends=gtkdoc/libApp-docs.xml,gtkdoc/sgml.stamp diff --git a/project.conf b/project.conf index 19c3cf3..5435d97 100644 --- a/project.conf +++ b/project.conf @@ -3,4 +3,4 @@ version=0.1.5 config=h,sh dist=Makefile,COPYING,config.h,config.sh -subdirs=data,include,src,tools +subdirs=data,doc,include,src,tools