diff options
-rwxr-xr-x | utils/FindSpecRefs | 55 |
1 files changed, 40 insertions, 15 deletions
diff --git a/utils/FindSpecRefs b/utils/FindSpecRefs index a537fe1f84..c74ca3d228 100755 --- a/utils/FindSpecRefs +++ b/utils/FindSpecRefs @@ -596,6 +596,10 @@ kDocuments = { } def findClosestTOCEntry(data, target): + # FIXME: Fix for named spec references + if isinstance(target[0],str): + return ('.'.join(target),'<named>',1) + offset = data[2] best = None for (name,page) in data[1]: @@ -643,7 +647,7 @@ def findClosestLineReference(clangRoot, doxyName, target): ### -nameAndSpecRefRE = re.compile(r"(C99|C90|C\+\+|H\&S) (([0-9]+)(\.[0-9]+)*(p[0-9]+)?)") +nameAndSpecRefRE = re.compile(r"(C99|C90|C\+\+|H\&S) ((([0-9]+)(\.[0-9]+)*|\[[^]]+\])(p[0-9]+)?)") loneSpecRefRE = re.compile(r" (([0-9]+)(\.[0-9]+){2,100}(p[0-9]+)?)") def scanFile(path, filename): try: @@ -673,12 +677,24 @@ def scanFile(path, filename): class SpecIndex: @staticmethod def fromstring(str): - secs = str.split('.') - paragraph = None - if 'p' in secs[-1]: - secs[-1],p = secs[-1].split('p',1) - paragraph = int(p) - indices = map(int, secs) + # Check for named sections + if str[0] == '[': + assert ']' in str + secs = str[1:str.index(']')].split('.') + tail = str[str.index(']')+1:] + if tail: + assert tail[0] == 'p' + paragraph = int(tail[1:]) + else: + paragraph = None + indices = secs + else: + secs = str.split('.') + paragraph = None + if 'p' in secs[-1]: + secs[-1],p = secs[-1].split('p',1) + paragraph = int(p) + indices = map(int, secs) return SpecIndex(indices, paragraph) def __init__(self, indices, paragraph=None): @@ -788,20 +804,26 @@ def main(): global options from optparse import OptionParser parser = OptionParser("usage: %prog [options] CLANG_ROOT <output-dir>") - - (options, args) = parser.parse_args() + parser.add_option("", "--debug", dest="debug", + help="Print extra debugging output", + action="store_true", + default=False) + (opts, args) = parser.parse_args() if len(args) != 2: parser.error("incorrect number of arguments") references = [] root,outputDir = args - for (dirpath, dirnames, filenames) in os.walk(root): - for filename in filenames: - name,ext = os.path.splitext(filename) - if ext in ('.c', '.cpp', '.h', '.def'): - fullpath = os.path.join(dirpath, filename) - references.extend(list(scanFile(fullpath, filename))) + if os.path.isdir(root): + for (dirpath, dirnames, filenames) in os.walk(root): + for filename in filenames: + name,ext = os.path.splitext(filename) + if ext in ('.c', '.cpp', '.h', '.def'): + fullpath = os.path.join(dirpath, filename) + references.extend(list(scanFile(fullpath, filename))) + else: + references.extend(list(scanFile(root, root))) refTree = buildRefTree(references) @@ -813,6 +835,9 @@ def main(): print 'Found %d references.'%(len(references),) + if opts.debug: + pprint(refTree) + referencesPath = os.path.join(outputDir,'references.html') print 'Writing: %s'%(referencesPath,) f = open(referencesPath,'w') |