On Thu, Feb 16, 2006 at 02:36:01AM +0100, Peter Eisentraut wrote: > We are currently maintaining information about configuration parameters > in at least three places: the documentation, guc.c, and > postgresql.conf.sample. I would like to generate these from a single > source. Computationally, this is not very challenging, it's just a bit > of work. I imagine as the source an XML file with a custom schema; see > below for an example. I think this is the best source format because > it allows integrating the DocBook-formatted descriptions without too > much trouble and it allows for file format validation. An alternative > might be m4 but that would not offer these features. To process this > we'd use XSLT stylesheets run through xsltproc. We'd run this part > during the tarball building phase, so users would not need it. > Obviously, all of this will need some fine-tuning, but can we agree on > this general direction?
Is there any reason why we can't just use something like awk? It's installed almost everywhere (it may be required, not sure) and a lot more people know how to use it. I havn't managed to wrap my brain around xslt yet. The input file could be simply line based. Attached is a simple script that takes the input below and produces something resembling what you suggested. It wouldn't be too hard to get it to produce multiple output formats and dump the output to different files... ---- Group: Query Tuning Subgroup: Planner Method Configuration Name: enable_hashagg Context: userset ... etc ... ---- -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a > tool for doing 5% of the work and then sitting around waiting for someone > else to do the other 95% so you can sue them.
BEGIN { havedata = 0; group = subgroup = ""; print "<parameters>\n"; } /^[A-Za-z]+: *(.*)/ { keyword = tolower(substr( $0, 1, index( $0, ":" ) - 1 ) ); data = substr( $0, index( $0, ":" ) + 1 ); sub( /^ +/, "", data ); sub( / +$/, "", data ); if( keyword == "group" ) { if( group != "" ) { print "</group>\n" } printf "<group><title>%s</title>\n", data; group = data; subgroup = ""; next; } if( keyword == "subgroup" ) { if( subgroup != "" ) { printf "</subgroup[%s]>\n", subgroup } printf "<subgroup><title>%s</title>\n", data; subgroup = data; next; } havedata = 1; fields[keyword] = data; next; } /^ *$/ { if( havedata == 0 ) { next } print "<parameter>\n"; for( keyword in fields ) { printf "<%s>%s<%s>\n", keyword, fields[keyword], keyword } print "</parameter>\n"; havedata = 0; delete fields; next; } { printf "Invalid input: %s\n", $0; exit; } END { if( havedata == 1 ) { print "<parameter>\n"; for( keyword in fields ) { printf "<%s>%s<%s>\n", keyword, fields[keyword], keyword } print "</parameter>\n"; } if( subgroup != "" ) { print "</subgroup>\n" } if( group != "" ) { print "</group>\n" } print "</parameters>\n"; }
signature.asc
Description: Digital signature