Exemplo n.º 1
0
def main():

    print "mkdocs.py $Revision: 1.9 $\n"

    fmap = {}
    for file in ClassToHeaderMap.values():
        if type(file) == type([]): continue
        fmap[file] = 0
    filelist = fmap.keys()
    filelist.sort()

    #-------------------------------------------------
    # Loop over header files to be scanned
    #-------------------------------------------------

    # Make sure html and txt directories exist

    os.system("mkdir -p html; mkdir -p txt")

    count = 0
    for index, filename in enumerate(filelist):

        # Create full pathname to header

        file = LOCALBASE + filename
        if not os.path.exists(file):
            file = BASE + filename
            if not os.path.exists(file):
                print "** file %s not found" % file
                continue
        file = os.path.abspath(file)

        # Scan header and parse it for classes

        record, items = parseHeader(file)
        if record == '': continue
        records = splitHeader(record)
        if len(records) == 0: continue

        # Now strip away path up to "/src/" in pathname of header

        header = file
        k = rfind(header, "/src/")  # search from right
        if k > 0: header = header[k + 5:]

        filestem = replace(header, 'interface/', '')
        filestem = split(filestem, '.h')[0]
        filestem = replace(filestem, '/', '.')

        # Initialize map to contain info about classes, methods & datamembers

        db = {'version': VERSION, 'filestem': filestem, 'header': header}

        names = []
        for irecord, (record, group, start, end) in enumerate(records):

            # Get actual record from items map

            key = strip(record)
            if items.has_key(key):
                record = items[key]
                if type(record) == type(()):
                    record, extraRecord = record
            record = stripBlanklines(record)

            if group == "namespace":
                name = strip(namespaceName(record))
                if name != '': names.append(name)

            elif group == "endnamespace":
                if len(names) > 0: names.pop()

            elif group in ["endclass", "endstructclass"]:

                fullname = joinfields(names, "::")

                # For now ignore templates
                if find(fullname, '<') > -1: continue

                # Get methods and/or datamembers and write them out

                db['scopes'] = {}
                db['methods'] = {}
                db['datamembers'] = {}
                db['classname'] = fullname
                db['classlist'] = []
                db['baseclassnames'] = []
                db['signature'] = {}
                classMethods(fullname, db)
                db['baseclassnames'] = []
                classDataMembers(fullname, db)

                nmeth = len(db['methods'])
                ndata = len(db['datamembers'])

                if nmeth > 0 or ndata > 0:

                    count += 1
                    print "%5d\t%s" % (count, fullname)

                    cname = split(fullname, '::').pop()
                    methfilename = "txt/%s.%s.txt" % (filestem, cname)

                    out = open(methfilename, 'w')
                    printHeader(db, out)
                    printMethods(db, out)
                    printDataMembers(db, out)
                    out.close()

                    writeHTML(db, methfilename)
                names.pop()

            elif group in ["class", "structclass"]:
                classname, basenames, template = getClassname(record)
                names.append(classname)

    # Create index.html

    print "\ncreating html/index.html.."
    os.system("mkindex.py")
    print "\n\tmkdocs.py is done!\n"
Exemplo n.º 2
0
def main():

    print "mkdocs.py $Revision: 1.9 $\n"

    fmap = {}
    for file in ClassToHeaderMap.values():
        if type(file) == type([]):
            continue
        fmap[file] = 0
    filelist = fmap.keys()
    filelist.sort()

    # -------------------------------------------------
    # Loop over header files to be scanned
    # -------------------------------------------------

    # Make sure html and txt directories exist

    os.system("mkdir -p html; mkdir -p txt")

    count = 0
    for index, filename in enumerate(filelist):

        # Create full pathname to header

        file = LOCALBASE + filename
        if not os.path.exists(file):
            file = BASE + filename
            if not os.path.exists(file):
                print "** file %s not found" % file
                continue
        file = os.path.abspath(file)

        # Scan header and parse it for classes

        record, items = parseHeader(file)
        if record == "":
            continue
        records = splitHeader(record)
        if len(records) == 0:
            continue

        # Now strip away path up to "/src/" in pathname of header

        header = file
        k = rfind(header, "/src/")  # search from right
        if k > 0:
            header = header[k + 5 :]

        filestem = replace(header, "interface/", "")
        filestem = split(filestem, ".h")[0]
        filestem = replace(filestem, "/", ".")

        # Initialize map to contain info about classes, methods & datamembers

        db = {"version": VERSION, "filestem": filestem, "header": header}

        names = []
        for irecord, (record, group, start, end) in enumerate(records):

            # Get actual record from items map

            key = strip(record)
            if items.has_key(key):
                record = items[key]
                if type(record) == type(()):
                    record, extraRecord = record
            record = stripBlanklines(record)

            if group == "namespace":
                name = strip(namespaceName(record))
                if name != "":
                    names.append(name)

            elif group == "endnamespace":
                if len(names) > 0:
                    names.pop()

            elif group in ["endclass", "endstructclass"]:

                fullname = joinfields(names, "::")

                # For now ignore templates
                if find(fullname, "<") > -1:
                    continue

                # Get methods and/or datamembers and write them out

                db["scopes"] = {}
                db["methods"] = {}
                db["datamembers"] = {}
                db["classname"] = fullname
                db["classlist"] = []
                db["baseclassnames"] = []
                db["signature"] = {}
                classMethods(fullname, db)
                db["baseclassnames"] = []
                classDataMembers(fullname, db)

                nmeth = len(db["methods"])
                ndata = len(db["datamembers"])

                if nmeth > 0 or ndata > 0:

                    count += 1
                    print "%5d\t%s" % (count, fullname)

                    cname = split(fullname, "::").pop()
                    methfilename = "txt/%s.%s.txt" % (filestem, cname)

                    out = open(methfilename, "w")
                    printHeader(db, out)
                    printMethods(db, out)
                    printDataMembers(db, out)
                    out.close()

                    writeHTML(db, methfilename)
                names.pop()

            elif group in ["class", "structclass"]:
                classname, basenames, template = getClassname(record)
                names.append(classname)

                # Create index.html

    print "\ncreating html/index.html.."
    os.system("mkindex.py")
    print "\n\tmkdocs.py is done!\n"
Exemplo n.º 3
0
def main():
	
	print "mkclassmap.py $Revision: 1.5 $\n"

	subpackagelist = SUBPACKAGELIST
	filelist = []
	if Update:
		for subpackage in subpackagelist:
			print "scan sub-package: %s" % subpackage
			file = "%s/interface/*.h" % subpackage
			hlist = glob(file)
			hlist.sort()
			filelist += hlist
	else:

		for subpackage in subpackagelist:
			package, subpkg = split(subpackage,'/')
			if subpkg == "*":

				cmd = "%s%s" % (LOCALBASE, subpackage)
				subsystems = filter(lambda x: os.path.isdir(x), glob(cmd))
				if len(subsystems) == 0:
					cmd = "%s%s" % (PKGBASE, subpackage)
					subsystems = filter(lambda x: os.path.isdir(x), glob(cmd))
					
				subsystems = map(lambda x: split(x, '/').pop(), subsystems)
			else:
				subsystems = [split(subpackage, '/').pop()]

			for subsystem in subsystems:
				if skipsubsystem.match(subsystem) != None: continue
				
				dirpath = "%s%s/%s" % (PKGBASE, package, subsystem)
				if not os.path.exists(dirpath):
					dirpath = "%s%s/%s" % (LOCALBASE, package, subsystem)
					if not os.path.exists(dirpath):
						"** directory %s not found" % dirpath
						continue
				print "scan sub-package: %s/%s" % (package, subsystem)
				file = "%s/interface/*.h" % dirpath
				hlist = glob(file)
				hlist.sort()
				filelist += hlist

	# Filter headers
	filelist = filter(lambda x: skipheader.search(x) == None, filelist)
	
	#-------------------------------------------------
	# Loop over header files to be scanned
	#-------------------------------------------------
	cmap = {}
	count = 0
	for index, file in enumerate(filelist):
		if not os.path.exists(file):
			print "** file %s not found" % file
			continue
		
		file = os.path.abspath(file)
		
		# Scan header and parse it for classes
		
		record, items = parseHeader(file)
		if record == '': continue
		records = splitHeader(record)
		if len(records) == 0: continue

		# Now strip away path up to "/src/" in pathname of header
		
		header = file
		k = rfind(header, "/src/") # search from right
		if k > 0: header = header[k+5:]
		
		names = []
		for irecord, (record, group, start, end) in enumerate(records):

			# Get actual record from items map

			key = strip(record)
			if items.has_key(key):
				record = items[key]
				if type(record) == type(()):
					record, extraRecord = record
			record = stripBlanklines(record)
			
			if group == "namespace":
				name = strip(namespaceName(record))
				if name != '': names.append(name)

			elif group == "endnamespace":
				if len(names) > 0: names.pop()
				
			elif group in ["endclass", "endstructclass"]:
				
				fullname = joinfields(names, "::")

				# Check for uninstantiated templates and
				# create keys

				if find(fullname, '<') > -1:
					tplate = True
					fullkey = split(fullname, '<')[0]
				else:
					tplate = False
					fullkey = fullname					
				key = stripnamespace.sub("", fullkey)
				
				if Update:
					addToMap(fullkey, key, header, ClassToHeaderMap)
				else:
					addToMap(fullkey, key, header, cmap)

				count += 1
				print "%5d\t%s" % (count, fullkey)
								
				names.pop()
				
			elif group in ["class", "structclass"]:
				classname, basenames, template = getClassname(record)
				names.append(classname)

	# Write out class to header map

	if Update:
		print "updating classmap.py..."
		hmap = ClassToHeaderMap
	else:
		print "creating classmap.py..."
		hmap = cmap

	recs = []
	keys = hmap.keys()
	keys.sort()
	for key in keys:
		value = hmap[key]
		if type(value) == type(""):
			recs.append("'%s': '%s'" % (key, value))
		else:
			recs.append("'%s': %s"   % (key, value))

	record = joinfields(recs,',\n')		
	outfile = CLASSMAPFILE
	out = open(outfile,'w')
	out.write('# Created: %s\n' % ctime(time()))
	out.write('# Version: %s\n' % VERSION)
	out.write('#$Revision: 1.5 $\n')
	out.write("ClassToHeaderMap = {\\\n")
	out.write(record+'\n')
	out.write("}\n")