def externaldocument (self, dict): # .aux document needed to cross-ref with xr auxfile = dict["arg"] + ".aux" texfile = dict["arg"] + ".tex" # Ignore the dependency if no tex source found if not(os.path.isfile(texfile)): msg.log(_("file %s is required by xr package but not found")\ % texfile, pkg="xr") return # Ask to compile the related .tex file to have the .aux texdep = Latex(self.env) texdep.set_source(texfile) texdep.batch = self.doc.batch texdep.encoding = self.doc.encoding texdep.draft_only = True # Final output not required here for m in self.texmodules: texdep.modules.register(m) # Load other modules from source, except xr to avoid loops texdep.prepare(exclude_mods=["xr-hyper"]) # Add the .aux as an expected input for compiling the doc self.doc.sources[auxfile] = texdep msg.log(_( "dependency %s added for external references") % auxfile, pkg="xr")
class LatexBuilder: """ Main (g)rubber wrapper hiding all the internals and compiling the required tex file. """ def __init__(self): # The actual workers self.maker = Maker() self.tex = Latex(self.maker) self.maker.dep_append(self.tex) # What to do self.backend = "pdftex" self.format = "pdf" self.index_style = "" self.batch = 1 self.encoding = "latin-1" self.texpost = "" self.options = "" def set_format(self, format): # Just record it self.format = format def set_backend(self, backend): self.backend = backend def set_index_style(self, index_style): self.index_style = index_style def compile(self, source): self.tex.batch = self.batch self.tex.encoding = self.encoding self.tex.set_source(source) if self.options: self.tex.opts += shlex.split(self.options) # Load the modules needed to produce the expected output format if (self.format == "pdf"): if (self.backend == "pdftex"): self.tex.modules.register("pdftex") elif (self.backend == "xetex"): self.tex.modules.register("xetex") else: self.tex.modules.register("dvips") self.tex.modules.register("ps2pdf") elif (self.format == "ps"): self.tex.modules.register("dvips") # Now load other the modules required to compile this file self.tex.prepare() # Set the index style if self.index_style and self.tex.modules.has_key("makeidx"): idx = self.tex.modules["makeidx"] idx.style = self.index_style # Let's go... rc = self.maker.make() if rc != 0: raise OSError("%s compilation failed" % self.tex.program) # Post process script to call? if not (self.texpost): return os.environ["LATEX"] = self.tex.program rc = subprocess.call([self.texpost, source], stdout=msg.stdout) if rc == 1: return if rc != 0: raise OSError("%s texpost failed" % self.texpost) rc = self.maker.make(force=1) if rc != 0: raise OSError("%s post compilation failed" % self.tex.program) def clean(self): self.tex.clean() self.reinit() def reinit(self): self.tex.reinit() self.maker.reinit() self.maker.dep_append(self.tex) def print_errors(self): msg.display_all(self.tex.get_errors(), writer=msg.write_stderr) def print_misschars(self): # Show the characters not handled by fonts self.tex.print_misschars()
class LatexBuilder: """ Main (g)rubber wrapper hiding all the internals and compiling the required tex file. """ def __init__(self): # The actual workers self.maker = Maker() self.tex = Latex(self.maker) self.maker.dep_append(self.tex) # What to do self.backend = "pdftex" self.format = "pdf" self.index_style = "" self.batch = 1 self.encoding = "latin-1" self.texpost = "" def set_format(self, format): # Just record it self.format = format def set_backend(self, backend): self.backend = backend def set_index_style(self, index_style): self.index_style = index_style def compile(self, source): self.tex.batch = self.batch self.tex.encoding = self.encoding self.tex.set_source(source) # Load the modules needed to produce the expected output format if (self.format == "pdf"): if (self.backend == "pdftex"): self.tex.modules.register("pdftex") elif (self.backend == "xetex"): self.tex.modules.register("xetex") else: self.tex.modules.register("dvips") self.tex.modules.register("ps2pdf") elif (self.format == "ps"): self.tex.modules.register("dvips") # Now load other the modules required to compile this file self.tex.prepare() # Set the index style if self.index_style and self.tex.modules.has_key("makeidx"): idx = self.tex.modules["makeidx"] idx.style = self.index_style # Let's go... rc = self.maker.make() if rc != 0: raise OSError("%s compilation failed" % self.tex.program) # Post process script to call? if not(self.texpost): return os.environ["LATEX"] = self.tex.program rc = subprocess.call([self.texpost, source], stdout=msg.stdout) if rc == 1: return if rc != 0: raise OSError("%s texpost failed" % self.texpost) rc = self.maker.make(force=1) if rc != 0: raise OSError("%s post compilation failed" % self.tex.program) def clean(self): self.tex.clean() self.reinit() def reinit(self): self.tex.reinit() self.maker.reinit() self.maker.dep_append(self.tex) def print_errors(self): msg.display_all(self.tex.get_errors(), writer=msg.write_stderr)