File: doxygen_scan.py

package info (click to toggle)
opencv 4.6.0%2Bdfsg-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 276,172 kB
  • sloc: cpp: 1,079,020; xml: 682,526; python: 43,885; lisp: 30,943; java: 25,642; ansic: 7,968; javascript: 5,956; objc: 2,039; sh: 1,017; cs: 601; perl: 494; makefile: 179
file content (48 lines) | stat: -rw-r--r-- 1,801 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import traceback

class Symbol(object):
    def __init__(self, anchor, type, cppname):
        self.anchor = anchor
        self.type = type
        self.cppname = cppname
        #if anchor == 'ga586ebfb0a7fb604b35a23d85391329be':
        #    print(repr(self))
        #    traceback.print_stack()

    def __repr__(self):
        return '%s:%s@%s' % (self.type, self.cppname, self.anchor)

def add_to_file(files_dict, file, anchor):
    anchors = files_dict.setdefault(file, [])
    anchors.append(anchor)


def scan_namespace_constants(ns, ns_name, files_dict):
    constants = ns.findall("./member[@kind='enumvalue']")
    for c in constants:
        c_name = c.find("./name").text
        name = ns_name + '::' + c_name
        file = c.find("./anchorfile").text
        anchor = c.find("./anchor").text
        #print('    CONST: {} => {}#{}'.format(name, file, anchor))
        add_to_file(files_dict, file, Symbol(anchor, "const", name))

def scan_namespace_functions(ns, ns_name, files_dict):
    functions = ns.findall("./member[@kind='function']")
    for f in functions:
        f_name = f.find("./name").text
        name = ns_name + '::' + f_name
        file = f.find("./anchorfile").text
        anchor = f.find("./anchor").text
        #print('    FN: {} => {}#{}'.format(name, file, anchor))
        add_to_file(files_dict, file, Symbol(anchor, "fn", name))

def scan_class_methods(c, c_name, files_dict):
    methods = c.findall("./member[@kind='function']")
    for m in methods:
        m_name = m.find("./name").text
        name = c_name + '::' + m_name
        file = m.find("./anchorfile").text
        anchor = m.find("./anchor").text
        #print('    Method: {} => {}#{}'.format(name, file, anchor))
        add_to_file(files_dict, file, Symbol(anchor, "method", name))