Bug Tracker

Show
Ignore:
Timestamp:
12/16/07 22:08:02 (1 year ago)
Author:
davidserduke
Message:

Fixed a bug and added a new parameter 'debug' to help when the xml portion can't be output correctly.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/tools/wikiapi2xml/createjQueryXMLDocs.py

    r4169 r4190  
    2525def printdebug(msg): 
    2626  if opts.verbose != "false" and infoNode != None: 
    27     msgNode = doc.createElement("msg") 
    28     msgNode.appendChild(doc.createTextNode(msg)) 
    29     infoNode.appendChild(msgNode) 
    30     # print msg 
    31     # print >>sys.stderr, msg 
     27    if opts.debug == "false": 
     28      msgNode = doc.createElement("msg") 
     29      msgNode.appendChild(doc.createTextNode(msg)) 
     30      infoNode.appendChild(msgNode) 
     31    else: 
     32      print msg 
     33      # print >>sys.stderr, msg 
    3234 
    3335# class to create static functions 
     
    4547    self.startingUrl = "API" 
    4648    self.exporterUrl = "http://docs.jquery.com/Special:Export"; 
    47     self.version = "Unknown" 
     49    self.version = "" 
    4850    self.convertLinks = "html" 
    4951    self.verbose = "false"  
     52    self.debug = "false" 
    5053    self.timestamp = "0" 
    5154    self.parseOptions(form) 
     
    7073      elif key == "verbose": 
    7174        self.verbose = form.getvalue(key) 
     75      elif key == "debug": 
     76        self.debug = form.getvalue(key) 
    7277 
    7378  def url(self, url): 
     
    171176 
    172177  def exportXML(self, parent): 
     178    printdebug("Exporting '" + self.page.url + "'")  
    173179    for child in self.children: 
    174180      if (child != None): 
     
    185191 
    186192  def exportXML(self, parent): 
     193    global subcat 
     194 
     195    printdebug("Exporting '" + self.page.url + "'")  
    187196    node = doc.createElement("cat") 
    188197    node.setAttribute("value", self.page.url)  
    189198    parent.appendChild(node) 
     199    # new cat so reset subcat 
     200    subcat = { 'name':'', 'node':None } 
     201    printdebug("Reset subcat to None"); 
    190202    for child in self.children: 
    191203      if (child != None): 
     
    379391          arg['num'] = 0 
    380392          arg['index'] = None 
     393          # create element as 'entry' initially till get a 'type' part then change it 
    381394          node = doc.createElement("entry") 
    382395          node.setAttribute("timestamp", self.page.timestamp) 
     
    384397            # have left a subcat so reset 
    385398            subcat = { 'name':'', 'node':None } 
     399            printdebug("Reset subcat to None"); 
    386400          ## != "Documentation" because in the wiki some people are using it as a general header 
    387401          elif self.page.header != "Unheadered" and self.page.header != "Documentation" and self.page.header != subcat['name']: 
     
    392406            n.setAttribute('value', subcat['name']) 
    393407            parent.appendChild(n) 
     408            printdebug("Set subcat to " + subcat['name']); 
    394409          # if there is a subcat then append to that, otherwise go right to parent 
    395410          if subcat['node'] != None: 
     
    479494    return 
    480495  if opts.supressContentType == "false": 
    481     print "Content-Type: text/xml\n" 
     496    if opts.debug == "false": 
     497      print "Content-Type: text/xml\n" 
     498    else: 
     499      print "Content-Type: text/plain\n" 
    482500 
    483501  impl = minidom.getDOMImplementation() 
     
    488506  page = XMLPage(opts.startingUrl) 
    489507  nodeTree = Node.factory(page) 
    490   doc.documentElement.setAttribute("version", opts.version) 
     508  doc.documentElement.setAttribute("startdoc", opts.startingUrl) 
    491509  doc.documentElement.setAttribute("timestamp", opts.timestamp) 
     510  if opts.version != "": 
     511    doc.documentElement.setAttribute("version", opts.version) 
    492512  if nodeTree == None: 
    493513    errorNode = doc.createElement("error");