Skip to content

Commit

Permalink
Cleanup, better error handling for malformed comment block
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Moore committed Dec 6, 2008
1 parent b9ee1f4 commit c8757ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 75 deletions.
51 changes: 4 additions & 47 deletions bin/yuidoc_generate.py
Expand Up @@ -93,11 +93,7 @@ def cleanseStr(self, strg):

def write(self, filename, data):
out = open(os.path.join(self.outpath, filename), "w")
# log.info(data);
# out.writelines(unicode(data, errors='strict'))
# out.writelines(unicode(data, 'utf-8', 'xmlcharrefreplace'))
out.writelines(str(data))
# out.writelines(unicode(data))
out.close()

def process(self):
Expand Down Expand Up @@ -140,12 +136,6 @@ def transferToTemplate(prop, dict, template, valOverride=''):
val = ""
if prop in dict:
val = unicode(dict[prop])
# val = str(dict[prop])
# val = dict[prop]
# if 'encode' in val:
# log.info(val)
# val.encode('ascii', 'xmlcharrefreplace')
# log.info(val)

if valOverride:
val = valOverride
Expand Down Expand Up @@ -180,9 +170,6 @@ def shouldShowClass(item):
return False

def soft_sort(x, y):
# pat = re.compile(r"[\_\-\.]")
# return cmp(pat.sub('', x.lower()), pat.sub('', y.lower()))
# pat = re.compile(r"[\_\-\.]")
return cmp(x.lower(), y.lower())


Expand All @@ -201,15 +188,13 @@ def getPropsFromSuperclass(superc, classes, dict):
elif const.PROTECTED in superprop: access = const.PROTECTED
else:access = ""
inhdef.append({const.NAME: prop, const.ACCESS: access, const.DEPRECATED: const.DEPRECATED in superprop})
#inhdef.append(superprop)
if const.METHODS in superc:
inhdef = dict[const.METHODS][supercname] = []
keys = superc[const.METHODS].keys()
keys.sort(soft_sort)
for method in keys:
supermethod = superc[const.METHODS][method]
if shouldShow(supermethod):
#inhdef.append(method)
if const.PRIVATE in supermethod: access = const.PRIVATE
elif const.PROTECTED in supermethod: access = const.PROTECTED
else:access = ""
Expand Down Expand Up @@ -309,12 +294,7 @@ def allprop_sort(x, y):
transferToTemplate(const.OPTIONAL, m, t)

transferToTemplate(const.BETA, m, t, "Beta")
# if const.BETA in m:
# t[const.BETA] = "Beta"
transferToTemplate(const.EXPERIMENTAL, m, t, "Experimental")
# if const.EXPERIMENTAL in m:
# t[const.EXPERIMENTAL] = "Experimental"


if len(m[const.SUBMODULES]) > 0:
strg = ', '.join(m[const.SUBMODULES])
Expand Down Expand Up @@ -654,33 +634,10 @@ def allprop_sort(x, y):
try:
pkgMap[i] = self.data[const.CLASS_MAP][i][const.MODULE]
except:
log.warn('class map ' + i + ' failure (no module declaration?)')

# log.info(" ")
# log.info(unicode(keys))
# log.info(" ")
# for i in keys:
# ns = i.split('.')
# log.info("processing: " + unicode(ns))
# cn = ns[len(ns) - 1]
# log.info("target class: " + cn)
# current = pkgMap
# for j in ns:
# if cn == j:
# if j in current:
# log.info("already defined: " + j)
# else:
# log.info("class: " + j + ", full class: " + i)
# current[j] = self.data[const.CLASS_MAP][i]['module']
# else:
# if j not in current:
# current[j] = {}
# current = current[j]

# # log.info(" ")
# log.info(unicode(pkgMap))
# classjson = "YAHOO.env.classMap = " + simplejson.dumps(pkgMap)
# log.info(classjson)
try:
log.warn('class map ' + i + ' failure (no module declaration?)')
except: pass

t.pkgmap = simplejson.dumps(pkgMap)
self.write("classmap.js", t)

Expand Down
28 changes: 0 additions & 28 deletions bin/yuidoc_parse.py
Expand Up @@ -266,13 +266,6 @@ def isTag(token):
""" identify an attribute tag vs a description block """
return token.strip()[:1] == "@"

# extracts compound comment blocks .. like {type}
# def compound_sub(match):
# if match.group(4):
# return "", match.group(4) + match.group(5)
# else:
# return match.group(2), (match.group(1) + match.group(3)).strip()

def parseParams(tokenMap, dict, srctag=const.PARAM, desttag=const.PARAMS):
if srctag in tokenMap:
# params must be an array because they need to stay in order
Expand Down Expand Up @@ -391,9 +384,6 @@ def defineClass(name):
tokenMap[token] = []


# if desc:
# desc = unicode(desc, 'utf-8', 'xmlcharrefreplace')

tokenMap[token].append(desc)

# There are key pieces of info we need to have before we
Expand Down Expand Up @@ -434,15 +424,12 @@ def defineClass(name):
# outer class
if const.FOR in tokenMap:
name = tokenMap[const.FOR][0]
#shortName, longName = self.getClassName(name, self.currentNamespace)
longName = name
currentFor = longName
if const.CLASS not in tokenMap:
if longName in self.data[const.CLASS_MAP]:
self.currentClass = longName
else:
# msg = "@for tag references a class that has not been defined"
# raise ValueError, unicode(tokens) + " " + msg
defineClass(name)

tokenMap.pop(const.FOR)
Expand Down Expand Up @@ -544,12 +531,6 @@ def parseModule(tokenMap):
if const.MODULE in tokenMap:
target, tokenMap = parseModule(tokenMap)

# if not 'subModName' in self:
# self.subModName = None


# log.warn("Here");

if self.subModName:
self.data[const.MODULES][self.currentModule][const.SUBDATA][self.subModName][const.NAME] = longName
if const.DESCRIPTION in tokenMap:
Expand Down Expand Up @@ -625,7 +606,6 @@ def parseModule(tokenMap):
if not const.METHODS in c: c[const.METHODS] = {}

if method in c[const.METHODS]:
# print "WARNING: %s - method %s was redefined (method overloading is not supported)" %(tokens, method)
log.warn("WARNING: method %s was redefined" %(method))
else:
c[const.METHODS][method] = parseParams(tokenMap, {})
Expand All @@ -646,7 +626,6 @@ def parseModule(tokenMap):
if not const.EVENTS in c: c[const.EVENTS] = {}

if event in c[const.EVENTS]:
#print "WARNING: %s - event %s was redefined" %(tokens, event)
log.warn("WARNING: event %s was redefined" %(event))
else:
c[const.EVENTS][event] = parseParams(tokenMap, {})
Expand All @@ -667,7 +646,6 @@ def parseModule(tokenMap):
if not const.PROPERTIES in c: c[const.PROPERTIES] = {}

if property in c[const.PROPERTIES]:
# print "WARNING: %s - Property %s was redefined" %(tokens, property)
log.warn("WARNING: Property %s was redefined" %(property))
else:
c[const.PROPERTIES][property] = {}
Expand All @@ -685,15 +663,13 @@ def parseModule(tokenMap):
c = self.data[const.CLASS_MAP][self.currentClass]
if const.ATTRIBUTE in tokenMap:
config = tokenMap[const.ATTRIBUTE][0]
# config.hasEvents = True;
else:
config = tokenMap[const.CONFIG][0]


if not const.CONFIGS in c: c[const.CONFIGS] = {}

if config in c[const.CONFIGS]:
# print "WARNING: %s - Property %s was redefined" %(tokens, config)
log.warn("WARNING: Property %s was redefined" %(config))
else:
c[const.CONFIGS][config] = {}
Expand All @@ -702,7 +678,6 @@ def parseModule(tokenMap):

if const.ATTRIBUTE in tokenMap:
tokenMap.pop(const.ATTRIBUTE)
# target[const.HASEVENTS] = True;

if not const.EVENTS in c: c[const.EVENTS] = {}

Expand Down Expand Up @@ -795,9 +770,6 @@ def get3xAttEvt(eventname, config):
for token in tokenMap:
if token not in target:
target[token] = tokenMap[token][0]
else:
msg = "WARNING no target, this block will be skipped"
# print "\n" + self.currentFile + "\n" + msg + ":\n\n" + unicode(tokens) + "\n"

def main():
optparser = OptionParser("usage: %prog [options] inputdir1 inputdir2 etc")
Expand Down

0 comments on commit c8757ed

Please sign in to comment.