summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Dahlin <johan@src.gnome.org>2006-08-06 21:16:16 +0000
committerJohan Dahlin <johan@src.gnome.org>2006-08-06 21:16:16 +0000
commit43b16b4003b760d3a992ca0184d17727af3a98d7 (patch)
treeac78121fd8fad1f6494e36469e6919ac4e99910f
parent64bc3928b2b4b7aad281fea52dff62a34d0dbb02 (diff)
downloadpygobject-43b16b4003b760d3a992ca0184d17727af3a98d7.tar.gz
pygobject-43b16b4003b760d3a992ca0184d17727af3a98d7.tar.xz
pygobject-43b16b4003b760d3a992ca0184d17727af3a98d7.zip
New file to workaround automake silliness
* m4/as-expand.m4: New file to workaround automake silliness * docs/xsl/fixxref.py.in: New script * docs/Makefile.am (XSLFILES): Add fixxref.py script, moved in from PyGTK.
-rw-r--r--ChangeLog7
-rw-r--r--configure.ac3
-rw-r--r--docs/Makefile.am1
-rw-r--r--docs/xsl/.cvsignore1
-rw-r--r--docs/xsl/fixxref.py.in71
-rw-r--r--m4/as-ac-expand.m440
-rw-r--r--pygobject-2.0.pc.in1
7 files changed, 124 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 08ca6b7..2610602 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2006-08-06 Johan Dahlin <johan@gnome.org>
+ * m4/as-expand.m4: New file to workaround automake silliness
+
+ * docs/xsl/fixxref.py.in: New script
+
+ * docs/Makefile.am (XSLFILES): Add fixxref.py script, moved in from
+ PyGTK.
+
* docs/xsl/html.xsl: Do not use shade.verbatim, set the background
color and border as a normal html tag to avoid an external
stylesheet.
diff --git a/configure.ac b/configure.ac
index bffb1e6..f32fcf5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -128,6 +128,8 @@ fi
pygobject_CODEGEN_DEFINES=""
AC_SUBST([pygobject_CODEGEN_DEFINES])
+AS_AC_EXPAND(DATADIR, $datadir)
+
dnl add required cflags ...
JH_ADD_CFLAG([-Wall])
JH_ADD_CFLAG([-std=c9x])
@@ -138,6 +140,7 @@ AC_CONFIG_FILES(
pygobject-2.0.pc
docs/Makefile
docs/reference/entities.docbook
+ docs/xsl/fixxref.py
gobject/Makefile
examples/Makefile
tests/Makefile
diff --git a/docs/Makefile.am b/docs/Makefile.am
index 99cd5bc..61bc126 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -17,6 +17,7 @@ XMLFILES = \
XSLFILES = \
xsl/common.xsl \
xsl/devhelp.xsl \
+ xsl/fixxref.py \
xsl/html.xsl \
xsl/pdf-style.xsl \
xsl/pdf.xsl \
diff --git a/docs/xsl/.cvsignore b/docs/xsl/.cvsignore
new file mode 100644
index 0000000..94774a1
--- /dev/null
+++ b/docs/xsl/.cvsignore
@@ -0,0 +1 @@
+fixxref.py
diff --git a/docs/xsl/fixxref.py.in b/docs/xsl/fixxref.py.in
new file mode 100644
index 0000000..497160e
--- /dev/null
+++ b/docs/xsl/fixxref.py.in
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+# -*- Mode: Python; py-indent-offset: 4 -*-
+
+import getopt
+import os
+import re
+import sys
+
+DOCDIR = '@DATADIR@/gtk-doc/html/pygobject'
+
+anchors = {}
+anchor_pat = re.compile(r'''^\s*<ANCHOR\s+id\s*=\s*"([^"]*)"\s+
+ href\s*=\s*"([^"]*)"\s*>''',
+ re.MULTILINE | re.VERBOSE)
+link_pat = re.compile(r'''<PYGTKDOCLINK\s+HREF="([^"]*)"\s*>(.*?)
+ </PYGTKDOCLINK\s*>''', re.VERBOSE)
+def scan_index_dir(idir):
+ for root, dirs, files in os.walk(idir):
+ if 'index.sgml' in files:
+ scan_index_file(os.path.join(root, 'index.sgml'))
+ return
+
+def scan_index_file(ifile):
+ buf = open(ifile).read()
+ for id, href in anchor_pat.findall(buf):
+ anchors[id] = href
+
+def fix_xrefs(hdir):
+ for f in os.listdir(hdir):
+ if os.path.splitext(f)[1] == '.html':
+ fix_html_file(os.path.join(hdir, f))
+
+def link_subst(m):
+ id, text = m.groups()
+ if anchors.has_key(id):
+ return '<a\nhref="../' + anchors[id] + '"\n>' + text + '</a>'
+ return text
+
+def fix_html_file(hfile):
+ buf = open(hfile).read()
+ buf = link_pat.sub(link_subst, buf)
+ open(hfile, 'w').write(buf)
+
+def usage(e=None):
+ if e:
+ sys.stderr.write('fixxref.py: %s\n' % e)
+ sys.stderr.write('usage: fixxref.py [-i index-dir] html-dir\n')
+ sys.exit(1)
+
+if __name__ == '__main__':
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "i:h:",
+ ["index-dir=", "html-dir="])
+ except getopt.error, e:
+ usage(e)
+
+ index_dirs = []
+ for opt, arg in opts:
+ if opt in ('-i', '--index-dir'):
+ index_dirs.append(arg)
+
+ index_dirs.append(DOCDIR)
+
+ if len(args) != 1:
+ usage()
+
+ for idir in index_dirs:
+ scan_index_dir(idir)
+
+ html_dir = args[0]
+ fix_xrefs(html_dir)
diff --git a/m4/as-ac-expand.m4 b/m4/as-ac-expand.m4
new file mode 100644
index 0000000..0c71173
--- /dev/null
+++ b/m4/as-ac-expand.m4
@@ -0,0 +1,40 @@
+dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
+dnl
+dnl example
+dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
+dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local
+
+AC_DEFUN([AS_AC_EXPAND],
+[
+ EXP_VAR=[$1]
+ FROM_VAR=[$2]
+
+ dnl first expand prefix and exec_prefix if necessary
+ prefix_save=$prefix
+ exec_prefix_save=$exec_prefix
+
+ dnl if no prefix given, then use /usr/local, the default prefix
+ if test "x$prefix" = "xNONE"; then
+ prefix=$ac_default_prefix
+ fi
+ dnl if no exec_prefix given, then use prefix
+ if test "x$exec_prefix" = "xNONE"; then
+ exec_prefix=$prefix
+ fi
+
+ full_var="$FROM_VAR"
+ dnl loop until it doesn't change anymore
+ while true; do
+ new_full_var="`eval echo $full_var`"
+ if test "x$new_full_var"="x$full_var"; then break; fi
+ full_var=$new_full_var
+ done
+
+ dnl clean up
+ full_var=$new_full_var
+ AC_SUBST([$1], "$full_var")
+
+ dnl restore prefix and exec_prefix
+ prefix=$prefix_save
+ exec_prefix=$exec_prefix_save
+])
diff --git a/pygobject-2.0.pc.in b/pygobject-2.0.pc.in
index 88f239c..4600d46 100644
--- a/pygobject-2.0.pc.in
+++ b/pygobject-2.0.pc.in
@@ -8,6 +8,7 @@ datadir=@datadir@
# pkg-config to get this value. You might want to use this to
# install additional headers.
pygtkincludedir=${includedir}/pygtk-2.0
+fixxref=${datadir}/pygobject/xsl/fixxref.py
Name: PyGObject
Description: Python bindings for GObject