commit-womb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commit-womb] gnumaint Makefile gm gm-generate.pl gm-read.pl


From: Brandon Invergo
Subject: [commit-womb] gnumaint Makefile gm gm-generate.pl gm-read.pl
Date: Tue, 08 Oct 2013 19:30:35 +0000

CVSROOT:        /sources/womb
Module name:    gnumaint
Changes by:     Brandon Invergo <brandon>       13/10/08 19:30:35

Modified files:
        .              : Makefile gm gm-generate.pl gm-read.pl 

Log message:
        add code to generate package blurb HTML

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnumaint/Makefile?cvsroot=womb&r1=1.50&r2=1.51
http://cvs.savannah.gnu.org/viewcvs/gnumaint/gm?cvsroot=womb&r1=1.56&r2=1.57
http://cvs.savannah.gnu.org/viewcvs/gnumaint/gm-generate.pl?cvsroot=womb&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnumaint/gm-read.pl?cvsroot=womb&r1=1.8&r2=1.9

Patches:
Index: Makefile
===================================================================
RCS file: /sources/womb/gnumaint/Makefile,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- Makefile    3 Aug 2013 16:23:07 -0000       1.50
+++ Makefile    8 Oct 2013 19:30:33 -0000       1.51
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.50 2013/08/03 16:23:07 karl Exp $
+# $Id: Makefile,v 1.51 2013/10/08 19:30:33 brandon Exp $
 # Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2013
 # Free Software Foundation, Inc.
 #
@@ -18,6 +18,9 @@
 html-diff:
        cd $(gw) && cvs diff -u0 */allgnupkgs.html
 
+pkg-desc-html:
+       gm generate descriptions html
+
 test-genlhtml ghtml:  # result included from www.gnu.org/graphics/manual.html
        gm generate logos html | tee ~/tmp/x.html
 

Index: gm
===================================================================
RCS file: /sources/womb/gnumaint/gm,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -b -r1.56 -r1.57
--- gm  24 Jun 2013 18:05:07 -0000      1.56
+++ gm  8 Oct 2013 19:30:33 -0000       1.57
@@ -1,5 +1,5 @@
 #!/usr/bin/env perl
-# $Id: gm,v 1.56 2013/06/24 18:05:07 karl Exp $
+# $Id: gm,v 1.57 2013/10/08 19:30:33 brandon Exp $
 # GNU maintainer-related operations.
 # 
 # Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software
@@ -21,7 +21,7 @@
 # Originally written by Karl Berry.
 
 $DEBUG = 0;
-my $ver = '$Id: gm,v 1.56 2013/06/24 18:05:07 karl Exp $';
+my $ver = '$Id: gm,v 1.57 2013/10/08 19:30:33 brandon Exp $';
 
 # In this particular case, using require seemed better than setting up
 # modules.  It's certainly simpler.
@@ -50,6 +50,8 @@
 $MAINTAINERS_FILE = "maintainers";
   # maintained here:
 $OLDPACKAGES_FILE = "oldpackages.txt";
+  # maintained here:
+$PKGDESCR_FILE = "pkgdescr.txt";  
 
 # The routines using these additional files are not yet fully implemented.
   # rsync://ftp.gnu.org/gnu/

Index: gm-generate.pl
===================================================================
RCS file: /sources/womb/gnumaint/gm-generate.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- gm-generate.pl      24 Jun 2013 18:05:07 -0000      1.2
+++ gm-generate.pl      8 Oct 2013 19:30:34 -0000       1.3
@@ -1,4 +1,4 @@
-# $Id: gm-generate.pl,v 1.2 2013/06/24 18:05:07 karl Exp $
+# $Id: gm-generate.pl,v 1.3 2013/10/08 19:30:34 brandon Exp $
 # The generate actions for the gm script (see --help message).
 # 
 # Copyright 2007, 2008, 2009, 2010, 2012, 2013 Free Software Foundation
@@ -335,4 +335,31 @@
 }
 
 
+# Return HTML-formatted blurbs about the packages for the featured
+# package on http://www.gnu.org.
+#
+sub generate_descriptions_html {
+  my $autostamp = &generated_by_us ();
+  my @ret = ("<!-- File $autostamp -->");
+  
+  my %pkgs = &read_pkgdescr ();
+  my $blurb;
+  for my $pkgname (sort keys %pkgs) {
+    next if &skip_pkg_p ($pkgname);
+    my %pkg = %{ $pkgs{$pkgname} };
+    push (@ret, "<--#if expr=\"\$pkg_selection = /:$pkg{package}:/\" -->");
+    push (@ret, "<h4><a href=\"$pkg{url}\">$pkg{name}</a></h4>");
+    $blurb = $pkg{blurb};
+    $blurb =~ s/\&/\&amp;/g;
+    $blurb =~ s/</\&lt;/g;
+    $blurb =~ s/>/\&gt;/g;
+    $blurb =~ s/"/\&quot;/g;
+    push (@ret, "<p>$blurb</p>");
+    push (@ret, "<!--#endif -->");
+  }
+
+  return @ret;
+}
+
+
 1;

Index: gm-read.pl
===================================================================
RCS file: /sources/womb/gnumaint/gm-read.pl,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- gm-read.pl  25 Apr 2013 23:18:32 -0000      1.8
+++ gm-read.pl  8 Oct 2013 19:30:35 -0000       1.9
@@ -1,4 +1,4 @@
-# $Id: gm-read.pl,v 1.8 2013/04/25 23:18:32 karl Exp $
+# $Id: gm-read.pl,v 1.9 2013/10/08 19:30:35 brandon Exp $
 # Subroutines for gm script that read various external data file.
 # 
 # Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2013
@@ -466,6 +466,60 @@
 }
 
 
+# Read the pkgdescr.txt file, return a hash of information, where the
+# keys are package names and the values are hash references with the
+# information.  If a key is given more than once (which shouldn't
+# happen), the values are separated by |.  A key "lineno" is
+# synthesized with the line number of the blank line following the
+# package.
+# 
+sub read_pkgdescr {
+  my %ret;
+
+  open (PKGDESCR_FILE) || die "open($PKGDESCR_FILE) failed: $!";
+
+  my %pkg;
+  while (<PKGDESCR_FILE>) {
+    next if /^#/;  # Ignore comments
+    s/ +$//; # remove trailing spaces
+    chomp;
+
+    # at a blank line, save the info we've accumulated, if any.
+    if (/^$/) {
+      next unless keys %pkg;
+      
+      if (exists $pkg{"package"}) {
+        my %copy = %pkg;  # do not save a pointer to what will be overwritten
+        $copy{"lineno"} = $. - 1;  # save line number
+        $ret{$pkg{"package"}} = \%copy;
+      } else {
+        warn "$PKGDESCR_FILE:$.: no package name for block ending here\n";
+      }
+      undef %pkg;  # clear out next
+      next;
+    }
+    # key is everything before the first colon.
+    # value is everything after the first colon and whitespace.
+    my ($key,$val) = split (/:\s*/, $_, 2);
+    if ($key eq $_) {
+      # multi-line blurbs are line-folded with "+ "
+      if ($key =~ /^\+ /) {
+        $pkg{blurb} = $pkg{blurb} . " " . substr($key, 2);
+      } else {
+        warn "$GNUPACKAGES_FILE:$.: no colon in line\n";
+      }
+    }
+    # if key already exists, use | to separate values.
+    $val = "$pkg{$key}|$val" if exists $pkg{$key};
+    
+    $pkg{$key} = $val;
+  }
+  close (PKGDESCR_FILE) || warn "close($PKGDESCR_FILE) failed: $!";
+  
+  return %ret;
+}
+
+
 
 # Read htmlxref.cnf file for entries relating to PKGNAME.
 # Return a hash where the keys are the manual identifiers and the values



reply via email to

[Prev in Thread] Current Thread [Next in Thread]