From 9d20ce8575d0779426abfb33a05a2a7ef545456c Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Tue, 29 Jan 2002 04:02:07 +0000 Subject: [PATCH] Added a bit of documentation. svn: r736 --- gramps/src/docgen/LaTeXDoc.py | 66 +++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 11 deletions(-) diff --git a/gramps/src/docgen/LaTeXDoc.py b/gramps/src/docgen/LaTeXDoc.py index a34910a53..5af29736c 100644 --- a/gramps/src/docgen/LaTeXDoc.py +++ b/gramps/src/docgen/LaTeXDoc.py @@ -18,38 +18,57 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +"""LaTeX document generator""" + +#------------------------------------------------------------------------ +# +# gramps modules +# +#------------------------------------------------------------------------ from TextDoc import * -from latin_utf8 import latin_to_utf8 import Plugins import intl _ = intl.gettext #------------------------------------------------------------------------ # -# +# LaTeXDoc # #------------------------------------------------------------------------ class LaTeXDoc(TextDoc): - + """LaTeX document interface class. Derived from TextDoc""" + def open(self,filename): + """Opens the specified file, making sure that it has the + extension of .tex""" + if filename[-4:] != ".tex": self.filename = filename + ".tex" else: self.filename = filename - self.f = open(self.filename,"w") + + # Font size control seems to be limited. For now, ignore + # any style constraints, and use 12pt has the default + options = "12pt" if self.orientation == PAPER_LANDSCAPE: options = options + ",landscape" + # Paper selections seem to be limited as well. Not sure + # what to do if the user picks something else. I believe + # this defaults to 'letter' if self.paper.name == "A4": options = options + ",a4paper" elif self.paper.name == "A5": options = options + ",a5paper" elif self.paper.name == "B5": options = options + ",b4paper" - + + # Use the article template, T1 font encodings, and specify + # that we should use Latin1 character encodings. + self.f.write('\\documentclass[%s]{article}\n' % options) self.f.write('\\usepackage[T1]{fontenc}\n') self.f.write('\\usepackage[latin1]{inputenc}\n') @@ -59,18 +78,25 @@ class LaTeXDoc(TextDoc): self.in_list = 0 def close(self): + """Clean up and close the document""" + if self.in_list: self.f.write('\\end{description}\n') self.f.write('\\end{document}\n') self.f.close() def start_page(self,orientation=None): + """Nothing needs to be done to start a page""" pass def end_page(self): + """Issue a new page command""" self.f.write('\\newpage') def start_paragraph(self,style_name,leader=None): + """Paragraphs handling - paragraphs seem to be limited in + what we can do. The only thing I can see to do is to use + the levels to provide the headers.""" style = self.style_list[style_name] self.level = style.get_header_level() @@ -91,6 +117,7 @@ class LaTeXDoc(TextDoc): self.f.write('\\item{%s} ' % leader) def end_paragraph(self): + """End the current paragraph""" if self.level > 0: self.f.write('}\n') elif not self.in_list: @@ -99,38 +126,55 @@ class LaTeXDoc(TextDoc): self.f.write('\n') def start_bold(self): + """Bold face""" self.f.write('\\bfseries ') - pass def end_bold(self): + """End bold face""" self.f.write('\\mdseries ') - pass def start_table(self,name,style_name): + """Currently no table support""" pass def end_table(self): + """Currently no table support""" pass def start_row(self): + """Currently no table support""" pass def end_row(self): + """Currently no table support""" pass def start_cell(self,style_name,span=1): + """Currently no table support""" pass def end_cell(self): + """Currently no table support""" pass def add_photo(self,name,pos,x,y): + """Currently no table support""" pass - def horizontal_line(self): - pass - def write_text(self,text): + """Write the text to the file""" self.f.write(text) -Plugins.register_text_doc(_("LaTeX"),LaTeXDoc,0,1,0) + +#------------------------------------------------------------------------ +# +# Register the document generator with the system +# +#------------------------------------------------------------------------ +Plugins.register_text_doc( + name=_("LaTeX"), + classref=LaTeXDoc, + table=0, + paper=1, + style=0 + )