Skip to content
This repository
Browse code

Cleanup, better error handling for malformed comment block

  • Loading branch information...
commit c8757ed62671e00ee7a93dde628aaeda7da89136 1 parent b9ee1f4
Adam Moore authored

Showing 2 changed files with 4 additions and 75 deletions. Show diff stats Hide diff stats

  1. +4 47 bin/yuidoc_generate.py
  2. +0 28 bin/yuidoc_parse.py
51 bin/yuidoc_generate.py
@@ -93,11 +93,7 @@ def cleanseStr(self, strg):
93 93
94 94 def write(self, filename, data):
95 95 out = open(os.path.join(self.outpath, filename), "w")
96   - # log.info(data);
97   - # out.writelines(unicode(data, errors='strict'))
98   - # out.writelines(unicode(data, 'utf-8', 'xmlcharrefreplace'))
99 96 out.writelines(str(data))
100   - # out.writelines(unicode(data))
101 97 out.close()
102 98
103 99 def process(self):
@@ -140,12 +136,6 @@ def transferToTemplate(prop, dict, template, valOverride=''):
140 136 val = ""
141 137 if prop in dict:
142 138 val = unicode(dict[prop])
143   - # val = str(dict[prop])
144   - # val = dict[prop]
145   - # if 'encode' in val:
146   - # log.info(val)
147   - # val.encode('ascii', 'xmlcharrefreplace')
148   - # log.info(val)
149 139
150 140 if valOverride:
151 141 val = valOverride
@@ -180,9 +170,6 @@ def shouldShowClass(item):
180 170 return False
181 171
182 172 def soft_sort(x, y):
183   - # pat = re.compile(r"[\_\-\.]")
184   - # return cmp(pat.sub('', x.lower()), pat.sub('', y.lower()))
185   - # pat = re.compile(r"[\_\-\.]")
186 173 return cmp(x.lower(), y.lower())
187 174
188 175
@@ -201,7 +188,6 @@ def getPropsFromSuperclass(superc, classes, dict):
201 188 elif const.PROTECTED in superprop: access = const.PROTECTED
202 189 else:access = ""
203 190 inhdef.append({const.NAME: prop, const.ACCESS: access, const.DEPRECATED: const.DEPRECATED in superprop})
204   - #inhdef.append(superprop)
205 191 if const.METHODS in superc:
206 192 inhdef = dict[const.METHODS][supercname] = []
207 193 keys = superc[const.METHODS].keys()
@@ -209,7 +195,6 @@ def getPropsFromSuperclass(superc, classes, dict):
209 195 for method in keys:
210 196 supermethod = superc[const.METHODS][method]
211 197 if shouldShow(supermethod):
212   - #inhdef.append(method)
213 198 if const.PRIVATE in supermethod: access = const.PRIVATE
214 199 elif const.PROTECTED in supermethod: access = const.PROTECTED
215 200 else:access = ""
@@ -309,12 +294,7 @@ def allprop_sort(x, y):
309 294 transferToTemplate(const.OPTIONAL, m, t)
310 295
311 296 transferToTemplate(const.BETA, m, t, "Beta")
312   - # if const.BETA in m:
313   - # t[const.BETA] = "Beta"
314 297 transferToTemplate(const.EXPERIMENTAL, m, t, "Experimental")
315   - # if const.EXPERIMENTAL in m:
316   - # t[const.EXPERIMENTAL] = "Experimental"
317   -
318 298
319 299 if len(m[const.SUBMODULES]) > 0:
320 300 strg = ', '.join(m[const.SUBMODULES])
@@ -654,33 +634,10 @@ def allprop_sort(x, y):
654 634 try:
655 635 pkgMap[i] = self.data[const.CLASS_MAP][i][const.MODULE]
656 636 except:
657   - log.warn('class map ' + i + ' failure (no module declaration?)')
658   -
659   - # log.info(" ")
660   - # log.info(unicode(keys))
661   - # log.info(" ")
662   - # for i in keys:
663   - # ns = i.split('.')
664   - # log.info("processing: " + unicode(ns))
665   - # cn = ns[len(ns) - 1]
666   - # log.info("target class: " + cn)
667   - # current = pkgMap
668   - # for j in ns:
669   - # if cn == j:
670   - # if j in current:
671   - # log.info("already defined: " + j)
672   - # else:
673   - # log.info("class: " + j + ", full class: " + i)
674   - # current[j] = self.data[const.CLASS_MAP][i]['module']
675   - # else:
676   - # if j not in current:
677   - # current[j] = {}
678   - # current = current[j]
679   -
680   - # # log.info(" ")
681   - # log.info(unicode(pkgMap))
682   - # classjson = "YAHOO.env.classMap = " + simplejson.dumps(pkgMap)
683   - # log.info(classjson)
  637 + try:
  638 + log.warn('class map ' + i + ' failure (no module declaration?)')
  639 + except: pass
  640 +
684 641 t.pkgmap = simplejson.dumps(pkgMap)
685 642 self.write("classmap.js", t)
686 643
28 bin/yuidoc_parse.py
@@ -266,13 +266,6 @@ def isTag(token):
266 266 """ identify an attribute tag vs a description block """
267 267 return token.strip()[:1] == "@"
268 268
269   - # extracts compound comment blocks .. like {type}
270   - # def compound_sub(match):
271   - # if match.group(4):
272   - # return "", match.group(4) + match.group(5)
273   - # else:
274   - # return match.group(2), (match.group(1) + match.group(3)).strip()
275   -
276 269 def parseParams(tokenMap, dict, srctag=const.PARAM, desttag=const.PARAMS):
277 270 if srctag in tokenMap:
278 271 # params must be an array because they need to stay in order
@@ -391,9 +384,6 @@ def defineClass(name):
391 384 tokenMap[token] = []
392 385
393 386
394   - # if desc:
395   -# desc = unicode(desc, 'utf-8', 'xmlcharrefreplace')
396   -
397 387 tokenMap[token].append(desc)
398 388
399 389 # There are key pieces of info we need to have before we
@@ -434,15 +424,12 @@ def defineClass(name):
434 424 # outer class
435 425 if const.FOR in tokenMap:
436 426 name = tokenMap[const.FOR][0]
437   - #shortName, longName = self.getClassName(name, self.currentNamespace)
438 427 longName = name
439 428 currentFor = longName
440 429 if const.CLASS not in tokenMap:
441 430 if longName in self.data[const.CLASS_MAP]:
442 431 self.currentClass = longName
443 432 else:
444   - # msg = "@for tag references a class that has not been defined"
445   - # raise ValueError, unicode(tokens) + " " + msg
446 433 defineClass(name)
447 434
448 435 tokenMap.pop(const.FOR)
@@ -544,12 +531,6 @@ def parseModule(tokenMap):
544 531 if const.MODULE in tokenMap:
545 532 target, tokenMap = parseModule(tokenMap)
546 533
547   - # if not 'subModName' in self:
548   - # self.subModName = None
549   -
550   -
551   - # log.warn("Here");
552   -
553 534 if self.subModName:
554 535 self.data[const.MODULES][self.currentModule][const.SUBDATA][self.subModName][const.NAME] = longName
555 536 if const.DESCRIPTION in tokenMap:
@@ -625,7 +606,6 @@ def parseModule(tokenMap):
625 606 if not const.METHODS in c: c[const.METHODS] = {}
626 607
627 608 if method in c[const.METHODS]:
628   - # print "WARNING: %s - method %s was redefined (method overloading is not supported)" %(tokens, method)
629 609 log.warn("WARNING: method %s was redefined" %(method))
630 610 else:
631 611 c[const.METHODS][method] = parseParams(tokenMap, {})
@@ -646,7 +626,6 @@ def parseModule(tokenMap):
646 626 if not const.EVENTS in c: c[const.EVENTS] = {}
647 627
648 628 if event in c[const.EVENTS]:
649   - #print "WARNING: %s - event %s was redefined" %(tokens, event)
650 629 log.warn("WARNING: event %s was redefined" %(event))
651 630 else:
652 631 c[const.EVENTS][event] = parseParams(tokenMap, {})
@@ -667,7 +646,6 @@ def parseModule(tokenMap):
667 646 if not const.PROPERTIES in c: c[const.PROPERTIES] = {}
668 647
669 648 if property in c[const.PROPERTIES]:
670   - # print "WARNING: %s - Property %s was redefined" %(tokens, property)
671 649 log.warn("WARNING: Property %s was redefined" %(property))
672 650 else:
673 651 c[const.PROPERTIES][property] = {}
@@ -685,7 +663,6 @@ def parseModule(tokenMap):
685 663 c = self.data[const.CLASS_MAP][self.currentClass]
686 664 if const.ATTRIBUTE in tokenMap:
687 665 config = tokenMap[const.ATTRIBUTE][0]
688   - # config.hasEvents = True;
689 666 else:
690 667 config = tokenMap[const.CONFIG][0]
691 668
@@ -693,7 +670,6 @@ def parseModule(tokenMap):
693 670 if not const.CONFIGS in c: c[const.CONFIGS] = {}
694 671
695 672 if config in c[const.CONFIGS]:
696   - # print "WARNING: %s - Property %s was redefined" %(tokens, config)
697 673 log.warn("WARNING: Property %s was redefined" %(config))
698 674 else:
699 675 c[const.CONFIGS][config] = {}
@@ -702,7 +678,6 @@ def parseModule(tokenMap):
702 678
703 679 if const.ATTRIBUTE in tokenMap:
704 680 tokenMap.pop(const.ATTRIBUTE)
705   - # target[const.HASEVENTS] = True;
706 681
707 682 if not const.EVENTS in c: c[const.EVENTS] = {}
708 683
@@ -795,9 +770,6 @@ def get3xAttEvt(eventname, config):
795 770 for token in tokenMap:
796 771 if token not in target:
797 772 target[token] = tokenMap[token][0]
798   - else:
799   - msg = "WARNING no target, this block will be skipped"
800   - # print "\n" + self.currentFile + "\n" + msg + ":\n\n" + unicode(tokens) + "\n"
801 773
802 774 def main():
803 775 optparser = OptionParser("usage: %prog [options] inputdir1 inputdir2 etc")

0 comments on commit c8757ed

Please sign in to comment.
Something went wrong with that request. Please try again.