diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-10-29 05:58:09 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-10-29 05:58:09 +0000 |
commit | 338bd0a160ae75d9ee9b8786484d11b3a4bc3c3c (patch) | |
tree | aab0f6dd77d7413a2cd1670d2a66908ae07e6973 | |
parent | 6a0b9846e60e321b1e295072e3d2d01d8411cc60 (diff) |
Update FindSpecRefs to recognize named section references.
- Unfortunately, I don't have an easy way to map from named sections
to numbers nicely so they don't get page numbers or integrate in
the list well.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58368 91177308-0d34-0410-b5e6-96231b3b80d8
-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') |