From b040a7b84d218e7ed6a725a7312b1b653a80b75a Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 23 Mar 2016 21:27:40 +0100 Subject: [PATCH] [DEV] correct some bug and set force python 2.7 --- monk.py | 16 ++--- monkArg.py | 4 +- monkHtml.py | 190 +++++++++++++++++++++++++++++-------------------- monkMethode.py | 13 ++++ monkModule.py | 42 ++++++++--- monkParse.py | 19 ++--- 6 files changed, 176 insertions(+), 108 deletions(-) diff --git a/monk.py b/monk.py index 384aed0..1e1126d 100755 --- a/monk.py +++ b/monk.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2.7 # for path inspection: import sys import os @@ -26,16 +26,16 @@ localArgument = myArg.parse() def usage(): # generic argument displayed : myArg.display() - print " all" - print " Build all (only for the current selected board) (bynary and packages)" - print " clean" - print " Clean all (same as previous)" + print(" all") + print(" Build all (only for the current selected board) (bynary and packages)") + print(" clean") + print(" Clean all (same as previous)") listOfAllModule = monkModule.list_all_module_with_desc() for mod in listOfAllModule: - print " " + mod[0] + " / " + mod[0] + "-clean" + print(" " + mod[0] + " / " + mod[0] + "-clean") if mod[1] != "": - print " " + mod[1] - print " ex: " + sys.argv[0] + " all" + print(" " + mod[1]) + print(" ex: " + sys.argv[0] + " all") exit(0) ## diff --git a/monkArg.py b/monkArg.py index ee73f51..6522d6b 100644 --- a/monkArg.py +++ b/monkArg.py @@ -241,10 +241,10 @@ class MonkArg: def display(self): - print "usage:" + print("usage:") listOfPropertiesArg = ""; for element in self.m_listProperties : listOfPropertiesArg += element.get_porperties() - print " " + sys.argv[0] + listOfPropertiesArg + " ..." + print(" " + sys.argv[0] + listOfPropertiesArg + " ...") for element in self.m_listProperties : element.display() \ No newline at end of file diff --git a/monkHtml.py b/monkHtml.py index f9a0b9e..b5b9cc0 100644 --- a/monkHtml.py +++ b/monkHtml.py @@ -3,6 +3,7 @@ import monkDebug as debug import sys import monkTools as tools #import CppHeaderParser +import os import re import codeBB import collections @@ -292,18 +293,20 @@ def write_methode(element, namespaceStack, displaySize = None, link = True): ret += ' = 0' if element['node'].get_constant() == True: ret += module.display_color(' const') - + if element['node'].get_override() == True: + ret += module.display_color(' override') + ret += ';' ret += '
' return ret -def generate_stupid_index_page(outFolder, header, footer, myLutinDoc): +def generate_stupid_index_page(outFolder, header, footer, my_lutin_doc): # create index.hml : filename = outFolder + "/index.html" tools.create_directory_of_file(filename); file = open(filename, "w") file.write(header) - file.write("

" + myLutinDoc.get_base_doc_node().get_name() + "

"); + file.write("

" + my_lutin_doc.get_base_doc_node().get_name() + "

"); file.write("
"); file.write("TODO : Main page ..."); file.write("
"); @@ -411,12 +414,39 @@ def generate_page(outFolder, header, footer, element, name_lib=""): listBaseMethode = element.get_all_sub_type(['methode', 'variable']) if len(listBaseMethode) != 0: globalWrite = "" + globalWriteProperties = "" + globalWriteSignals = "" displayLen = calculate_methode_size(listBaseMethode) for elem in listBaseMethode: if 'access' in elem.keys() \ and elem['access'] == 'private': continue - globalWrite += write_methode(elem, namespaceStack, displayLen) + find_special = False + if 'node' in elem.keys() \ + and elem['node'].get_node_type() == 'variable': + name = elem['node'].get_name() + if len(name) > 8 \ + and name[:8] == "property": + globalWriteProperties += write_methode(elem, namespaceStack, displayLen) + find_special = True + elif len(name) > 6 \ + and name[:6] == "signal": + globalWriteSignals += write_methode(elem, namespaceStack, displayLen) + find_special = True + if find_special == False: + globalWrite += write_methode(elem, namespaceStack, displayLen) + if globalWriteProperties != "": + file.write('

Properties:

\n') + file.write('
\n');
+				file.write(globalWriteProperties);
+				file.write('
\n') + file.write('
\n') + if globalWriteSignals != "": + file.write('

Signals:

\n') + file.write('
\n');
+				file.write(globalWriteSignals);
+				file.write('
\n') + file.write('
\n') if globalWrite != "": file.write('

Synopsis:

\n') file.write('
\n');
@@ -589,38 +619,38 @@ def generate_page(outFolder, header, footer, element, name_lib=""):
 
 
 
-def generate(myLutinDoc, outFolder) :
-	myDoc = myLutinDoc.get_base_doc_node()
+def generate(my_lutin_doc, outFolder) :
+	my_doc = my_lutin_doc.get_base_doc_node()
 	tools.copy_file(tools.get_current_path(__file__)+"/theme/base.css", outFolder+"/base.css")
 	tools.copy_file(tools.get_current_path(__file__)+"/theme/menu.css", outFolder+"/menu.css")
 	# create common header
-	genericHeader  = '\n'
-	genericHeader += '\n'
-	genericHeader += '\n'
-	genericHeader += '	\n'
-	genericHeader += '	' + myDoc.get_name() + ' Library\n'
-	genericHeader += '	\n'
-	genericHeader += '	\n'
-	genericHeader += '\n'
-	genericHeader += '\n'
-	genericHeader += '	\n"
 	googleData = tools.file_read_data("google-analytics.txt")
 	if googleData != "":
 		debug.info("insert Google analytics Data")
-		genericFooter += googleData
-	genericFooter += "\n"
-	genericFooter += "\n"
+		generic_footer += googleData
+	generic_footer += "\n"
+	generic_footer += "\n"
 	
-	# create index.hml : 
-	generate_stupid_index_page(outFolder, genericHeader, genericFooter, myLutinDoc)
+	# create index.hml:
+	generate_stupid_index_page(outFolder, generic_header, generic_footer, my_lutin_doc)
 	
-	# create the namespace index properties :
-	generate_page(outFolder, genericHeader, genericFooter, myDoc, name_lib=myLutinDoc.name )
+	# create the namespace index properties:
+	generate_page(outFolder, generic_header, generic_footer, my_doc, name_lib=my_lutin_doc.name)
 	
-	for iii in range(0, len(myLutinDoc.listTutorialFile)) :
-		docInputName,outpath = myLutinDoc.listTutorialFile[iii]
+	for iii in range(0, len(my_lutin_doc.list_tutorial_file)) :
+		docInputName,outpath = my_lutin_doc.list_tutorial_file[iii]
 		
-		debug.print_element("tutorial", myLutinDoc.name, "<==", docInputName)
-		outputFileName = outFolder + "/" + outpath.replace('/','_') +".html"
-		debug.debug("output file : " + outputFileName)
+		debug.print_element("tutorial", my_lutin_doc.name, "<==", docInputName)
+		if outpath[0] == '/':
+			outpath = outpath[1:]
+		outputFileName = os.path.join(outFolder, outpath.replace('/','_') + ".html")
+		debug.debug("output file : " + outputFileName + " out path=" + outFolder + " baseName=" + outpath)
 		tools.create_directory_of_file(outputFileName)
 		name = outputFileName.split('_')[-1][:-5]
 		inData = tools.file_read_data(docInputName)
 		if inData == "":
 			continue
-		outData = genericHeader
+		outData = generic_header
 		localHeader = ""
 		localHeader += "=?=" + camel_case_decode(name) + "=?=\n___________________________\n"
 		if iii != 0:
-			previousName, previousOutpath = myLutinDoc.listTutorialFile[iii-1]
+			previousName, previousOutpath = my_lutin_doc.list_tutorial_file[iii-1]
 			previousName = previousName.split('_')[-1][:-3]
 			previousOutpath = previousOutpath.split('/')[-1]
 			localHeader += "[left][tutorial[" + previousOutpath + " | Previous: " + capitalise_first_letter(camel_case_decode(previousName)) + "]][/left] "
-		if iii != len(myLutinDoc.listTutorialFile)-1:
-			nextName, nextOutpath = myLutinDoc.listTutorialFile[iii+1]
+		if iii != len(my_lutin_doc.list_tutorial_file)-1:
+			nextName, nextOutpath = my_lutin_doc.list_tutorial_file[iii+1]
 			nextName = nextName.split('_')[-1][:-3]
 			nextOutpath = nextOutpath.split('/')[-1]
 			localHeader += " [right][tutorial[" + nextOutpath + " | Next: " + capitalise_first_letter(camel_case_decode(nextName)) + "]][/right]"
@@ -724,18 +756,18 @@ def generate(myLutinDoc, outFolder) :
 		outData += codeBB.transcode(localHeader)
 		#debug.info(localHeader)
 		outData += codeBB.transcode(inData)
-		outData += genericFooter
+		outData += generic_footer
 		tools.file_write_data(outputFileName, outData)
 	
-	for docInputName,outpath in myLutinDoc.listDocFile :
-		debug.print_element("doc", myLutinDoc.name, "<==", docInputName)
+	for docInputName,outpath in my_lutin_doc.list_doc_file :
+		debug.print_element("doc", my_lutin_doc.name, "<==", docInputName)
 		outputFileName = outFolder + outpath + ".html"
 		debug.debug("output file : " + outputFileName)
 		tools.create_directory_of_file(outputFileName)
 		inData = tools.file_read_data(docInputName)
 		if inData == "":
 			continue
-		outData = genericHeader + codeBB.transcode(inData) + genericFooter
+		outData = generic_header + codeBB.transcode(inData) + generic_footer
 		tools.file_write_data(outputFileName, outData)
 
 
diff --git a/monkMethode.py b/monkMethode.py
index d6dccea..1c293b2 100644
--- a/monkMethode.py
+++ b/monkMethode.py
@@ -8,6 +8,7 @@ class Methode(Node.Node):
 	def __init__(self, stack=[], file="", lineNumber=0, documentation=[], className = ""):
 		name = ""
 		type = 'methode'
+		self.override = False
 		self.virtual = False
 		self.virtualPure = False
 		self.static = False
@@ -62,6 +63,9 @@ class Methode(Node.Node):
 		if stack[0] == 'inline':
 			self.inline = True
 			stack = stack[1:]
+		if stack[len(stack)-1] == 'override':
+			self.override = True
+			stack = stack[:len(stack)-1]
 		if stack[len(stack)-1] == 'noexcept':
 			self.noexcept = True
 			stack = stack[:len(stack)-1]
@@ -152,6 +156,9 @@ class Methode(Node.Node):
 		if self.noexcept == True:
 			ret += " noexcept"
 			retDecorated += " " + module.display_color("noexcept")
+		if self.override == True:
+			ret += " override"
+			retDecorated += " " + module.display_color("override")
 		return [ret, retDecorated]
 	
 	##
@@ -207,5 +214,11 @@ class Methode(Node.Node):
 	##
 	def get_param(self):
 		return self.variable
+	##
+	## @brief Get Override parameter
+	## @return The requested override parameter
+	##
+	def get_override(self):
+		return self.override
 
 
diff --git a/monkModule.py b/monkModule.py
index 94a9a50..8cf0ce7 100644
--- a/monkModule.py
+++ b/monkModule.py
@@ -28,8 +28,8 @@ class Module:
 		self.type='LIBRARY'
 		# Name of the module
 		self.name=moduleName
-		self.listDocFile = []
-		self.listTutorialFile = []
+		self.list_doc_file = []
+		self.list_tutorial_file = []
 		self.webSite = ""
 		self.webSource = ""
 		self.pathParsing = ""
@@ -138,6 +138,25 @@ class Module:
 					else:
 						self.add_file_doc(fileCompleteName, pathBase)
 	
+	##
+	## @brief Sort a list of n element containing a list of element (order with the first)
+	## @param[in] value List to order
+	## @return ordered list
+	##
+	def sort_list_first_elem(self, value):
+		# order the list:
+		order_elem = []
+		for elem in value:
+			order_elem.append(elem[0])
+		order_elem.sort()
+		out = []
+		for elem in order_elem:
+			for old_val in value:
+				if elem == old_val[0]:
+					out.append(old_val)
+					break;
+		return out
+	
 	##
 	## @brief Add a documentation file at the parsing system
 	## @param[in] filename File To add at the parsing element system.
@@ -147,13 +166,14 @@ class Module:
 	def add_file_doc(self, filename, outPath):
 		debug.debug("adding file in documantation : '" + filename + "'");
 		done = False
-		for iii in range(0,len(self.listDocFile)):
-			if self.listDocFile[iii][0] > filename:
-				self.listDocFile.insert(iii, [filename, outPath])
+		for iii in range(0,len(self.list_doc_file)):
+			if self.list_doc_file[iii][0] > filename:
+				self.list_doc_file.insert(iii, [filename, outPath])
 				done = True
 				break
 		if done == False:
-			self.listDocFile.append([filename, outPath])
+			self.list_doc_file.append([filename, outPath])
+		self.list_doc_file = self.sort_list_first_elem(self.list_doc_file)
 	
 	##
 	## @brief Add a documentation file at the parsing system
@@ -165,13 +185,15 @@ class Module:
 		count = int(filename.split('/')[-1].split('_')[0])
 		debug.debug("adding file in documantation : '" + filename + "'");
 		done = False
-		for iii in range(0,len(self.listTutorialFile)):
-			if self.listTutorialFile[iii][0] > filename:
-				self.listTutorialFile.insert(iii, [filename, outPath])
+		for iii in range(0,len(self.list_tutorial_file)):
+			if self.list_tutorial_file[iii][0] > filename:
+				self.list_tutorial_file.insert(iii, [filename, outPath])
 				done = True
 				break
 		if done == False:
-			self.listTutorialFile.append([filename, outPath])
+			self.list_tutorial_file.append([filename, outPath])
+		self.list_tutorial_file = self.sort_list_first_elem(self.list_tutorial_file)
+		
 	
 	##
 	## @brief Add a file at the parsing system
diff --git a/monkParse.py b/monkParse.py
index 89f3d60..b2b1c37 100644
--- a/monkParse.py
+++ b/monkParse.py
@@ -560,14 +560,15 @@ def is_a_function(stack) :
 	if     stack[len(stack)-2] == '=' \
 	   and stack[len(stack)-1] == '0':
 		stack = stack[:len(stack)-2]
-	#can end with 2 possibilities : ')', 'const' or ')'
-	if    stack[len(stack)-1] == ')' \
-	   or (     stack[len(stack)-2] == ')' \
-	        and stack[len(stack)-1] == 'const')\
-	   or (     stack[len(stack)-2] == ')' \
-	        and stack[len(stack)-1] == 'noexcept')\
-	   or (     stack[len(stack)-3] == ')' \
-	        and stack[len(stack)-2] == 'const' \
-	        and stack[len(stack)-1] == 'noexcept'):
+	# find ')' element :
+	id = len(stack)-1
+	while id >= 0:
+		if stack[id] == ')':
+			break;
+		id -= 1
+	if id >= 0:
+		for elem in stack[id+1:]:
+			if elem not in ['const', 'noexcept', 'override']:
+				return False
 		return True
 	return False
\ No newline at end of file