1 package SQL::Translator::Producer::Latex;
3 # -------------------------------------------------------------------
4 # Copyright (C) 2002-6 SQLFairy Authors
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation; version 2.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 # -------------------------------------------------------------------
25 SQL::Translator::Producer::Latex -
26 Produces latex formatted tables ready for import from schema.
31 my $translator = SQL::Translator->new(
33 filename => 'foo_schema.sql',
36 print $translator->translate;
40 Currently you will get one class (with the a table
41 stereotype) generated per table in the schema. The fields are added as
42 attributes of the classes and their datatypes set. It doesn't currently set any
43 of the relationships. It doesn't do any layout, all the classses are in one big
44 stack. However it is still useful as you can use the layout tools in Dia to
45 automatically arrange them horizontally or vertically.
57 use vars qw[ $DEBUG $VERSION @EXPORT_OK ];
59 $DEBUG = 0 unless defined $DEBUG;
61 use SQL::Translator::Utils 'debug';
64 my $translator = shift;
65 my $schema = $translator->schema;
67 for my $table ( $schema->get_tables ) {
68 my $table_name = $table->name or next;
69 my $n = latex($table_name);
79 \begin{tabular}{l l p{8cm}}
80 Column & Datatype & Description \\\\ \hline
82 $n, latex($table->comments), $n, $table_name;
84 foreach my $f ($table->get_fields) {
85 $o .= sprintf '%s & %s & %s \\\\', map {latex($_)} ($f->name, $f->data_type, $f->comments || '');
100 return '' unless defined $s;
101 $s =~ s/([\&\_\$\{\#])/\\$1/g;