On 11/05/2012 02:40:12 PM, Tom Lane wrote: > Robert Haas <robertmh...@gmail.com> writes: > > On Fri, Oct 26, 2012 at 10:03 AM, Karl O. Pinc <k...@meme.com> > wrote: > >> This patch adds an empty row before each section header > >> in the error codes table in the docs. > > > This doesn't seem like a particularly good idea to me, but what do > > other people think? > > It seems like a kluge. If the vertical spacing isn't nice looking, > the > place to fix that is in the stylesheet or formatting macros, not by > hacking table contents.
The attached patch, errorcode_table_v2.patch, is an attempt to do it the right way. IMO the right way, instead of attempting to manually style table data rows into column headers as the code presently does, is to use multiple <tgroup>s, each of which has it's own header. This results in a single table, with multiple "sub-tables" and lets the toolchain style the headers as appropriate. Using multiple <tgroup>s is the approach taken in this patch. In my very limited experience alternate output formats, formats other than html (like PDF), output tables containing multiple tgroups format sensibly, the output is as a single table with sub-headings and consistent column widths throughout. So, this new patch does not attempt to apply any additional style to the multi-tgroup table for non-html formats. However, this new patch does not work for html. Or, rather, it works but produces ugly html output. The html output consists of multiple tables, one for each tgroup, each of which, by default, might be (and is) a different width. Ugly. Normally this can be fixed by styling the html with css. However in this case there are 2 problems. The first is the serious one. I'd expect to be able to set %entry-propagates-style%, or at least %phrase-propagates-style%, and use a role="style" attribute to style all the columns to a consistent width. But neither %entry-propagates-style% nor %phrase-propagates-style% works, so the styling info never makes it through the toolchain into the html. (The patch as submitted to you attempts to use %phrase-propagates-style%. I believe this is true by default and I shouldn't have to set it in the stylesheet.dsl, but there's code in this patch to do this anyway.) I don't know why the styling does not make it through to the html. There's dsssl stylesheets on my box that purport to handle %phrase-propagates-style%, but I didn't check to be sure that these were the stylesheets actually in use. Perhaps the docbook version used by the pg docs is not new enough to use a stylesheet which supports this. I don't think the custom navbar heading styling done in stylesheet.dsl is the problem, but I suppose it's possible. Or maybe I've a typo. In short, I've no clue why this patch fails. (Someday I imagine that pg will want to move to Docbook 5, and I don't even know if there's dsssl stylesheets for Docbook 5.) I could hack the doc/src/sgml/stylesheet.dsl file and put in the code that processes %phrase-propagates-style%, but that seems a little crazy. The second problem is that there's a make variable (STYLE=website) which causes the generated html to use the css found on the pg website. This patch does not frob the website's css so even if this patch otherwise worked somebody would have to change the pg website's css. So at this point I'm out of ideas. Unless somebody can chime in with a clue I'm ready to give up. It might be possible to improve the look of the current output by throwing some xsl/dsssl styling at the box edges of the faked table headers or do something else along those lines. IMHO the right way forward is to get tgroups working. Regards, Karl <k...@meme.com> Free Software: "You don't pay back, you pay forward." -- Robert A. Heinlein
diff --git a/doc/src/sgml/errcodes.sgml b/doc/src/sgml/errcodes.sgml index 16cb6c7..2388daf 100644 --- a/doc/src/sgml/errcodes.sgml +++ b/doc/src/sgml/errcodes.sgml @@ -53,24 +53,8 @@ <table id="errcodes-table"> <title><productname>PostgreSQL</productname> Error Codes</title> - <tgroup cols="2"> - <colspec colnum="1" colname="errorcode"> - <colspec colnum="2" colname="condname"> - <spanspec namest="errorcode" nameend="condname" spanname="span12"> + &errcodes-table; - <thead> - <row> - <entry>Error Code</entry> - <entry>Condition Name</entry> - </row> - </thead> - - <tbody> - - &errcodes-table; - - </tbody> - </tgroup> </table> diff --git a/doc/src/sgml/generate-errcodes-table.pl b/doc/src/sgml/generate-errcodes-table.pl index b9c14d3..91cda36 100644 --- a/doc/src/sgml/generate-errcodes-table.pl +++ b/doc/src/sgml/generate-errcodes-table.pl @@ -6,11 +6,51 @@ use warnings; use strict; +sub start_tgroup($) { + my $sname = shift; + + print <<'EOF'; + + + <tgroup cols="2"> + <colspec colnum="1" colname="errorcode"> + <colspec colnum="2" colname="condname"> + <spanspec namest="errorcode" nameend="condname" spanname="span12"> + + <thead> + <row> + <entry spanname="span12"> +EOF + + print " $sname</entry>\n"; + + print <<'EOF'; + </row> + <row> + <entry><phrase role="errcodes_errorcode">Error Code</phrase></entry> + <entry><phrase role="errcodes_condname">Condition Name</phrase></entry> + </row> + </thead> + + <tbody> +EOF +} + +sub stop_tgroup() { + + print <<'EOF'; + </tbody> + </tgroup> +EOF + +} + print "<!-- autogenerated from src/backend/utils/errcodes.txt, do not edit -->\n"; open my $errcodes, $ARGV[0] or die; +my $in_sect = 0; while (<$errcodes>) { chomp; @@ -32,11 +72,12 @@ while (<$errcodes>) # Wrap PostgreSQL in <productname/> s/PostgreSQL/<productname>PostgreSQL<\/>/g; - print "\n\n"; - print "<row>\n"; - print "<entry spanname=\"span12\">"; - print "<emphasis role=\"bold\">$_</></entry>\n"; - print "</row>\n"; + if ($in_sect) + { + stop_tgroup; + } + start_tgroup($_); + $in_sect = 1; next; } @@ -56,4 +97,6 @@ while (<$errcodes>) print "</row>\n"; } +stop_tgroup(); + close $errcodes; diff --git a/doc/src/sgml/stylesheet.css b/doc/src/sgml/stylesheet.css index 0fd0f01..4ad67fe 100644 --- a/doc/src/sgml/stylesheet.css +++ b/doc/src/sgml/stylesheet.css @@ -94,3 +94,7 @@ PRE.LITERALLAYOUT, .SCREEN, .SYNOPSIS, .PROGRAMLISTING { VAR { font-family: monospace; font-style: italic; } /* Konqueror's standard style for ACRONYM is italic. */ ACRONYM { font-style: inherit; } + +/* tgroup-ed table of error codes */ +th.errcodes_errorcode { width: 7em; } +th.errcodes_condname { width: 50em; } diff --git a/doc/src/sgml/stylesheet.dsl b/doc/src/sgml/stylesheet.dsl index 29e885d..1c4a2e6 100644 --- a/doc/src/sgml/stylesheet.dsl +++ b/doc/src/sgml/stylesheet.dsl @@ -199,6 +199,7 @@ (define use-output-dir #t) (define %output-dir% "html") (define html-index-filename "../HTML.index") +(define %phrase-propagates-style% #t) ;; Only build HTML.index or the actual HTML output, not both. Saves a
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers