Add new graph output format to the tree document generator
The "graph" is the data part for genealogytree without the boilerplate code around it that makes up a full LaTeX file. This format is useful for people who have their own (more sophisticated) LaTeX file with custom styles and so on. The implementation is pretty straight-forward: Just don't output the LaTeX code.
This commit is contained in:
parent
bedc4b8e74
commit
f3555d0168
@ -586,6 +586,47 @@ class TreeDocBase(BaseDoc, TreeDoc):
|
||||
self.write_end()
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# TreeGraphDoc
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
class TreeGraphDoc(TreeDocBase):
|
||||
"""
|
||||
TreeGraphDoc implementation that generates a .graph file.
|
||||
"""
|
||||
|
||||
def write_start(self):
|
||||
"""
|
||||
Write the start of the document - nothing for a graph file.
|
||||
"""
|
||||
pass
|
||||
|
||||
def start_tree(self, option_list):
|
||||
"""
|
||||
Write the start of a tree - nothing for a graph file.
|
||||
"""
|
||||
pass
|
||||
|
||||
def end_tree(self):
|
||||
"""
|
||||
Write the end of a tree - nothing for a graph file.
|
||||
"""
|
||||
pass
|
||||
|
||||
def write_end(self):
|
||||
"""
|
||||
Write the end of the document - nothing for a graph file.
|
||||
"""
|
||||
pass
|
||||
|
||||
def close(self):
|
||||
""" Implements TreeDocBase.close() """
|
||||
TreeDocBase.close(self)
|
||||
|
||||
with open(self._filename, 'w', encoding='utf-8') as texfile:
|
||||
texfile.write(self._tex.getvalue())
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# TreeTexDoc
|
||||
@ -653,6 +694,11 @@ if _LATEX_FOUND:
|
||||
'mime' : "application/pdf",
|
||||
'class': TreePdfDoc}]
|
||||
|
||||
FORMATS += [{'type' : "graph",
|
||||
'ext' : "graph",
|
||||
'descr': _("Graph File for genealogytree"),
|
||||
'class': TreeGraphDoc}]
|
||||
|
||||
FORMATS += [{'type' : "tex",
|
||||
'ext' : "tex",
|
||||
'descr': _("LaTeX File"),
|
||||
|
Loading…
Reference in New Issue
Block a user