#1880: Unify flag descriptions to generate both docs and code
----------------------+-----------------------------------------------------
 Reporter:  simonmar  |          Owner:             
     Type:  task      |         Status:  new        
 Priority:  normal    |      Milestone:  6.10 branch
Component:  Compiler  |        Version:  6.8.1      
 Severity:  normal    |     Resolution:             
 Keywords:            |     Difficulty:  Unknown    
 Testcase:            |   Architecture:  Unknown    
       Os:  Unknown   |  
----------------------+-----------------------------------------------------
Comment (by claus):

 This ticket is the only surviving replacement of #1226, so it must be on
 topic. And the point was that something had gone missing unresolved from
 that ticket, including the motivation for the changes that seems to elude
 you (such as easy programatic access to the docs matching a particular
 version of ghc).

 But I'm not unwilling to help: if the patch for #1226 had been accepted,
 every GHC installation would come with a `flagref.txt` file extracted from
 `flags.xml` serving as the basis for `--full-flag-help`, but also easily
 useable to extract just the flag names.

 Meanwhile, you don't have to wait for the grand unification in this ticket
 to succeed, you could use a subset of the xsl file used in that patch to
 extract the flag names from `flags.xml` (at least to a first
 approximation, there are a handful of special cases that may need further
 tweaking, like `-monly-[432]-regs`):
 {{{
 <xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; >

 <xsl:output method="text" omit-xml-declaration="yes" />
 <xsl:template match="/">

 <xsl:for-each select="//sect2">
   <xsl:for-each select=".//row">
     <xsl:choose>
   <xsl:when test="entry[1]='Flag'">
   </xsl:when>
   <xsl:otherwise>
   <xsl:value-of select="normalize-space(entry[1])"/>
   <xsl:text>
 </xsl:text>
   </xsl:otherwise>
   </xsl:choose>
   </xsl:for-each>
 </xsl:for-each>

 </xsl:template>
 </xsl:stylesheet>
 }}}
 and then you can run this (after merging back into a single line or
 script)
 {{{
 $ sed 's/\(<?xml version[^>]*>\)/
         \0\n<!DOCTYPE sect1 \[<!ENTITY ndash  "-"> <!ENTITY ldquo  "\`">
 <!ENTITY rdquo  "'\''">\]>/'
       ghc/docs/users_guide/flags.xml
   | xsltproc flaglist.xsl -
 }}}
 to get
 {{{
 -?
 -help
 -n
 -v
 -vn
 -V
 --supported-languages
 --info
 --version
 --numeric-version
 --print-libdir
 -ferror-spans
 -Hsize
 -Rghc-timing
 ..
 }}}

 btw 1: it would be useful to make sure that `<option>` is *only* used for
 options in the users guide, and then compare the list of options extracted
 from the users guide to the list of options extracted from `flags.xml` (or
 whatever unified source this ticket leads to). that would reduce the
 number of outdated flag-references in the users guide.

 btw 2: is there a bash completion file for haskell tools somewhere?

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1880#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to