Package: rubber Version: 1.0-1 Severity: wishlist Tags: patch Hi,
xindy <http://xindy.sf.net> is a new index processing system that has some advantages over makeindex, e.g. it can handle expanded spaces (\, \; etc.) correct. It would be nice if rubber would support xindy. So I propose this patch. But take it as a proof of concept. I am not a python programmer and I didn't understand the magic in the class Module. With this patch it works for me as expected, if I add this lines to my latex source: % rubber: index.xindy (default) 1 % rubber: index.language (default) german-duden % rubber: index.modules (default) indexstyle.xdy Regards, Jörg. BTW: rubber is really hot! -- System Information: Debian Release: unstable/experimental APT prefers unstable APT policy: (990, 'unstable'), (1, 'experimental') Architecture: powerpc (ppc) Shell: /bin/sh linked to /bin/dash Kernel: Linux 2.6.13.1 Locale: LANG=de_DE, LC_CTYPE=de_DE (charmap=ISO-8859-1) Versions of packages rubber depends on: ii python 2.3.5-3 An interactive high-level object-o ii tetex-bin 3.0-10.1 The teTeX binary files rubber recommends no packages. -- no debconf information
--- index.py 2005-06-16 10:28:27.000000000 +0200
+++ /usr/share/rubber/rubber/rules/latex/index.py 2005-12-20
19:40:41.000000000 +0100
@@ -64,6 +64,9 @@
self.path.append(doc.src_path)
self.style = None
self.opts = []
+ self.xindy = 0
+ self.modules = []
+ self.lang = ""
def do_order (self, *args):
for opt in args:
@@ -79,6 +82,15 @@
def do_style (self, style):
self.style = style
+ def do_xindy (self, use_it):
+ self.xindy = 1
+
+ def do_modules (self, *args):
+ self.modules.extend(args)
+
+ def do_language (self, lang):
+ self.lang = lang
+
def post_compile (self):
"""
Run makeindex if needed, with appropriate options and
environment.
@@ -90,13 +102,35 @@
return 0
msg.progress(_("processing index %s") % self.source)
- cmd = ["makeindex", "-o", self.target] + self.opts
- if self.style:
- cmd.extend(["-s", self.style])
- cmd.append(self.pbase)
+ if self.xindy:
+ cmd = ["texindy", "--quiet"]
+ for opt in self.opts:
+ if opt == "-g":
+ if self.lang != "":
msg.warn("\".language\" overrides \".order german\"")
+ else: self.lang = "german-din"
+ elif opt == "-l":
+ self.modules.append("letter-ordering")
+ msg.warn("specify \"letter-ordering\"
as module instead of using .order letter")
+ else:
+ msg.error("unknown option to xindy: %s"
% opt)
+ for mod in self.modules:
+ cmd.extend(["--module", mod])
+ if self.lang != "": cmd.extend(["--language",
self.lang])
+ else:
+ cmd = ["makeindex"]
+ if self.style:
+ cmd.extend(["-s", self.style])
+ cmd.extend(self.opts)
+ cmd.extend(["-o", self.target])
+ if self.xindy:
+ cmd.append(self.source)
+ else:
+ cmd.append(self.pbase)
if self.path != [""]:
- env = { 'INDEXSTYLE':
- string.join(self.path +
[os.getenv("INDEXSTYLE", "")], ":") }
+ if self.xindy: var_name = "XINDY_SEARCHPATH"
+ else: var_name = "INDEXSTYLE"
+ env = { var_name:
+ string.join(self.path + [os.getenv(var_name,
"")], ":") }
else:
env = {}
if self.doc.env.execute(cmd, env):
@@ -135,6 +169,29 @@
msg.log(_("removing %s") % file, pkg="index")
os.unlink(file)
+# Stolen from __init__.py
+ def command (self, cmd, args, pos={}):
+ """
+ Execute the rubber command 'cmd' with arguments 'args'. This is
called
+ when a command is found in the source file or in a
configuration file.
+ A command name of the form 'foo.bar' is considered to be a
command
+ 'bar' for module 'foo'. The argument 'pos' describes the
position
+ (file and line) where the command occurs.
+ """
+ # Calls to this method are actually translated into calls to
"do_*"
+ # methods, except for calls to module directives.
+ lst = string.split(cmd, ".", 1)
+ if len(lst) > 1:
+ self.modules.command(lst[0], lst[1], args)
+ else:
+ if hasattr(self, "do_" + cmd):
+ try:
+ getattr(self, "do_" + cmd)(*args)
+ except TypeError:
+ msg.warn(_("wrong syntax for '%s'") %
cmd, **pos)
+ else:
+ msg.warn(_("unknown directive '%s'") % cmd,
**pos)
+
re_newindex = re.compile(" *{(?P<idx>[^{}]*)} *{(?P<ind>[^{}]*)}")
re_optarg = re.compile("\((?P<list>[^()]*)\) *")
@@ -147,12 +204,16 @@
self.indices = {}
doc.add_hook("makeindex", self.makeindex)
doc.add_hook("newindex", self.newindex)
+ self.makeindex("foo")
def makeindex (self, dict):
"""
Register the standard index.
"""
- self.indices["default"] = Index(self.doc, "idx", "ind")
+ if self.indices.has_key("default"):
+ msg.warn("makeindex called again; ignoring this call")
+ else:
+ self.indices["default"] = Index(self.doc, "idx", "ind")
def newindex (self, dict):
"""
pgp9bukUTxt6p.pgp
Description: PGP signature

