From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7413 invoked by alias); 3 Apr 2008 14:40:22 -0000 Received: (qmail 7402 invoked by uid 22791); 3 Apr 2008 14:40:20 -0000 X-Spam-Status: No, hits=1.1 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_16,J_CHICKENPOX_17,J_CHICKENPOX_33,J_CHICKENPOX_34,J_CHICKENPOX_35,J_CHICKENPOX_36,J_CHICKENPOX_37,J_CHICKENPOX_42,J_CHICKENPOX_44,J_CHICKENPOX_47,J_CHICKENPOX_73,J_CHICKENPOX_93,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 03 Apr 2008 14:39:52 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m33Ednq1009970; Thu, 3 Apr 2008 10:39:49 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m33EdnxU018476; Thu, 3 Apr 2008 10:39:49 -0400 Received: from localhost.localdomain (sebastian-int.corp.redhat.com [172.16.52.221]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m33EdmPt014599; Thu, 3 Apr 2008 10:39:48 -0400 Message-ID: <47F4EC2C.7000707@redhat.com> Date: Thu, 03 Apr 2008 21:03:00 -0000 From: Andrew Cagney User-Agent: Thunderbird 2.0.0.12 (X11/20080226) MIME-Version: 1.0 To: Mark Wielaard CC: frysk Subject: Re: Put refpurposes one line for easy manpage generation. References: <1207230707.4284.11.camel@localhost.localdomain> <47F4E516.4070000@redhat.com> <1207232684.4284.24.camel@localhost.localdomain> In-Reply-To: <1207232684.4284.24.camel@localhost.localdomain> Content-Type: multipart/mixed; boundary="------------070501020002050803020908" X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-Virus-Checked: Checked by ClamAV on sourceware.org X-IsSubscribed: yes Mailing-List: contact frysk-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-owner@sourceware.org X-SW-Source: 2008-q2/txt/msg00020.txt.bz2 This is a multi-part message in MIME format. --------------070501020002050803020908 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1124 Mark, I'm not fluent in XML either, however I still managed to hack up the attached (from htdocs/bugzilla). Can we do something with that? Andrew Mark Wielaard wrote: > Hi Andrew, > > On Thu, 2008-04-03 at 10:09 -0400, Andrew Cagney wrote: > >> Mark Wielaard wrote: >> >>> This puts all refpurpose tags and content on one line for better manpage >>> generation. Also did an upload-manpages. The currrent script expects >>> this tag and matching closing tag on one line, if it isn't the >>> description on the man index page will be empty (if someone knows some >>> sed foo to make this more flexible that would be appreciated). >>> http://sourceware.org/frysk/manpages/ >>> >> Our man pages are in XML for a reason; surely we can make use of that. >> A short script should do it. >> > > Then instead of someone with sed foo, we are looking for someone with > some xslt foo :) I am sure both could be used to generate the index > page, I am just not fluent in either. See common/manpages.sh for the > current script which currently uses just a simple sed invocation. > > Cheers, > > Mark > > --------------070501020002050803020908 Content-Type: text/x-java; name="Bug.java" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="Bug.java" Content-length: 4750 import java.io.File; import java.io.FilenameFilter; import java.util.Map; import java.util.TreeMap; import java.util.LinkedList; import java.util.List; import java.util.Iterator; import java.util.Collection; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Node; public class Bug implements Comparable { private final File file; private final String id; private final int hash; Bug (File file) { this.file = file; this.id = file.getName ().split ("\\.")[0]; this.hash = Integer.parseInt (this.id); } /** * Is the object equals to this one. */ public boolean equals (Object o) { return ((Bug)o).hash == hash; } /** * Return the hash code for this ID (hash on the underlying ID * value). */ public int hashCode () { return hash; } /** * Assuming that the two objects are the same, do a relative * comparison. */ public int compareTo (Object o) { Bug rhs = (Bug)o; return rhs.hash - this.hash; } /** * The bug as a simplified string. */ public String toString () { return id; } public String toPrint () { return "" + id + " " + reporter + " " + duplicate + " " + dependson + " " + blocked + " " + description; } String bug_id = "?"; String description = ""; List blocked = new LinkedList (); List dependson = new LinkedList (); boolean duplicate = false; String reporter; String assigned_to; private void walk (Map map, Node parent) { for (Node child = parent.getFirstChild (); child != null; child = child.getNextSibling ()) { if (child.getNodeType () == Node.TEXT_NODE && parent.getNodeType () == Node.ELEMENT_NODE) { // Grab the bug-id as it flies by. String name = parent.getNodeName (); String value = child.getNodeValue (); if (name.equals ("bug_id")) bug_id = value; if (name.equals ("short_desc")) description = description + value; // Print anything this blocks if (name.equals ("blocked")) blocked.add (map.get (value)); if (name.equals ("dependson")) dependson.add (map.get (value)); if (name.equals ("resolution")) duplicate = value.equals("DUPLICATE"); if (name.equals ("reporter")) reporter = value; if (name.equals ("assigned_to")) assigned_to = value; } walk (map, child); } } private static final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); public void parse (Map map) { try { DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder (); String file = id + ".xml"; Document document = documentBuilder.parse (file); walk (map, document); } catch (javax.xml.parsers.ParserConfigurationException e) { throw new RuntimeException (e); } catch (org.xml.sax.SAXException e) { throw new RuntimeException (e); } catch (java.io.IOException e) { throw new RuntimeException (e); } catch (gnu.xml.dom.ls.DomLSException e) { System.err.println (id + " parse error"); } } public static TreeMap slurp () { TreeMap map = new TreeMap (); File[] dotXml = new File (".").listFiles (new FilenameFilter () { public boolean accept (File path, String filename) { return filename.matches ("^[0-9]*.xml$"); } }); System.out.println ("Loading bugs"); for (int i = 0; i < dotXml.length; i++) { File file = dotXml[i]; Bug bug = new Bug (file); map.put (bug.id, bug); } System.out.println ("Parsing bugs"); for (Iterator i = map.values ().iterator (); i.hasNext (); ) { Bug bug = (Bug)i.next (); bug.parse (map); System.out.println (bug.id + " " + bug.description); } return map; } public static void main (String[] args) { TreeMap map = slurp (); { System.out.println ("Roots:"); Collection roots = ((Map) (map.clone())).values (); for (Iterator i = roots.iterator (); i.hasNext (); ) { Bug bug = (Bug)i.next (); if (bug.blocked.size () > 0) i.remove (); } for (Iterator i = roots.iterator (); i.hasNext (); ) { Bug bug = (Bug)i.next (); System.out.println ("Root: " + bug.toPrint ()); } } { System.out.println ("Duplicates:"); for (Iterator i = map.values ().iterator (); i.hasNext (); ) { Bug bug = (Bug)i.next (); if (!bug.duplicate) continue; if (bug.dependson.size () > 0) System.out.println ("dependson: " + bug.toPrint ()); if (bug.blocked.size () != 1) System.out.println ("blocked: " + bug.toPrint ()); } } } } --------------070501020002050803020908--