mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-10-06 01:12:40 +02:00
2008-08-18 Lars-Peter Clausen <lars@metafoo.de> Add new documenation based on the pygobject documentation system. * configure.in * plug-ins/pygimp/Makefile.am * plug-ins/pygimp/doc/Makefile.am * plug-ins/pygimp/doc/html * plug-ins/pygimp/doc/html/style.css * plug-ins/pygimp/doc/xsl * plug-ins/pygimp/doc/xsl/ref-html-style.xsl * plug-ins/pygimp/doc/xsl/fixxref.py.in * plug-ins/pygimp/doc/xsl/html.xsl * plug-ins/pygimp/doc/xsl/devhelp.xsl * plug-ins/pygimp/doc/xsl/pdf-style.xsl * plug-ins/pygimp/doc/xsl/common.xsl * plug-ins/pygimp/doc/xsl/pdf.xsl * plug-ins/pygimp/doc/Makefile.am * plug-ins/pygimp/doc/reference * plug-ins/pygimp/doc/reference/pygimp-classes.xml * plug-ins/pygimp/doc/reference/pygimp-pixel-fetcher.xml * plug-ins/pygimp/doc/reference/entities.docbook * plug-ins/pygimp/doc/reference/pygimp-drawable.xml * plug-ins/pygimp/doc/reference/pygimp.xml * plug-ins/pygimp/doc/reference/pygimp-image.xml * plug-ins/pygimp/doc/reference/pygimp-pixel-rgn.xml * plug-ins/pygimp/doc/reference/entities.docbook.in * plug-ins/pygimp/doc/reference/pygimp-channel.xml * plug-ins/pygimp/doc/reference/pygimp-parasite.xml * plug-ins/pygimp/doc/reference/pygimp-ref.xml * plug-ins/pygimp/doc/reference/pygimp-layer.xml svn path=/branches/soc-2008-python/; revision=26644
68 lines
1.8 KiB
Python
68 lines
1.8 KiB
Python
#!/usr/bin/env python
|
|
# -*- Mode: Python; py-indent-offset: 4 -*-
|
|
|
|
import getopt
|
|
import os
|
|
import re
|
|
import sys
|
|
|
|
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.DOTALL | 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)
|
|
|
|
if len(args) != 1:
|
|
usage()
|
|
|
|
for idir in index_dirs:
|
|
scan_index_dir(idir)
|
|
|
|
html_dir = args[0]
|
|
fix_xrefs(html_dir)
|