Compare commits

...

7 Commits
0.2.0 ... main

30 changed files with 1419 additions and 559 deletions

View File

@ -12,7 +12,8 @@ import codeHLshell
def transcode(type, value): def transcode(type, value):
if type == "c++": if type == "c++" \
or type == "cpp":
value = codeHLcpp.transcode(value) value = codeHLcpp.transcode(value)
elif type == "java": elif type == "java":
value = codeHLJava.transcode(value) value = codeHLJava.transcode(value)

View File

@ -16,8 +16,6 @@ listRegExp = [
'code-storage-keyword'], 'code-storage-keyword'],
[ r'(bool|BOOL|char(16_t|32_t)?|double|float|u?int(8|16|32|64|128)?(_t)?|long|short|signed|size_t|unsigned|void|(I|U)(8|16|32|64|128))', [ r'(bool|BOOL|char(16_t|32_t)?|double|float|u?int(8|16|32|64|128)?(_t)?|long|short|signed|size_t|unsigned|void|(I|U)(8|16|32|64|128))',
'code-type'], 'code-type'],
[ r'(((0(x|X)[0-9a-fA-F]*)|(\d+\.?\d*|\.\d+)((e|E)(\+|\-)?\d+)?)(L|l|UL|ul|u|U|F|f)?)',
'code-number'],
[ r'(m_[A-Za-z_0-9])', [ r'(m_[A-Za-z_0-9])',
'code-member'], 'code-member'],
[ r'(( |\t)_[A-Za-z_0-9]*)', [ r'(( |\t)_[A-Za-z_0-9]*)',
@ -37,7 +35,9 @@ listRegExp = [
[ r'(true|TRUE|false|FALSE)', [ r'(true|TRUE|false|FALSE)',
'<code-operator'], '<code-operator'],
[ r'((\w+::)+\w+)', [ r'((\w+::)+\w+)',
'code-class'] 'code-class'],
[ r'(((0(x|X)[0-9a-fA-F]*)|(\d+\.?\d*|\.\d+)((e|E)(\+|\-)?\d+)?)(L|l|UL|ul|u|U|F|f)?)',
'code-number']
] ]
def transcode(value): def transcode(value):

51
codeMarkDown/MD_Code.py Normal file
View File

@ -0,0 +1,51 @@
#!/usr/bin/python
import monkDebug as debug
import sys
import monkTools
import codeHL
import re
##
## @brief Transcode balise :
## [code language=cpp]
## int main(void) {
## return 0;
## }
## [/code]
## @param[in] value String to transform.
## @return Transformed string.
##
def transcode(value):
#value = re.sub(r'\[code(( |\t|\n|\r)+style=(.*))?\](.*?)\[/code\]',
"""
value = re.sub(r'```(( |\t|\n|\r){\.(.*?))?\}(.*?)\```',
replace_code, #r'<pre>\4</pre>',
value,
flags=re.DOTALL)
"""
value = re.sub(r'```(( |\t|\n|\r)*(\{\.(.*?)\}))?(.*?)\```',
replace_code, #r'<pre>\4</pre>',
value,
flags=re.DOTALL)
# TODO : remove the basic indentation of the element (to have a better display in the text tutorial ...
return value
def transcode_part2(value):
value = value.replace(":CODE:UNDER:SCORE:", "_")
value = value.replace(":CODE:STAR:", "*")
return value
def replace_code(match):
if match.group() == "":
return ""
#debug.info("plop: " + str(match.groups()))
#debug.info("code format: " + str(match.groups()[3]))
value = codeHL.transcode(match.groups()[3], match.groups()[4])
#value = value.replace("\n", "<br/>")
value = value.replace("_", ":CODE:UNDER:SCORE:")
value = value.replace("*", ":CODE:STAR:")
return '<pre>' + str(value) + '</pre>'

19
codeMarkDown/MD_Image.py Normal file
View File

@ -0,0 +1,19 @@
#!/usr/bin/python
import monkDebug as debug
import sys
import monkTools
import re
##
## @brief Transcode balise:
## [img w=125 h=45]dossier/image.jpg[/img]
## [img w=125 h=45]http://plop.com/dossier/image.png[/img]
## @param[in] value String to transform.
## @return Transformed string.
##
def transcode(value):
return value

View File

@ -0,0 +1,60 @@
#!/usr/bin/python
import monkDebug as debug
import sys
import monkTools
import re
##
## @brief Transcode
## commencez les lignes par:
## *
## *
##
## +
## +
##
## resultat:
##
## -
## -
## -
##
## commencez les lignes par:
## -
## -
##
## resultat:
##
## 1.
## 2.
## 3.
##
## @param[in] value String to transform.
## @return Transformed string.
##
def transcode(value):
value = re.sub(r'\n(( - )|( * )|( # ))',
r'\n:INDENT:[STAR]',
value)
p = re.compile('((\:INDENT\:(.*?)\n)*)',
flags=re.DOTALL)
value = p.sub(replace_wiki_identation,
value)
value = re.sub(r'\[STAR\](.*?)\n',
r'<li>\1</li>',
value,
flags=re.DOTALL)
return value
def replace_wiki_identation(match):
if match.group() == "":
return ""
#debug.verbose("plop: " + str(match.group()))
value = "<ul>"
value += re.sub(r':INDENT:',
r'',
match.group())
value += "</ul>"
return transcode(value)

84
codeMarkDown/MD_Link.py Normal file
View File

@ -0,0 +1,84 @@
#!/usr/bin/python
import monkDebug as debug
import sys
import monkTools
import re
##
## @brief Transcode:
## [http://votre_site.con] => http://votre_site.con
## [http://votre_site.con | text displayed] => text displayed
## [http://votre_site.con text displayed] => text displayed.
##
## @param[in] value String to transform.
## @return Transformed string.
##
def transcode(value):
# named link : [[http://plop.html | link name]]
value = re.sub(r'\[\[http://(.*?) \| (.*?)\]\]',
r'<a href="http://\1">\2</a>',
value)
# direct link : [[http://plop.html]]
value = re.sub(r'\[\[http://(.*?)\]\]',
r'<a href="http://\1">http://\1</a>',
value)
# direct lib link : [lib[libname]]
value = re.sub(r'\[lib\[(.*?) \| (.*?)\]\]',
r'<a href="../\1">\2</a>',
value)
value = re.sub(r'\[doc\[(.*?) \| (.*?)\]\]',
r'<a href="\1.html">\2</a>',
value)
value = re.sub(r'\[tutorial\[(.*?) \| (.*?)\]\]',
r'<a href="tutorial_\1.html">\2</a>',
value)
value = re.sub(r'\[(lib|class|methode)\[(.*?)\]\]',
replace_link_class,
value)
"""
p = re.compile('\[\[(.*?)(|(.*?))\]\])',
flags=re.DOTALL)
value = p.sub(replace_link,
value)
"""
return value
"""
def replace_link(match):
if match.group() == "":
return ""
#debug.verbose("plop: " + str(match.group()))
value = "<ul>"
value += re.sub(r':INDENT:',
r'',
match.group())
value += "</ul>"
return transcode(value)
"""
def replace_link_class(match):
if match.group() == "":
return ""
#debug.info("plop: " + str(match.group()))
if match.groups()[0] == 'class':
className = match.groups()[1]
value = re.sub(':', '_', className)
return '<a href="class_' + value + '.html">' + className + '</a>'
elif match.groups()[0] == 'lib':
return match.groups()[1]
elif match.groups()[0] == 'methode':
return match.groups()[1]
else:
return match.groups()[1]

View File

@ -0,0 +1,17 @@
#!/usr/bin/python
import monkDebug as debug
import sys
import monkTools
import re
##
## @brief Transcode thales specification ...
## @param[in] value String to transform.
## @return Transformed string.
##
def transcode(value):
return value

42
codeMarkDown/MD_Table.py Normal file
View File

@ -0,0 +1,42 @@
#!/usr/bin/python
import monkDebug as debug
import sys
import monkTools
import re
##
## @brief Transcode table:
## { | tableau_type_1
## | [b]colone 1[/b]
## ligne 1
## | colone 2 ligne 1
## |---
## | colone 1 ligne 1
## | colone 2 ligne 2
## |}
## Avec autant de ligne et de colone que vous voullez..
## Il est possible de faire des retour a la ligne dans une case du tableau...
## En bref sa tend a marcher comme sur un Wiki...
##
## result:
## +-------------------------------------+
## | colone 1 |
## +------------------+------------------+
## | ligne 1 | colone 2 ligne 1 |
## +------------------+------------------+
## | colone 1 ligne 1 | colone 2 ligne 2 |
## +------------------+------------------+
##
## TODO : Create simple table like :
## | colone 1 ||
## | ligne 1 | colone 2 ligne 1 |
## | colone 1 ligne 1 | colone 2 ligne 2|
## @param[in] value String to transform.
## @return Transformed string.
##
def transcode(value):
return value

49
codeMarkDown/MD_Text.py Normal file
View File

@ -0,0 +1,49 @@
#!/usr/bin/python
import monkDebug as debug
import sys
import monkTools
import re
##
## @brief Transcode .
## [b]texte ici[/b]
## [i]texte ici[/i]
## [u]texte ici[/u]
## [strike]texte ici[/strike]
## [color=olive]texte ici[/color]
## [color=#456FF33F]texte ici[/color]
## Left : [left]texte ici[/left]
## Center : [center]texte ici[/center]
## Right : [right]texte ici[/right]
## [size=22]sdfgsdfgsdgsfd[/size]
## [cadre]mettre les code ici[/cadre]
## @param[in] string String to transform.
## @return Transformed string.
##
def transcode(value):
value = re.sub(r'\*\*(.*?)\*\*',
r'<strong>\1</strong>',
value,
flags=re.DOTALL)
value = re.sub(r'__(.*?)__',
r'<strong>\1</strong>',
value,
flags=re.DOTALL)
value = re.sub(r'\*(.*?)\*',
r'<em>\1</em>',
value,
flags=re.DOTALL)
value = re.sub(r'_(.*?)_',
r'<em>\1</em>',
value,
flags=re.DOTALL)
value = re.sub(r'____(.*?)\n',
r'<hr>',
value,
flags=re.DOTALL)
return value

73
codeMarkDown/MD_Title.py Normal file
View File

@ -0,0 +1,73 @@
#!/usr/bin/python
import monkDebug as debug
import sys
import monkTools
import re
##
## @brief Transcode .
## =?=Page Title=?=
## ==Title 1==
## ===Title 2===
## ====Title 3====
## =====Title 4=====
## ======Title 5======
## @param[in] value String to transform.
## @return Transformed string.
##
def transcode(value):
value = "\n" + value
value = re.sub(r'@tableofcontents',
r'',
value)
value = re.sub(r'\n(.*?)(( |\t)*\{.*\})*\n====*',
r'\n<h1>\1</h1>',
value)
value = re.sub(r'\n(.*?)(( |\t)*\{.*\})*\n---*',
r'\n<h2>\1</h2>',
value)
value = re.sub(r'\n###### (.*?)(( |\t)*\{.*\})* ######',
r'\n<h6>\1</h6>',
value)
value = re.sub(r'\n###### (.*?)(( |\t)*\{.*\})*',
r'\n<h6>\1</h6>',
value)
value = re.sub(r'\n##### (.*?)(( |\t)*\{.*\})* #####',
r'\n<h5>\1</h5>',
value)
value = re.sub(r'\n##### (.*?)(( |\t)*\{.*\})*',
r'\n<h5>\1</h5>',
value)
value = re.sub(r'\n#### (.*?)(( |\t)*\{.*\})* ####',
r'\n<h4>\1</h4>',
value)
value = re.sub(r'\n#### (.*?)(( |\t)*\{.*\})*',
r'\n<h4>\1</h4>',
value)
value = re.sub(r'\n### (.*?)(( |\t)*\{.*\})* ###',
r'\n<h3>\1</h3>',
value)
value = re.sub(r'\n### (.*?)(( |\t)*\{.*\})*',
r'\n<h3>\1</h3>',
value)
value = re.sub(r'\n## (.*?)(( |\t)*\{.*\})* ##',
r'\n<h2>\1</h2>',
value)
value = re.sub(r'\n## (.*?)(( |\t)*\{.*\})*',
r'\n<h2>\1</h2>',
value)
value = value[1:]
return value

View File

@ -0,0 +1,23 @@
#!/usr/bin/python
import monkDebug as debug
import sys
import monkTools
import re
_comment_code = "[comment]:"
##
## @brief Transcode balise:
## line start with [comment]:
## @param[in] value String to transform.
## @return Transformed string.
##
def transcode(value):
out = "";
for elem in value.split("\n"):
if len(elem) >= len(_comment_code) \
and elem[:len(_comment_code)] == _comment_code:
continue
out += elem + "\n"
return out

View File

@ -0,0 +1,30 @@
#!/usr/bin/python
import monkDebug as debug
import sys
import monkTools
import re
##
## @brief Transcode balise:
## \n\n ==> <br/>
## @param[in] value String to transform.
## @return Transformed string.
##
def transcode(value):
value = re.sub(r'\r\n',
r'\n',
value)
value = re.sub(r'\n\n',
r'<br/>',
value)
value = re.sub(r'<br/>',
r'<br/>\n',
value)
return value

View File

@ -0,0 +1,61 @@
#!/usr/bin/python
import monkDebug as debug
import sys
import monkTools
import re
"""
import BB_Link
import BB_Image
import BB_Table
import BB_Specification
"""
import MD_Text
import MD_IndentAndDot
import MD_Title
import MD_comment
import MD_lineReturn
import MD_Code
##
## @brief Transcode input data in the corect format.
## @param[in] string String to transform.
## @return Transformed string.
##
def transcode(value):
# remove html property
value = re.sub(r'&', r'&amp;', value)
value = re.sub(r'<', r'&lt;', value)
value = re.sub(r'>', r'&gt;', value)
value = re.sub(r'\r\n', r'\n', value)
value = re.sub(r'\n\r', r'\n', value)
value = re.sub(r'\r', r'\n', value)
value = MD_comment.transcode(value)
value = MD_Title.transcode(value)
value = MD_IndentAndDot.transcode(value)
value = MD_Code.transcode(value)
value = MD_lineReturn.transcode(value)
value = MD_Text.transcode(value)
"""
value = BB_Text.transcode(value)
value = BB_Link.transcode(value)
value = BB_Image.transcode(value)
value = BB_Table.transcode(value)
value = BB_Specification.transcode(value)
"""
value = MD_Code.transcode_part2(value)
return value
##
## @brief transcode a BBcode file in a html file
## @return True if the file is transformed
##
def transcode_file(inputFileName, outputFileName):
inData = monkTools.file_read_data(inputFileName)
if inData == "":
return False
outData = transcode(inData)
debug.warning(" out: " + outputFileName)
monkTools.file_write_data(outputFileName, outData)
return True

16
monk.py
View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/python2.7
# for path inspection: # for path inspection:
import sys import sys
import os import os
@ -26,16 +26,16 @@ localArgument = myArg.parse()
def usage(): def usage():
# generic argument displayed : # generic argument displayed :
myArg.display() myArg.display()
print " all" print(" all")
print " Build all (only for the current selected board) (bynary and packages)" print(" Build all (only for the current selected board) (bynary and packages)")
print " clean" print(" clean")
print " Clean all (same as previous)" print(" Clean all (same as previous)")
listOfAllModule = monkModule.list_all_module_with_desc() listOfAllModule = monkModule.list_all_module_with_desc()
for mod in listOfAllModule: for mod in listOfAllModule:
print " " + mod[0] + " / " + mod[0] + "-clean" print(" " + mod[0] + " / " + mod[0] + "-clean")
if mod[1] != "": if mod[1] != "":
print " " + mod[1] print(" " + mod[1])
print " ex: " + sys.argv[0] + " all" print(" ex: " + sys.argv[0] + " all")
exit(0) exit(0)
## ##

View File

@ -4,22 +4,22 @@ import monkDebug as debug
class ArgElement: class ArgElement:
def __init__(self, option, value=""): def __init__(self, option, value=""):
self.m_option = option; self.option = option;
self.m_arg = value; self.arg = value;
def get_option_name(self): def get_option_name(self):
return self.m_option return self.option
def get_arg(self): def get_arg(self):
return self.m_arg return self.arg
def display(self): def display(self):
if len(self.m_arg)==0: if len(self.arg)==0:
debug.info("option : " + self.m_option) debug.info("option : " + self.option)
elif len(self.m_option)==0: elif len(self.option)==0:
debug.info("element : " + self.m_arg) debug.info("element : " + self.arg)
else: else:
debug.info("option : " + self.m_option + ":" + self.m_arg) debug.info("option : " + self.option + ":" + self.arg)
class ArgDefine: class ArgDefine:
@ -29,61 +29,61 @@ class ArgDefine:
list=[], # ["val", "description"] list=[], # ["val", "description"]
desc="", desc="",
haveParam=False): haveParam=False):
self.m_optionSmall = smallOption; self.option_small = smallOption;
self.m_optionBig = bigOption; self.option_big = bigOption;
self.m_list = list; self.list = list;
if len(self.m_list)!=0: if len(self.list)!=0:
self.m_haveParam = True self.have_param = True
else: else:
if True==haveParam: if True==haveParam:
self.m_haveParam = True self.have_param = True
else: else:
self.m_haveParam = False self.have_param = False
self.m_description = desc; self.description = desc;
def get_option_small(self): def get_option_small(self):
return self.m_optionSmall return self.option_small
def get_option_big(self): def get_option_big(self):
return self.m_optionBig return self.option_big
def need_parameters(self): def need_parameters(self):
return self.m_haveParam return self.have_param
def get_porperties(self): def get_porperties(self):
return "" return ""
def check_availlable(self, argument): def check_availlable(self, argument):
if len(self.m_list)==0: if len(self.list)==0:
return True return True
for element,desc in self.m_list: for element,desc in self.list:
if element == argument: if element == argument:
return True return True
return False return False
def display(self): def display(self):
if self.m_optionSmall != "" and self.m_optionBig != "": if self.option_small != "" and self.option_big != "":
print(" -" + self.m_optionSmall + " / --" + self.m_optionBig) print(" -" + self.option_small + " / --" + self.option_big)
elif self.m_optionSmall != "": elif self.option_small != "":
print(" -" + self.m_optionSmall) print(" -" + self.option_small)
elif self.m_optionSmall != "": elif self.option_small != "":
print(" --" + self.m_optionBig) print(" --" + self.option_big)
else: else:
print(" ???? ==> internal error ...") print(" ???? ==> internal error ...")
if self.m_description != "": if self.description != "":
print(" " + self.m_description) print(" " + self.description)
if len(self.m_list)!=0: if len(self.list)!=0:
hasDescriptiveElement=False hasDescriptiveElement=False
for val,desc in self.m_list: for val,desc in self.list:
if desc!="": if desc!="":
hasDescriptiveElement=True hasDescriptiveElement=True
break; break;
if hasDescriptiveElement==True: if hasDescriptiveElement==True:
for val,desc in self.m_list: for val,desc in self.list:
print(" " + val + " : " + desc) print(" " + val + " : " + desc)
else: else:
tmpElementPrint = "" tmpElementPrint = ""
for val,desc in self.m_list: for val,desc in self.list:
if len(tmpElementPrint)!=0: if len(tmpElementPrint)!=0:
tmpElementPrint += " / " tmpElementPrint += " / "
tmpElementPrint += val tmpElementPrint += val
@ -97,8 +97,8 @@ class ArgSection:
def __init__(self, def __init__(self,
sectionName="", sectionName="",
desc=""): desc=""):
self.m_section = sectionName; self.section = sectionName;
self.m_description = desc; self.description = desc;
def get_option_small(self): def get_option_small(self):
return "" return ""
@ -107,10 +107,10 @@ class ArgSection:
return "" return ""
def get_porperties(self): def get_porperties(self):
return " [" + self.m_section + "]" return " [" + self.section + "]"
def display(self): def display(self):
print(" [" + self.m_section + "] : " + self.m_description) print(" [" + self.section + "] : " + self.description)
def parse(self, argList, currentID): def parse(self, argList, currentID):
return currentID; return currentID;
@ -118,13 +118,13 @@ class ArgSection:
class MonkArg: class MonkArg:
def __init__(self): def __init__(self):
self.m_listProperties = [] self.list_properties = []
def add(self, argument): def add(self, argument):
self.m_listProperties.append(argument) #argDefine(smallOption, bigOption, haveParameter, parameterList, description)); self.list_properties.append(argument) #argDefine(smallOption, bigOption, haveParameter, parameterList, description));
def add_section(self, sectionName, sectionDesc): def add_section(self, sectionName, sectionDesc):
self.m_listProperties.append(ArgSection(sectionName, sectionDesc)) self.list_properties.append(ArgSection(sectionName, sectionDesc))
def parse(self): def parse(self):
listArgument = [] # composed of list element listArgument = [] # composed of list element
@ -147,7 +147,7 @@ class MonkArg:
argumentFound=False; argumentFound=False;
if option[:2]=="--": if option[:2]=="--":
# big argument # big argument
for prop in self.m_listProperties: for prop in self.list_properties:
if prop.get_option_big()=="": if prop.get_option_big()=="":
continue continue
if prop.get_option_big() == option[2:]: if prop.get_option_big() == option[2:]:
@ -189,7 +189,7 @@ class MonkArg:
debug.error("UNKNOW argument : '" + argument + "'") debug.error("UNKNOW argument : '" + argument + "'")
elif option[:1]=="-": elif option[:1]=="-":
# small argument # small argument
for prop in self.m_listProperties: for prop in self.list_properties:
if prop.get_option_small()=="": if prop.get_option_small()=="":
continue continue
if prop.get_option_small() == option[1:1+len(prop.get_option_small())]: if prop.get_option_small() == option[1:1+len(prop.get_option_small())]:
@ -241,10 +241,10 @@ class MonkArg:
def display(self): def display(self):
print "usage:" print("usage:")
listOfPropertiesArg = ""; listOfPropertiesArg = "";
for element in self.m_listProperties : for element in self.list_properties :
listOfPropertiesArg += element.get_porperties() listOfPropertiesArg += element.get_porperties()
print " " + sys.argv[0] + listOfPropertiesArg + " ..." print(" " + sys.argv[0] + listOfPropertiesArg + " ...")
for element in self.m_listProperties : for element in self.m_list_properties :
element.display() element.display()

View File

@ -60,11 +60,11 @@ class Class(Node.Node):
return return
Node.Node.__init__(self, 'class', stack[1], file, lineNumber, documentation) Node.Node.__init__(self, 'class', stack[1], file, lineNumber, documentation)
self.template = templateDeclatation self.template = templateDeclatation
self.subList = [] self.sub_list = []
self.access = "private" self.access = "private"
# heritage list : # heritage list :
self.templateType = None self.template_type = None
self.templateTypeStr = "" self.template_type_str = ""
self.inherit = [] self.inherit = []
if len(stack) == 2: if len(stack) == 2:
# just a simple class... # just a simple class...
@ -74,23 +74,23 @@ class Class(Node.Node):
# This is a template # This is a template
for iii in range(0, len(stack)): for iii in range(0, len(stack)):
if stack[iii] == '>': if stack[iii] == '>':
self.templateType = stack[2:iii] self.template_type = stack[2:iii]
stack = stack[:2] + stack[iii+1:] stack = stack[:2] + stack[iii+1:]
break; break;
# TODO : add tpe in rendering # TODO : add tpe in rendering
if self.templateType == None: if self.template_type == None:
debug.error("error in parsing class : " + str(stack) + " can not parse template property ...") debug.error("error in parsing class : " + str(stack) + " can not parse template property ...")
else: else:
copyTemplateType = self.templateType; copytemplate_type = self.template_type;
self.templateType = [] self.template_type = []
self.templateTypeStr = "<" self.template_type_str = "<"
for val in copyTemplateType: for val in copytemplate_type:
if val[0] == '<': if val[0] == '<':
val = val[1:] val = val[1:]
if val != '>': if val != '>':
self.templateType.append(val) self.template_type.append(val)
self.templateTypeStr += val + " " self.template_type_str += val + " "
self.templateTypeStr = ">" self.template_type_str = ">"
if len(stack) == 3: if len(stack) == 3:
debug.error("error in parsing class : " + str(stack)) debug.error("error in parsing class : " + str(stack))
return return
@ -123,7 +123,7 @@ class Class(Node.Node):
def to_str(self) : def to_str(self) :
ret = "class " + self.name ret = "class " + self.name
ret += self.templateTypeStr ret += self.template_type_str
if len(self.inherit) != 0 : if len(self.inherit) != 0 :
ret += " : " ret += " : "
isFirst = True isFirst = True
@ -155,8 +155,8 @@ class Class(Node.Node):
if parrentName == self.inherit[0]['class']: if parrentName == self.inherit[0]['class']:
ret.append(self.get_displayable_name()) ret.append(self.get_displayable_name())
# set for all sub elements ... # set for all sub elements ...
if self.subList != None: if self.sub_list != None:
for element in self.subList: for element in self.sub_list:
tmpRet = element['node'].get_whith_specific_parrent(parrentName) tmpRet = element['node'].get_whith_specific_parrent(parrentName)
if len(tmpRet) != 0: if len(tmpRet) != 0:
for tmp in tmpRet: for tmp in tmpRet:

View File

@ -4,28 +4,40 @@ import monkNode as Node
class Enum(Node.Node): class Enum(Node.Node):
def __init__(self, stack=[], file="", lineNumber=0, documentation=[]): def __init__(self, stack=[], file="", lineNumber=0, documentation=[]):
self.baseValue = 0; self.base_value = 0;
# check input : # check input :
if len(stack) < 1: if len(stack) < 1:
debug.error("Can not parse enum : " + str(stack)) debug.error("Can not parse enum : " + str(stack))
return return
self.typedef = False self.typedef = False
if stack[0] == 'typedef': if len(stack) > 0 \
and stack[0] == 'typedef':
self.typedef = True self.typedef = True
stack[1:] stack[1:]
if len(stack) == 0: if len(stack) > 0 \
and stack[0] == 'enum':
stack[1:]
else:
debug.error("Can not parse enum : " + str(stack)) debug.error("Can not parse enum : " + str(stack))
return return
if len(stack) == 1: self.is_class = False
localEnumName = "" if len(stack) > 0 \
else: and stack[0] == 'class':
self.is_class = True
stack[1:]
if len(stack) >= 1:
localEnumName = stack[1] localEnumName = stack[1]
else:
debug.error("Can not parse enum : " + str(stack))
return
Node.Node.__init__(self, 'enum', localEnumName, file, lineNumber, documentation) Node.Node.__init__(self, 'enum', localEnumName, file, lineNumber, documentation)
self.listElement = [] self.list_element = []
def to_str(self) : def to_str(self) :
if self.is_class == True:
return "enum class " + self.name + " { ... };"
return "enum " + self.name + " { ... };" return "enum " + self.name + " { ... };"
def enum_append(self, stack): def enum_append(self, stack):
@ -60,23 +72,23 @@ class Enum(Node.Node):
for tmp in element[2:]: for tmp in element[2:]:
value = tmp value = tmp
if value == "": if value == "":
if self.baseValue == None: if self.base_value == None:
value = "???" value = "???"
else: else:
value = str(self.baseValue) value = str(self.base_value)
self.baseValue += 1 self.base_value += 1
else: else:
try: try:
tmpVal = int(value) tmpVal = int(value)
self.baseValue = tmpVal + 1 self.base_value = tmpVal + 1
except: except:
debug.debug("can not parse enum value : '" + value + "'") debug.debug("can not parse enum value : '" + value + "'")
self.baseValue = None self.base_value = None
self.listElement.append({'name' : element[0], 'value' : value, 'doc' : comments}) self.list_element.append({'name' : element[0], 'value' : value, 'doc' : comments})
debug.verbose("enum list : " + str(self.listElement)) debug.verbose("enum list : " + str(self.list_element))
def get_enum_list(self): def get_enum_list(self):
return self.listElement return self.list_element

View File

@ -3,8 +3,10 @@ import monkDebug as debug
import sys import sys
import monkTools as tools import monkTools as tools
#import CppHeaderParser #import CppHeaderParser
import os
import re import re
import codeBB import codeBB
import codeMarkDown
import collections import collections
import monkModule as module import monkModule as module
import monkNode as node import monkNode as node
@ -203,6 +205,7 @@ def calculate_methode_size(list):
methodeSize = 0; methodeSize = 0;
haveVirtual = False haveVirtual = False
for element in list: for element in list:
debug.info("node type = " + element['node'].get_node_type())
if element['node'].get_node_type() == 'methode' \ if element['node'].get_node_type() == 'methode' \
or element['node'].get_node_type() == 'constructor' \ or element['node'].get_node_type() == 'constructor' \
or element['node'].get_node_type() == 'destructor': or element['node'].get_node_type() == 'destructor':
@ -210,6 +213,8 @@ def calculate_methode_size(list):
haveVirtual = True haveVirtual = True
if element['node'].get_node_type() == 'variable': if element['node'].get_node_type() == 'variable':
retType = element['node'].get_type().to_str() retType = element['node'].get_type().to_str()
elif element['node'].get_node_type() == 'using':
retType = ""
else: else:
retType = element['node'].get_return_type().to_str() retType = element['node'].get_return_type().to_str()
tmpLen = len(retType) tmpLen = len(retType)
@ -240,7 +245,11 @@ def write_methode(element, namespaceStack, displaySize = None, link = True):
else: else:
ret += ' ' ret += ' '
if element['node'].get_node_type() == 'variable': if element['node'].get_node_type() in ['variable']:
if displaySize[2] == True:
ret += ' '
raw, decorated = element['node'].get_type().to_str_decorated()
elif element['node'].get_node_type() in ['using']:
if displaySize[2] == True: if displaySize[2] == True:
ret += ' ' ret += ' '
raw, decorated = element['node'].get_type().to_str_decorated() raw, decorated = element['node'].get_type().to_str_decorated()
@ -269,7 +278,7 @@ def write_methode(element, namespaceStack, displaySize = None, link = True):
else: else:
ret += '<span class="' + classDecoration + '">' + name + '</span>' ret += '<span class="' + classDecoration + '">' + name + '</span>'
if element['node'].get_node_type() != 'variable': if element['node'].get_node_type() not in ['variable', 'using']:
ret += white_space(displaySize[1] - len(name)) + ' (' ret += white_space(displaySize[1] - len(name)) + ' ('
listParam = element['node'].get_param() listParam = element['node'].get_param()
first = True first = True
@ -288,22 +297,26 @@ def write_methode(element, namespaceStack, displaySize = None, link = True):
ret += " " ret += " "
ret += "<span class=\"code-argument\">" + param.get_name() + "</span>" ret += "<span class=\"code-argument\">" + param.get_name() + "</span>"
ret += ')' ret += ')'
if element['node'].get_virtual_pure() == True:
ret += ' = 0'
if element['node'].get_constant() == True: if element['node'].get_constant() == True:
ret += module.display_color(' const') ret += module.display_color(' const')
if element['node'].get_override() == True:
ret += module.display_color(' override')
if element['node'].get_virtual_pure() == True:
ret += ' = 0'
if element['node'].get_delete() == True:
ret += ' = delete'
ret += ';' ret += ';'
ret += '<br/>' ret += '<br/>'
return 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 : # create index.hml :
filename = outFolder + "/index.html" filename = outFolder + "/index.html"
tools.create_directory_of_file(filename); tools.create_directory_of_file(filename);
file = open(filename, "w") file = open(filename, "w")
file.write(header) file.write(header)
file.write("<h1>" + myLutinDoc.get_base_doc_node().get_name() + "</h1>"); file.write("<h1>" + my_lutin_doc.get_base_doc_node().get_name() + "</h1>");
file.write("<br/>"); file.write("<br/>");
file.write("TODO : Main page ..."); file.write("TODO : Main page ...");
file.write("<br/>"); file.write("<br/>");
@ -315,8 +328,8 @@ def generate_page(outFolder, header, footer, element, name_lib=""):
debug.print_element("code-doc", name_lib, "<==", element.name) debug.print_element("code-doc", name_lib, "<==", element.name)
currentPageSite = element.get_doc_website_page() currentPageSite = element.get_doc_website_page()
namespaceStack = element.get_namespace() namespaceStack = element.get_namespace()
if element.get_node_type() in ['library', 'application', 'namespace', 'class', 'struct', 'enum', 'union']: if element.get_node_type() in ['library', 'application', 'namespace', 'class', 'struct', 'enum', 'union', 'using']:
listBase = element.get_all_sub_type(['library', 'application', 'namespace', 'class', 'struct', 'enum', 'union']) listBase = element.get_all_sub_type(['library', 'application', 'namespace', 'class', 'struct', 'enum', 'union', 'using'])
for elem in listBase: for elem in listBase:
generate_page(outFolder, header, footer, elem['node'], name_lib) generate_page(outFolder, header, footer, elem['node'], name_lib)
filename = outFolder + '/' + generate_html_page_name(element) filename = outFolder + '/' + generate_html_page_name(element)
@ -363,7 +376,7 @@ def generate_page(outFolder, header, footer, element, name_lib=""):
file.write('</ul>\n'); file.write('</ul>\n');
if element.get_node_type() in ['library', 'application', 'namespace', 'class', 'struct']: if element.get_node_type() in ['library', 'application', 'namespace', 'class', 'struct']:
for nameElement in ['namespace', 'class', 'struct', 'enum', 'union']: for nameElement in ['namespace', 'class', 'struct', 'enum', 'union', 'using']:
listBase = element.get_all_sub_type(nameElement) listBase = element.get_all_sub_type(nameElement)
if len(listBase) == 0: if len(listBase) == 0:
continue continue
@ -382,12 +395,11 @@ def generate_page(outFolder, header, footer, element, name_lib=""):
file.write('</ul>\n'); file.write('</ul>\n');
# calculate element size : # calculate element size :
listBase = element.get_all_sub_type(['methode', 'constructor', 'destructor', 'variable']) listBase = element.get_all_sub_type(['methode', 'constructor', 'destructor', 'variable', 'using'])
displayLen = calculate_methode_size(listBase) displayLen = calculate_methode_size(listBase)
if element.get_node_type() == 'class' \ if element.get_node_type() == 'class' \
or element.get_node_type() == 'struct': or element.get_node_type() == 'struct':
if len(element.get_all_sub_type(['constructor', 'destructor'])) != 0: if len(element.get_all_sub_type(['constructor', 'destructor'])) != 0:
globalWrite = "" globalWrite = ""
listBaseConstructor = element.get_all_sub_type(['constructor']) listBaseConstructor = element.get_all_sub_type(['constructor'])
@ -408,15 +420,42 @@ def generate_page(outFolder, header, footer, element, name_lib=""):
file.write('<br/>\n') file.write('<br/>\n')
if element.get_node_type() in ['library', 'application', 'namespace', 'class', 'struct']: if element.get_node_type() in ['library', 'application', 'namespace', 'class', 'struct']:
listBaseMethode = element.get_all_sub_type(['methode', 'variable']) listBaseMethode = element.get_all_sub_type(['methode', 'variable', 'using'])
if len(listBaseMethode) != 0: if len(listBaseMethode) != 0:
globalWrite = "" globalWrite = ""
globalWriteProperties = ""
globalWriteSignals = ""
displayLen = calculate_methode_size(listBaseMethode) displayLen = calculate_methode_size(listBaseMethode)
for elem in listBaseMethode: for elem in listBaseMethode:
if 'access' in elem.keys() \ if 'access' in elem.keys() \
and elem['access'] == 'private': and elem['access'] == 'private':
continue 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('<h2>Properties:</h2>\n')
file.write('<pre>\n');
file.write(globalWriteProperties);
file.write('</pre>\n')
file.write('<br/>\n')
if globalWriteSignals != "":
file.write('<h2>Signals:</h2>\n')
file.write('<pre>\n');
file.write(globalWriteSignals);
file.write('</pre>\n')
file.write('<br/>\n')
if globalWrite != "": if globalWrite != "":
file.write('<h2>Synopsis:</h2>\n') file.write('<h2>Synopsis:</h2>\n')
file.write('<pre>\n'); file.write('<pre>\n');
@ -589,38 +628,38 @@ def generate_page(outFolder, header, footer, element, name_lib=""):
def generate(myLutinDoc, outFolder) : def generate(my_lutin_doc, outFolder) :
myDoc = myLutinDoc.get_base_doc_node() 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/base.css", outFolder+"/base.css")
tools.copy_file(tools.get_current_path(__file__)+"/theme/menu.css", outFolder+"/menu.css") tools.copy_file(tools.get_current_path(__file__)+"/theme/menu.css", outFolder+"/menu.css")
# create common header # create common header
genericHeader = '<!DOCTYPE html>\n' generic_header = '<!DOCTYPE html>\n'
genericHeader += '<html>\n' generic_header += '<html>\n'
genericHeader += '<head>\n' generic_header += '<head>\n'
genericHeader += ' <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">\n' generic_header += ' <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">\n'
genericHeader += ' <title>' + myDoc.get_name() + ' Library</title>\n' generic_header += ' <title>' + my_doc.get_name() + ' Library</title>\n'
genericHeader += ' <link rel="stylesheet" href="base.css">\n' generic_header += ' <link rel="stylesheet" href="base.css">\n'
genericHeader += ' <link rel="stylesheet" href="menu.css">\n' generic_header += ' <link rel="stylesheet" href="menu.css">\n'
genericHeader += '</head>\n' generic_header += '</head>\n'
genericHeader += '<body>\n' generic_header += '<body>\n'
genericHeader += ' <div class="navbar navbar-fixed-top">\n' generic_header += ' <div class="navbar navbar-fixed-top">\n'
genericHeader += ' <div class="container">\n' generic_header += ' <div class="container">\n'
if myDoc.get_node_type() == 'library': if my_doc.get_node_type() == 'library':
genericHeader += ' <h1><a href="index.html">' + myDoc.get_name() + ' library</a></h1>\n' generic_header += ' <h1><a href="index.html">' + my_doc.get_name() + ' library</a></h1>\n'
else: else:
genericHeader += ' <h1><a href="index.html">' + myDoc.get_name() + '</a></h1>\n' generic_header += ' <h1><a href="index.html">' + my_doc.get_name() + '</a></h1>\n'
if myLutinDoc.get_website_sources() != '': if my_lutin_doc.get_website_sources() != '':
genericHeader += ' <h4><a href="' + myLutinDoc.get_website_sources() + '">&nbsp;&nbsp;&nbsp;[ sources ]</a></h4>\n' generic_header += ' <h4><a href="' + my_lutin_doc.get_website_sources() + '">&nbsp;&nbsp;&nbsp;[ sources ]</a></h4>\n'
genericHeader += '<h3>API:</h3>' generic_header += '<h3>API:</h3>'
genericHeader += ' <div id="menu">\n' generic_header += ' <div id="menu">\n'
#genericHeader += ' <h2>' + myDoc.moduleName + '</h2>\n' #generic_header += ' <h2>' + my_doc.moduleName + '</h2>\n'
genericHeader += generate_menu(myDoc) generic_header += generate_menu(my_doc)
#genericHeader += ' <h3> </h3>\n' #generic_header += ' <h3> </h3>\n'
genericHeader += ' </div>\n' generic_header += ' </div>\n'
# TODO : add Generic doc main point. # TODO : add Generic doc main point.
if len(myLutinDoc.listDocFile) > 0: if len(my_lutin_doc.list_doc_file) > 0:
docList = "" docList = ""
for docInputName,outpath in myLutinDoc.listDocFile: for docInputName,outpath in my_lutin_doc.list_doc_file:
outputFileName = outFolder + "/" + outpath.replace('/','_') +".html" outputFileName = outFolder + "/" + outpath.replace('/','_') +".html"
outputFileName = outputFileName.split('/')[-1] outputFileName = outputFileName.split('/')[-1]
name = outputFileName.split('_')[-1][:-5] name = outputFileName.split('_')[-1][:-5]
@ -630,14 +669,14 @@ def generate(myLutinDoc, outFolder) :
docList += '<li><a href="' + outputFileName + '">' + capitalise_first_letter(camel_case_decode(name)) + '</a></li>\n' docList += '<li><a href="' + outputFileName + '">' + capitalise_first_letter(camel_case_decode(name)) + '</a></li>\n'
docList += '</ul>' docList += '</ul>'
if docList != "": if docList != "":
genericHeader += '<h3>Documentation:</h3>' generic_header += '<h3>Documentation:</h3>'
genericHeader += '<div id="menu">\n' generic_header += '<div id="menu">\n'
genericHeader += docList generic_header += docList
genericHeader += '</div>\n' generic_header += '</div>\n'
# TODO : add Tutorial doc main point. # TODO : add Tutorial doc main point.
if len(myLutinDoc.listTutorialFile) > 0: if len(my_lutin_doc.list_tutorial_file) > 0:
tutorialList = "" tutorialList = ""
for docInputName,outpath in myLutinDoc.listTutorialFile: for docInputName,outpath in my_lutin_doc.list_tutorial_file:
outputFileName = outFolder + "/" + outpath+".html" outputFileName = outFolder + "/" + outpath+".html"
outputFileName = outputFileName.split('/')[-1] outputFileName = outputFileName.split('/')[-1]
name = outputFileName.split('_')[-1][:-5] name = outputFileName.split('_')[-1][:-5]
@ -647,95 +686,107 @@ def generate(myLutinDoc, outFolder) :
tutorialList += '<li><a href="tutorial_' + outputFileName + '">' + capitalise_first_letter(camel_case_decode(name)) + '</a></li>\n' tutorialList += '<li><a href="tutorial_' + outputFileName + '">' + capitalise_first_letter(camel_case_decode(name)) + '</a></li>\n'
tutorialList += '</ul>' tutorialList += '</ul>'
if tutorialList != "": if tutorialList != "":
genericHeader += '<h3>Tutorials:</h3>' generic_header += '<h3>Tutorials:</h3>'
genericHeader += '<div id="menu">\n' generic_header += '<div id="menu">\n'
genericHeader += tutorialList generic_header += tutorialList
genericHeader += '</div>\n' generic_header += '</div>\n'
localWebsite = myLutinDoc.get_website() localWebsite = my_lutin_doc.get_website()
# add other libs entry point : # add other libs entry point :
allModule = module.get_all_module() allModule = module.get_all_module()
if len(allModule) != 1: if len(allModule) != 1:
genericHeader += '<br/>' generic_header += '<br/>'
genericHeader += '<h3>Associate libraries:</h3>' generic_header += '<h3>Associate libraries:</h3>'
genericHeader += '<div id="menu">\n' generic_header += '<div id="menu">\n'
for modd in allModule: for modd in allModule:
if modd.type == 'application': if modd.type == 'application':
continue continue
if modd.name == myLutinDoc.name: if modd.name == my_lutin_doc.name:
continue continue
genericHeader += '<ul class="niveau1">' generic_header += '<ul class="niveau1">'
link = node.get_doc_website_page_relative(localWebsite, modd.get_website()) link = node.get_doc_website_page_relative(localWebsite, modd.get_website())
if link[-1] != "/": debug.debug("link = " + str(link) + " << " + localWebsite + " !! " + str(modd.get_website()))
if len(link) != 0 \
and link[-1] != "/":
link += "/" link += "/"
genericHeader += '<li><a href="' + link + 'index.html">' + modd.name + '</a></li>\n' generic_header += '<li><a href="' + link + 'index.html">' + modd.name + '</a></li>\n'
genericHeader += '</ul>' generic_header += '</ul>'
genericHeader += '</div>\n' generic_header += '</div>\n'
genericHeader += "<br/>\n" generic_header += "<br/>\n"
genericHeader += "<br/>\n" generic_header += "<br/>\n"
genericHeader += "<br/>\n" generic_header += "<br/>\n"
genericHeader += "<br/>\n" generic_header += "<br/>\n"
genericHeader += "<br/>\n" generic_header += "<br/>\n"
genericHeader += "<br/>\n" generic_header += "<br/>\n"
genericHeader += " </div>\n" generic_header += " </div>\n"
genericHeader += " </div>\n" generic_header += " </div>\n"
genericHeader += " <div class=\"container\" id=\"content\">\n" generic_header += " <div class=\"container\" id=\"content\">\n"
genericFooter = " </div>\n" generic_footer = " </div>\n"
googleData = tools.file_read_data("google-analytics.txt") googleData = tools.file_read_data("google-analytics.txt")
if googleData != "": if googleData != "":
debug.info("insert Google analytics Data") debug.info("insert Google analytics Data")
genericFooter += googleData generic_footer += googleData
genericFooter += "</body>\n" generic_footer += "</body>\n"
genericFooter += "</html>\n" generic_footer += "</html>\n"
# create index.hml : # create index.hml:
generate_stupid_index_page(outFolder, genericHeader, genericFooter, myLutinDoc) generate_stupid_index_page(outFolder, generic_header, generic_footer, my_lutin_doc)
# create the namespace index properties : # create the namespace index properties:
generate_page(outFolder, genericHeader, genericFooter, myDoc, name_lib=myLutinDoc.name ) generate_page(outFolder, generic_header, generic_footer, my_doc, name_lib=my_lutin_doc.name)
for iii in range(0, len(myLutinDoc.listTutorialFile)) : for iii in range(0, len(my_lutin_doc.list_tutorial_file)) :
docInputName,outpath = myLutinDoc.listTutorialFile[iii] docInputName,outpath = my_lutin_doc.list_tutorial_file[iii]
debug.print_element("tutorial", myLutinDoc.name, "<==", docInputName) debug.print_element("tutorial", my_lutin_doc.name, "<==", docInputName)
outputFileName = outFolder + "/" + outpath.replace('/','_') +".html" if outpath[0] == '/':
debug.debug("output file : " + outputFileName) 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) tools.create_directory_of_file(outputFileName)
name = outputFileName.split('_')[-1][:-5] name = outputFileName.split('_')[-1][:-5]
inData = tools.file_read_data(docInputName) inData = tools.file_read_data(docInputName)
if inData == "": if inData == "":
continue continue
outData = genericHeader outData = generic_header
localHeader = "" localHeader = ""
localHeader += "=?=" + camel_case_decode(name) + "=?=\n___________________________\n" localHeader += "=?=" + camel_case_decode(name) + "=?=\n___________________________\n"
if iii != 0: if iii != 0:
previousName, previousOutpath = myLutinDoc.listTutorialFile[iii-1] previousName, previousOutpath = my_lutin_doc.list_tutorial_file[iii-1]
previousName = previousName.split('_')[-1][:-3] previousName = previousName.split('_')[-1][:-3]
previousOutpath = previousOutpath.split('/')[-1] previousOutpath = previousOutpath.split('/')[-1]
localHeader += "[left][tutorial[" + previousOutpath + " | Previous: " + capitalise_first_letter(camel_case_decode(previousName)) + "]][/left] " localHeader += "[left][tutorial[" + previousOutpath + " | Previous: " + capitalise_first_letter(camel_case_decode(previousName)) + "]][/left] "
if iii != len(myLutinDoc.listTutorialFile)-1: if iii != len(my_lutin_doc.list_tutorial_file)-1:
nextName, nextOutpath = myLutinDoc.listTutorialFile[iii+1] nextName, nextOutpath = my_lutin_doc.list_tutorial_file[iii+1]
nextName = nextName.split('_')[-1][:-3] nextName = nextName.split('_')[-1][:-3]
nextOutpath = nextOutpath.split('/')[-1] nextOutpath = nextOutpath.split('/')[-1]
localHeader += " [right][tutorial[" + nextOutpath + " | Next: " + capitalise_first_letter(camel_case_decode(nextName)) + "]][/right]" localHeader += " [right][tutorial[" + nextOutpath + " | Next: " + capitalise_first_letter(camel_case_decode(nextName)) + "]][/right]"
localHeader += "\n" localHeader += "\n"
outData += codeBB.transcode(localHeader) outData += codeBB.transcode(localHeader)
#debug.info(localHeader) #debug.info(localHeader)
outData += codeBB.transcode(inData) if docInputName[-2:] == "bb":
outData += codeBB.transcode(inData)
elif docInputName[-2:] == "md":
outData += codeMarkDown.transcode(inData)
outData += genericFooter outData += genericFooter
tools.file_write_data(outputFileName, outData) tools.file_write_data(outputFileName, outData)
for docInputName,outpath in myLutinDoc.listDocFile : for docInputName,outpath in my_lutin_doc.list_doc_file :
debug.print_element("doc", myLutinDoc.name, "<==", docInputName) debug.print_element("doc", my_lutin_doc.name, "<==", docInputName)
outputFileName = outFolder + outpath + ".html" outputFileName = outFolder + outpath + ".html"
debug.debug("output file : " + outputFileName) debug.debug("output file : " + outputFileName)
tools.create_directory_of_file(outputFileName) tools.create_directory_of_file(outputFileName)
inData = tools.file_read_data(docInputName) inData = tools.file_read_data(docInputName)
if inData == "": if inData == "":
continue continue
outData = genericHeader + codeBB.transcode(inData) + genericFooter outData = generic_header
if docInputName[-2:] == "bb":
outData += codeBB.transcode(inData)
elif docInputName[-2:] == "md":
outData += codeMarkDown.transcode(inData)
outData += generic_footer
tools.file_write_data(outputFileName, outData) tools.file_write_data(outputFileName, outData)

View File

@ -8,12 +8,15 @@ class Methode(Node.Node):
def __init__(self, stack=[], file="", lineNumber=0, documentation=[], className = ""): def __init__(self, stack=[], file="", lineNumber=0, documentation=[], className = ""):
name = "" name = ""
type = 'methode' type = 'methode'
self.override = False
self.virtual = False self.virtual = False
self.virtualPure = False self.virtual_pure = False
self.static = False self.static = False
self.inline = False self.inline = False
self.const = False # the end of line cont methode is sont for the class ... self.const = False # the end of line cont methode is sont for the class ...
self.noexcept = False self.noexcept = False
self.override = False
self.delete = False
# remove constructer inside declaration ... # remove constructer inside declaration ...
if ':' in stack: if ':' in stack:
@ -25,8 +28,9 @@ class Methode(Node.Node):
break break
stack = res stack = res
#check if it is a template class: #check if it is a template methode:
if stack[0] == "template": # note: A methode template can contain multiple methode handle ...
while stack[0] == "template":
debug.debug("find a template methode: " + str(stack)) debug.debug("find a template methode: " + str(stack))
#remove template properties ==> not manage for now ... #remove template properties ==> not manage for now ...
newStack = [] newStack = []
@ -51,35 +55,58 @@ class Methode(Node.Node):
if stack[len(stack)-2] == '=' \ if stack[len(stack)-2] == '=' \
and stack[len(stack)-1] == '0': and stack[len(stack)-1] == '0':
stack = stack[:len(stack)-2] stack = stack[:len(stack)-2]
self.virtualPure = True self.virtual_pure = True
if stack[0] == 'virtual': if stack[len(stack)-2] == '=' \
self.virtual = True and stack[len(stack)-1] == 'delete':
stack = stack[1:] stack = stack[:len(stack)-2]
if stack[0] == 'static': self.delete = True
self.static = True
stack = stack[1:]
if stack[0] == 'inline':
self.inline = True
stack = stack[1:]
if stack[len(stack)-1] == 'noexcept':
self.noexcept = True
stack = stack[:len(stack)-1]
if stack[len(stack)-1] == 'const':
self.const = True
stack = stack[:len(stack)-1]
namePos = -1 while len(stack) > 0\
and ( stack[0] == 'virtual'\
or stack[0] == 'static'\
or stack[0] == 'inline')::
if stack[0] == 'virtual':
self.virtual = True
stack = stack[1:]
if stack[0] == 'static':
self.static = True
stack = stack[1:]
if stack[0] == 'inline':
self.inline = True
stack = stack[1:]
while stack[-1] in ['override', 'noexcept', 'const']:
if stack[-1] == 'override':
self.override = True
stack = stack[:-1]
if stack[-1] == 'noexcept':
self.noexcept = True
stack = stack[:-1]
if stack[-1] == 'const':
self.const = True
stack = stack[:-1]
debug.debug("methode parse : " + str(stack)) debug.debug("methode parse : " + str(stack))
for iii in range(0, len(stack)-2): namePos = -1
if stack[iii+1] == '(': # form start to '(' char we will concatenate the name of the function wit template attributes
name = stack[iii] # ex: ['esignal', '::', 'Signal', '<', 'T_ARGS', '>', '::', 'Signal', '(', 'CLASS_TYPE', '*', '_class', ',', 'FUNC_TYPE', '_func', ')']
# ==> ['esignal::Signal<T_ARGS>::Signal', '(', 'CLASS_TYPE', '*', '_class', ',', 'FUNC_TYPE', '_func', ')']
# find pos of '(':
namePos = len(stack)
namePosStart = 0
for iii in range(0, len(stack)):
if stack[iii] == '(':
namePos = iii namePos = iii
break; break;
if iii != 0 \
if namePos == 0: and not ( stack[iii-1] in ["::", "<", ">", ","]
debug.debug("start with '" + str(name[0]) + "'") or stack[iii] in ["::", "<", ">", ","]) :
namePosStart = iii
if namePos == len(stack):
debug.error(" can not parse function name :" + str(stack))
name = "".join(stack[namePosStart: namePos])
if namePosStart == 0:
debug.verbose("start with '" + str(name[0]) + "'")
if name[0] == '~': if name[0] == '~':
if className == name[1:]: if className == name[1:]:
type = 'destructor' type = 'destructor'
@ -89,15 +116,15 @@ class Methode(Node.Node):
debug.debug("methode name : " + name) debug.debug("methode name : " + name)
Node.Node.__init__(self, type, name, file, lineNumber, documentation) Node.Node.__init__(self, type, name, file, lineNumber, documentation)
self.returnType = Type.TypeNone() self.return_type = Type.TypeNone()
self.variable = [] self.variable = []
# create the return Type (Can be Empty) # create the return Type (Can be Empty)
retTypeStack = stack[:namePos] retTypeStack = stack[:namePosStart]
debug.debug("return : " + str(retTypeStack)) debug.debug("return : " + str(retTypeStack))
self.returnType = Type.Type(retTypeStack) self.return_type = Type.Type(retTypeStack)
parameterStack = stack[namePos+2:len(stack)-1] parameterStack = stack[namePos+1:len(stack)-1]
debug.debug("parameter : " + str(parameterStack)) debug.debug("parameter : " + str(parameterStack))
paramTmp = [] paramTmp = []
braceOpen = 0 braceOpen = 0
@ -106,16 +133,16 @@ class Methode(Node.Node):
if element == ',': if element == ',':
self.variable.append(Variable.Variable(paramTmp)) self.variable.append(Variable.Variable(paramTmp))
paramTmp = [] paramTmp = []
elif element == '(': elif element in ['(', '<']:
paramTmp.append(element) paramTmp.append(element)
braceOpen += 1 braceOpen += 1
else: else:
paramTmp.append(element) paramTmp.append(element)
else: else:
paramTmp.append(element) paramTmp.append(element)
if element == '(': if element in ['(', '<']:
braceOpen += 1 braceOpen += 1
elif element == ')': elif element in [')', '>']:
braceOpen -= 1 braceOpen -= 1
if len(paramTmp) != 0: if len(paramTmp) != 0:
self.variable.append(Variable.Variable(paramTmp)) self.variable.append(Variable.Variable(paramTmp))
@ -135,7 +162,7 @@ class Methode(Node.Node):
if self.inline == True: if self.inline == True:
ret += "inline " ret += "inline "
retDecorated += module.display_color("inline") + " " retDecorated += module.display_color("inline") + " "
raw, decorated = self.returnType.to_str_decorated() raw, decorated = self.return_type.to_str_decorated()
ret += raw ret += raw
retDecorated += decorated retDecorated += decorated
ret += " " ret += " "
@ -143,7 +170,7 @@ class Methode(Node.Node):
ret += "(" ret += "("
# ... # ...
ret += ")" ret += ")"
if self.virtualPure == True: if self.virtual_pure == True:
ret += " = 0" ret += " = 0"
retDecorated += " = 0" retDecorated += " = 0"
if self.const == True: if self.const == True:
@ -152,6 +179,12 @@ class Methode(Node.Node):
if self.noexcept == True: if self.noexcept == True:
ret += " noexcept" ret += " noexcept"
retDecorated += " " + module.display_color("noexcept") retDecorated += " " + module.display_color("noexcept")
if self.override == True:
ret += " override"
retDecorated += " " + module.display_color("override")
if self.delete == True:
ret += " = delete"
retDecorated += " = " + module.display_color("delete")
return [ret, retDecorated] return [ret, retDecorated]
## ##
@ -169,7 +202,14 @@ class Methode(Node.Node):
## @note Availlable only if the virtual is active ## @note Availlable only if the virtual is active
## ##
def get_virtual_pure(self): def get_virtual_pure(self):
return self.virtualPure return self.virtual_pure
##
## @brief Get the status of the delete function ( virtual XXX(...) = delete;)
## @return True if =delete is present, False otherwise
##
def get_delete(self):
return self.delete
## ##
## @brief Get the status of the inline function ( inline XXX(...);) ## @brief Get the status of the inline function ( inline XXX(...);)
@ -199,7 +239,7 @@ class Methode(Node.Node):
## @return Return methode type (type: Type.Type) ## @return Return methode type (type: Type.Type)
## ##
def get_return_type(self): def get_return_type(self):
return self.returnType return self.return_type
## ##
## @brief Get the list of parameter of the methode ## @brief Get the list of parameter of the methode
@ -207,5 +247,11 @@ class Methode(Node.Node):
## ##
def get_param(self): def get_param(self):
return self.variable return self.variable
##
## @brief Get Override parameter
## @return The requested override parameter
##
def get_override(self):
return self.override

View File

@ -9,6 +9,7 @@ import monkNode as Node
import monkParse as Parse import monkParse as Parse
import monkHtml import monkHtml
import re import re
import json
class Module: class Module:
## ##
@ -22,21 +23,21 @@ class Module:
## ##
def __init__(self, file, moduleName, moduleType): def __init__(self, file, moduleName, moduleType):
## Remove all variable to prevent error of multiple deffinition of the module ... ## Remove all variable to prevent error of multiple deffinition of the module ...
self.originFile='' self.origin_file=''
self.originFolder='' self.origin_folder=''
# type of the module: # type of the module:
self.type='LIBRARY' self.type='LIBRARY'
# Name of the module # Name of the module
self.name=moduleName self.name=moduleName
self.listDocFile = [] self.list_doc_file = []
self.listTutorialFile = [] self.list_tutorial_file = []
self.webSite = "" self.web_site = ""
self.webSource = "" self.web_source = ""
self.pathParsing = "" self.path_parsing = ""
self.pathGlobalDoc = "" self.path_global_doc = ""
self.externalLink = [] self.external_link = []
self.title = moduleName + " Library" self.title = moduleName + " Library"
self.styleHtml = "" self.style_html = ""
## end of basic INIT ... ## end of basic INIT ...
if moduleType.upper() == 'APPLICATION': if moduleType.upper() == 'APPLICATION':
self.type = 'application' self.type = 'application'
@ -46,27 +47,27 @@ class Module:
debug.error('for module "%s"' %moduleName) debug.error('for module "%s"' %moduleName)
debug.error(' ==> error : "%s" ' %moduleType) debug.error(' ==> error : "%s" ' %moduleType)
raise 'Input value error' raise 'Input value error'
self.structureLib = Node.MainNode(self.type, moduleName) self.structure_lib = Node.MainNode(self.type, moduleName)
self.originFile = file; self.origin_file = file;
self.originFolder = tools.get_current_path(self.originFile) self.origin_folder = tools.get_current_path(self.origin_file)
## ##
## @brief Set the module website (activate only when compile in release mode, else "../moduleName/) ## @brief Set the module web_site (activate only when compile in release mode, else "../moduleName/)
## @param[in] url New Website url ## @param[in] url New web_site url
## ##
def set_website(self, url): def set_website(self, url):
self.webSite = url self.web_site = url
def get_website(self): def get_website(self):
return self.webSite return self.web_site
def set_website_sources(self, url): def set_website_sources(self, url):
self.webSource = url self.web_source = url
def get_website_sources(self): def get_website_sources(self):
return self.webSource return self.web_source
## ##
@ -74,21 +75,21 @@ class Module:
## @param[in] path New path to parse ## @param[in] path New path to parse
## ##
def set_path(self, path): def set_path(self, path):
self.pathParsing = path self.path_parsing = path
## ##
## @brief set the glabal documentation parsing folder ## @brief set the glabal documentation parsing folder
## @param[in] path New path to parse ## @param[in] path New path to parse
## ##
def set_path_general_doc(self, path): def set_path_general_doc(self, path):
self.pathGlobalDoc = path self.path_global_doc = path
## ##
## @brief List of validate external library link (disable otherwise) ## @brief List of validate external library link (disable otherwise)
## @param[in] availlable List of all module link availlable ## @param[in] availlable List of all module link availlable
## ##
def set_external_link(self, availlable): def set_external_link(self, availlable):
self.externalLink = availlable self.external_link = availlable
## ##
## @brief Set the library title ## @brief Set the library title
@ -102,42 +103,66 @@ class Module:
## @param[in] file File of the css style sheet ## @param[in] file File of the css style sheet
## ##
def set_html_css(self, cssFile): def set_html_css(self, cssFile):
self.styleHtml = cssFile self.style_html = cssFile
## ##
## @brief Create the module documentation: ## @brief Create the module documentation:
## ##
def parse_code(self): def parse_code(self):
debug.info('Parse documantation code : ' + self.name) debug.info('Parse documantation code : ' + self.name)
if self.pathParsing != "": if self.path_parsing != "":
for root, dirnames, filenames in os.walk(self.pathParsing): for root, dirnames, filenames in os.walk(self.path_parsing):
tmpList = fnmatch.filter(filenames, "*.h") tmpList = fnmatch.filter(filenames, "*.hpp")
# Import the module : # Import the module :
for filename in tmpList: for filename in tmpList:
fileCompleteName = os.path.join(root, filename) fileCompleteName = os.path.join(root, filename)
debug.debug(" Find a file : '" + fileCompleteName + "'") debug.debug(" Find a file : '" + fileCompleteName + "'")
self.add_file(fileCompleteName) self.add_file(fileCompleteName)
# all file is parset ==> now we create the namespacing of all elements: # all file is parset ==> now we create the namespacing of all elements:
self.structureLib.set_namespace() self.structure_lib.set_namespace()
self.structureLib.set_module_link(self) self.structure_lib.set_module_link(self)
#self.structureLib.complete_display() #self.structure_lib.complete_display()
# display the hierarchie of all the class and namespace ... # display the hierarchie of all the class and namespace ...
#self.structureLib.debug_display() #self.structure_lib.debug_display()
if self.pathGlobalDoc != "": if self.path_global_doc != "":
for root, dirnames, filenames in os.walk(self.pathGlobalDoc): for root, dirnames, filenames in os.walk(self.path_global_doc):
tmpList = fnmatch.filter(filenames, "*.bb") tmpList = fnmatch.filter(filenames, "*.md")
# Import the module : # Import the module :
for filename in tmpList: for filename in tmpList:
fileCompleteName = os.path.join(root, filename) fileCompleteName = os.path.join(root, filename)
tutorialPath = os.path.join(self.pathGlobalDoc, "tutorial/") tutorialPath = os.path.join(self.path_global_doc, "tutorial/")
pathBase = fileCompleteName[len(self.pathGlobalDoc):len(fileCompleteName)-3] pathBase = fileCompleteName[len(self.path_global_doc):len(fileCompleteName)-3]
while len(pathBase) > 0 \
and pathBase[0] == '/':
pathBase = pathBase[1:]
debug.verbose(" Find a doc file : fileCompleteName='" + fileCompleteName + "'") debug.verbose(" Find a doc file : fileCompleteName='" + fileCompleteName + "'")
if fileCompleteName[:len(tutorialPath)] == tutorialPath: if fileCompleteName[:len(tutorialPath)] == tutorialPath:
debug.warning("add_tutorial_doc : '" + fileCompleteName + "' ==> '" + pathBase + "'")
self.add_tutorial_doc(fileCompleteName, pathBase) self.add_tutorial_doc(fileCompleteName, pathBase)
else: else:
debug.warning("add_file_doc : '" + fileCompleteName + "' ==> '" + pathBase + "'")
self.add_file_doc(fileCompleteName, pathBase) 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 ## @brief Add a documentation file at the parsing system
## @param[in] filename File To add at the parsing element system. ## @param[in] filename File To add at the parsing element system.
@ -147,13 +172,14 @@ class Module:
def add_file_doc(self, filename, outPath): def add_file_doc(self, filename, outPath):
debug.debug("adding file in documantation : '" + filename + "'"); debug.debug("adding file in documantation : '" + filename + "'");
done = False done = False
for iii in range(0,len(self.listDocFile)): for iii in range(0,len(self.list_doc_file)):
if self.listDocFile[iii][0] > filename: if self.list_doc_file[iii][0] > filename:
self.listDocFile.insert(iii, [filename, outPath]) self.list_doc_file.insert(iii, [filename, outPath])
done = True done = True
break break
if done == False: 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 ## @brief Add a documentation file at the parsing system
@ -165,13 +191,15 @@ class Module:
count = int(filename.split('/')[-1].split('_')[0]) count = int(filename.split('/')[-1].split('_')[0])
debug.debug("adding file in documantation : '" + filename + "'"); debug.debug("adding file in documantation : '" + filename + "'");
done = False done = False
for iii in range(0,len(self.listTutorialFile)): for iii in range(0,len(self.list_tutorial_file)):
if self.listTutorialFile[iii][0] > filename: if self.list_tutorial_file[iii][0] > filename:
self.listTutorialFile.insert(iii, [filename, outPath]) self.list_tutorial_file.insert(iii, [filename, outPath])
done = True done = True
break break
if done == False: 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 ## @brief Add a file at the parsing system
@ -184,7 +212,7 @@ class Module:
#parsedFile = Parse.parse_file("Widget.h") #parsedFile = Parse.parse_file("Widget.h")
#debug.error("plop") #debug.error("plop")
parsedFile = Parse.parse_file(filename) parsedFile = Parse.parse_file(filename)
self.structureLib = parsedFile.fusion(self.structureLib) self.structure_lib = parsedFile.fusion(self.structure_lib)
return True return True
@ -195,14 +223,16 @@ class Module:
## ##
def generate(self): def generate(self):
debug.info('Generate documantation code : ' + self.name) debug.info('Generate documantation code : ' + self.name)
destFolder = "out/doc/" + self.name + '/' #json_data = json.dumps(self, sort_keys=True, indent=4)
#tools.file_write_data(os.path.join("out", "doc", self.name + ".json"), json_data)
destFolder = os.path.join("out", "doc", self.name)
tools.remove_folder_and_sub_folder(destFolder); tools.remove_folder_and_sub_folder(destFolder);
if monkHtml.generate(self, destFolder) == False: if monkHtml.generate(self, destFolder + '/') == False:
debug.warning("Generation Documentation ==> return an error for " + self.name) debug.warning("Generation Documentation ==> return an error for " + self.name)
def get_base_doc_node(self): def get_base_doc_node(self):
return self.structureLib return self.structure_lib
## ##
## @brief Get the heritage list (parent) of one element. ## @brief Get the heritage list (parent) of one element.
@ -212,8 +242,8 @@ class Module:
def get_heritage_list(self, element): def get_heritage_list(self, element):
list = [] list = []
# get element class : # get element class :
if element in self.listClass.keys(): if element in self.list_class.keys():
localClass = self.listClass[element] localClass = self.list_class[element]
if len(localClass['inherits']) != 0: if len(localClass['inherits']) != 0:
# TODO : Support multiple heritage ... # TODO : Support multiple heritage ...
isFirst = True isFirst = True
@ -233,8 +263,8 @@ class Module:
def get_down_heritage_list(self, curentClassName): def get_down_heritage_list(self, curentClassName):
list = [] list = []
# get element class : # get element class :
for element in self.listClass: for element in self.list_class:
localClass = self.listClass[element] localClass = self.list_class[element]
if len(localClass['inherits']) != 0: if len(localClass['inherits']) != 0:
for heritedClass in localClass['inherits']: for heritedClass in localClass['inherits']:
if curentClassName == heritedClass['class']: if curentClassName == heritedClass['class']:
@ -244,11 +274,11 @@ class Module:
return list return list
def get_whith_specific_parrent(self, name, appName=None): def get_whith_specific_parrent(self, name, appName=None):
if self.structureLib.get_node_type() == "library": if self.structure_lib.get_node_type() == "library":
return self.structureLib.get_whith_specific_parrent(name) return self.structure_lib.get_whith_specific_parrent(name)
if appName != self.structureLib.get_name(): if appName != self.structure_lib.get_name():
return [] return []
return self.structureLib.get_whith_specific_parrent(name) return self.structure_lib.get_whith_specific_parrent(name)

View File

@ -8,7 +8,7 @@ class Namespace(Node.Node):
debug.error("Can not parse namespace : " + str(stack)) debug.error("Can not parse namespace : " + str(stack))
Node.Node.__init__(self, 'namespace', stack[1], file, lineNumber, documentation) Node.Node.__init__(self, 'namespace', stack[1], file, lineNumber, documentation)
# enable sub list # enable sub list
self.subList = [] self.sub_list = []
debug.verbose("find namespace : " + self.to_str()) debug.verbose("find namespace : " + self.to_str())

View File

@ -2,7 +2,7 @@
import monkDebug as debug import monkDebug as debug
import monkModule as module import monkModule as module
accessList = ['private', 'protected', 'public'] access_list = ['private', 'protected', 'public']
def debug_space(level): def debug_space(level):
ret = "" ret = ""
@ -13,23 +13,23 @@ def debug_space(level):
genericUID = 0 genericUID = 0
class Node(): class Node():
def __init__(self, type, name="", file="", lineNumber=0, documentation=[]): def __init__(self, type, name="", file="", line_number=0, documentation=[]):
global genericUID global genericUID
genericUID+=1 genericUID+=1
self.uid = genericUID self.uid = genericUID
self.documenatationCode = [] self.documenatation_code = []
self.nodeType = type self.node_type = type
self.name = name self.name = name
self.doc = None self.doc = None
self.fileName = file self.file_name = file
self.lineNumber = lineNumber self.line_number = line_number
self.subList = None self.sub_list = None
self.access = None self.access = None
# namespace elements : (set when all element are parsed ... # namespace elements : (set when all element are parsed ...
self.namespace = [] self.namespace = []
self.moduleLink = None # this is a link on the main application node or library node (usefull to get the website ...) self.module_link = None # this is a link on the main application node or library node (usefull to get the website ...)
self.hiddenRequest = False # @not-in-doc self.hidden_request = False # @not-in-doc
self.previousRequest = False # @previous self.previous_request = False # @previous
self.template = [] self.template = []
self.add_doc(documentation) self.add_doc(documentation)
@ -40,7 +40,7 @@ class Node():
return self.to_str() return self.to_str()
def get_node_type(self): def get_node_type(self):
return self.nodeType return self.node_type
def get_name(self): def get_name(self):
ret = "" ret = ""
@ -65,18 +65,18 @@ class Node():
def add_doc(self, doc): def add_doc(self, doc):
for element in doc: for element in doc:
self.documenatationCode.append(element) self.documenatation_code.append(element)
if element.find("@not-in-doc") != -1 : if element.find("@not-in-doc") != -1 :
self.hiddenRequest = True self.hidden_request = True
if element.find("@previous") != -1 : if element.find("@previous") != -1 :
self.previousRequest = True self.previous_request = True
def get_request_hidden(self): def get_request_hidden(self):
return self.hiddenRequest return self.hidden_request
def get_request_in_previous(self): def get_request_in_previous(self):
return self.previousRequest return self.previous_request
def get_displayable_name(self): def get_displayable_name(self):
@ -91,16 +91,16 @@ class Node():
def get_doc(self): def get_doc(self):
#debug.info(str(self.doc)) #debug.info(str(self.doc))
if len(self.documenatationCode) > 0: if len(self.documenatation_code) > 0:
ret = "" ret = ""
isFirst = True isFirst = True
for req in self.documenatationCode: for req in self.documenatation_code:
if isFirst == False: if isFirst == False:
ret += '\n' ret += '\n'
isFirst = False isFirst = False
ret += req ret += req
return ret return ret
if self.nodeType not in ['methode']: if self.node_type not in ['methode']:
return "" return ""
#try to get previous element : #try to get previous element :
if len(self.namespace) == 0: if len(self.namespace) == 0:
@ -130,35 +130,35 @@ class Node():
heveMethode, pointerMethode = element.have_methode(self.name) heveMethode, pointerMethode = element.have_methode(self.name)
if heveMethode == False: if heveMethode == False:
continue continue
if len(pointerMethode.documenatationCode) != 0: if len(pointerMethode.documenatation_code) != 0:
return pointerMethode.get_doc() return pointerMethode.get_doc()
return "" return ""
def get_lib_name(self): def get_lib_name(self):
if self.moduleLink == None: if self.module_link == None:
return None return None
return self.moduleLink.get_base_doc_node().get_name() return self.module_link.get_base_doc_node().get_name()
def debug_display(self, level=0, access = None): def debug_display(self, level=0, access = None):
if access == 'private': if access == 'private':
debug.info(debug_space(level) + "- " + self.nodeType + " => " + self.name) debug.info(debug_space(level) + "- " + self.node_type + " => " + self.name)
elif access == 'protected': elif access == 'protected':
debug.info(debug_space(level) + "# " + self.nodeType + " => " + self.name) debug.info(debug_space(level) + "# " + self.node_type + " => " + self.name)
elif access == 'public': elif access == 'public':
debug.info(debug_space(level) + "+ " + self.nodeType + " => " + self.name) debug.info(debug_space(level) + "+ " + self.node_type + " => " + self.name)
else: else:
debug.info(debug_space(level) + self.nodeType + " => " + self.name) debug.info(debug_space(level) + self.node_type + " => " + self.name)
if self.subList!= None: if self.sub_list!= None:
for element in self.subList: for element in self.sub_list:
if 'access' in element.keys(): if 'access' in element.keys():
element['node'].debug_display(level+1, element['access']) element['node'].debug_display(level+1, element['access'])
else: else:
element['node'].debug_display(level+1) element['node'].debug_display(level+1)
def set_access(self, access): def set_access(self, access):
if access not in accessList: if access not in access_list:
debug.warning("This is not a valid access : '" + access + "' : availlable : " + str(accessList)) debug.warning("This is not a valid access : '" + access + "' : availlable : " + str(access_list))
return return
if self.access == None: if self.access == None:
debug.error("This Node does not support acces configuration...") debug.error("This Node does not support acces configuration...")
@ -170,18 +170,18 @@ class Node():
def append(self, newSubElement): def append(self, newSubElement):
# just add it in a sub List : # just add it in a sub List :
if self.subList == None: if self.sub_list == None:
debug.error("can not add a '" + newSubElement.nodeType + "' at this '" + self.nodeType + "'") debug.error("can not add a '" + newSubElement.node_type + "' at this '" + self.node_type + "'")
return return
if newSubElement.get_node_type() != 'namespace': if newSubElement.get_node_type() != 'namespace':
if self.access == None: if self.access == None:
self.subList.append({'node' : newSubElement}) self.sub_list.append({'node' : newSubElement})
else: else:
self.subList.append({'access' : self.access, 'node' : newSubElement}) self.sub_list.append({'access' : self.access, 'node' : newSubElement})
return return
# check if the element already exist # check if the element already exist
for element in self.subList: for element in self.sub_list:
if element['node'].get_node_type() == 'namespace': if element['node'].get_node_type() == 'namespace':
if element['node'].get_name() == newSubElement.get_name(): if element['node'].get_name() == newSubElement.get_name():
debug.verbose("fusionate with previous declaration") debug.verbose("fusionate with previous declaration")
@ -189,16 +189,16 @@ class Node():
return return
# normal case adding : # normal case adding :
if self.access == None: if self.access == None:
self.subList.append({'node' : newSubElement}) self.sub_list.append({'node' : newSubElement})
else: else:
self.subList.append({'access' : self.access, 'node' : newSubElement}) self.sub_list.append({'access' : self.access, 'node' : newSubElement})
## ##
## @ brief only for namespace : ## @ brief only for namespace :
## ##
## ##
def fusion(self, addedElement): def fusion(self, addedElement):
for element in addedElement.subList: for element in addedElement.sub_list:
self.append(element['node']) self.append(element['node'])
## ##
@ -209,13 +209,13 @@ class Node():
## ##
def get_all_sub_type(self, type='all', sorted = False): def get_all_sub_type(self, type='all', sorted = False):
if type == 'all': if type == 'all':
return self.subList return self.sub_list
if isinstance(type, list) == False: if isinstance(type, list) == False:
type = [type] type = [type]
if self.subList == None: if self.sub_list == None:
return [] return []
ret = [] ret = []
for element in self.subList: for element in self.sub_list:
if element['node'].get_node_type() in type: if element['node'].get_node_type() in type:
ret.append(element) ret.append(element)
if sorted == True: if sorted == True:
@ -224,9 +224,9 @@ class Node():
return ret return ret
def get_doc_website_page(self): def get_doc_website_page(self):
if self.moduleLink == None: if self.module_link == None:
return "" return ""
ret = self.moduleLink.get_website() ret = self.module_link.get_website()
if ret[-1] != '/': if ret[-1] != '/':
ret += '/' ret += '/'
ret += self.get_node_type() ret += self.get_node_type()
@ -266,15 +266,15 @@ class Node():
return ret return ret
def set_module_link(self, module): def set_module_link(self, module):
self.moduleLink = module self.module_link = module
# set for all sub elements ... # set for all sub elements ...
if self.subList == None: if self.sub_list == None:
return return
if self.nodeType in ['class', 'namespace', 'struct']: if self.node_type in ['class', 'namespace', 'struct']:
for element in self.subList: for element in self.sub_list:
element['node'].set_module_link(module) element['node'].set_module_link(module)
elif self.nodeType in ['library', 'application']: elif self.node_type in ['library', 'application']:
for element in self.subList: for element in self.sub_list:
element['node'].set_module_link(module) element['node'].set_module_link(module)
def set_namespace(self, hierarchy = []): def set_namespace(self, hierarchy = []):
@ -283,16 +283,16 @@ class Node():
for tmpName in hierarchy: for tmpName in hierarchy:
self.namespace.append(tmpName) self.namespace.append(tmpName)
# set for all sub elements ... # set for all sub elements ...
if self.subList == None: if self.sub_list == None:
return return
if self.nodeType in ['class', 'namespace', 'struct']: if self.node_type in ['class', 'namespace', 'struct']:
for element in self.subList: for element in self.sub_list:
hierarchy.append(self.name) hierarchy.append(self.name)
element['node'].set_namespace(hierarchy) element['node'].set_namespace(hierarchy)
#debug.info(" ==> " + str(element['node'].get_namespace())) #debug.info(" ==> " + str(element['node'].get_namespace()))
hierarchy.pop() hierarchy.pop()
elif self.nodeType in ['library', 'application']: elif self.node_type in ['library', 'application']:
for element in self.subList: for element in self.sub_list:
element['node'].set_namespace() element['node'].set_namespace()
#debug.info(" ==> " + str(element['node'].get_namespace())) #debug.info(" ==> " + str(element['node'].get_namespace()))
@ -301,19 +301,19 @@ class Node():
def complete_display(self): def complete_display(self):
debug.info(str(self.namespace) + ' : ' + self.name) debug.info(str(self.namespace) + ' : ' + self.name)
if self.subList == None: if self.sub_list == None:
return return
for element in self.subList: for element in self.sub_list:
element['node'].complete_display() element['node'].complete_display()
def find(self, list): def find(self, list):
debug.verbose("find : " + str(list) + " in " + self.nodeType + "(" + self.name + ")") debug.verbose("find : " + str(list) + " in " + self.node_type + "(" + self.name + ")")
if len(list) == 0: if len(list) == 0:
return None return None
if self.nodeType in ['library', 'application']: if self.node_type in ['library', 'application']:
if self.subList == None: if self.sub_list == None:
return None return None
for element in self.subList: for element in self.sub_list:
ret = element['node'].find(list) ret = element['node'].find(list)
if ret != None: if ret != None:
return ret return ret
@ -323,12 +323,12 @@ class Node():
tmpList = list[1:] tmpList = list[1:]
if len(tmpList) == 0: if len(tmpList) == 0:
return self return self
elif self.nodeType not in ['class', 'namespace', 'struct']: elif self.node_type not in ['class', 'namespace', 'struct']:
# have other sub element and other elemetn than upper can have sub element ... # have other sub element and other elemetn than upper can have sub element ...
return None return None
if self.subList == None: if self.sub_list == None:
return None return None
for element in self.subList: for element in self.sub_list:
ret = element['node'].find(tmpList) ret = element['node'].find(tmpList)
if ret != None: if ret != None:
return ret return ret
@ -338,8 +338,8 @@ class Node():
def get_whith_specific_parrent(self, parrentName): def get_whith_specific_parrent(self, parrentName):
ret = [] ret = []
# set for all sub elements ... # set for all sub elements ...
if self.subList != None: if self.sub_list != None:
for element in self.subList: for element in self.sub_list:
tmpRet = element['node'].get_whith_specific_parrent(parrentName) tmpRet = element['node'].get_whith_specific_parrent(parrentName)
if len(tmpRet) != 0: if len(tmpRet) != 0:
for tmp in tmpRet: for tmp in tmpRet:
@ -347,8 +347,8 @@ class Node():
return ret return ret
def have_methode(self, methodeName): def have_methode(self, methodeName):
if self.subList != None: if self.sub_list != None:
for element in self.subList: for element in self.sub_list:
if element['node'].get_node_type() != 'methode': if element['node'].get_node_type() != 'methode':
continue continue
if element['access'] == "private": if element['access'] == "private":
@ -363,7 +363,7 @@ class Node():
class MainNode(Node): class MainNode(Node):
def __init__(self, type="library", name=""): def __init__(self, type="library", name=""):
Node.__init__(self, type, name) Node.__init__(self, type, name)
self.subList = [] self.sub_list = []
def get_doc_website_page_relative(base, dest): def get_doc_website_page_relative(base, dest):
realBase = "" realBase = ""

View File

@ -2,11 +2,13 @@
import os import os
import sys import sys
import re import re
import copy
import monkTools as tools import monkTools as tools
sys.path.append(tools.get_current_path(__file__) + "/ply/ply/") sys.path.append(tools.get_current_path(__file__) + "/ply/ply/")
sys.path.append(tools.get_current_path(__file__) + "/codeBB/") sys.path.append(tools.get_current_path(__file__) + "/codeBB/")
sys.path.append(tools.get_current_path(__file__) + "/codeMarkDown/")
sys.path.append(tools.get_current_path(__file__) + "/codeHL/") sys.path.append(tools.get_current_path(__file__) + "/codeHL/")
import lex import lex
@ -21,6 +23,8 @@ import monkMethode as Methode
import monkEnum as Enum import monkEnum as Enum
import monkVariable as Variable import monkVariable as Variable
import monkNode as Node import monkNode as Node
import monkUsing as Using
import monkTypedef as Typedef
tokens = [ tokens = [
'NUMBER', 'NUMBER',
@ -82,7 +86,7 @@ t_EXCLAMATION = r'!'
def t_PRECOMP(t): def t_PRECOMP(t):
r'\#.*?\n' r'\#.*?\n'
t.value = re.sub(r'\#\#multiline\#\#', "\\\n", t.value) t.value = re.sub(r'\#\#multiline\#\#', "\\\n", t.value)
t.lexer.lineno += len(filter(lambda a: a=="\n", t.value)) t.lexer.lineno += len(list(filter(lambda a: a=="\n", t.value)))
return t return t
def t_COMMENT_SINGLELINE_DOC_PREVIOUS(t): def t_COMMENT_SINGLELINE_DOC_PREVIOUS(t):
r'//(/|!)<.*?\n' r'//(/|!)<.*?\n'
@ -127,7 +131,8 @@ t_STRING_LITERAL = r'"([^"\\]|\\.)*"'
#Found at http://ostermiller.org/findcomment.html #Found at http://ostermiller.org/findcomment.html
def t_COMMENT_MULTILINE_DOC(t): def t_COMMENT_MULTILINE_DOC(t):
r'/\*(\*|!)(\n|.)*?\*/' r'/\*(\*|!)(\n|.)*?\*/'
t.lexer.lineno += len(filter(lambda a: a=="\n", t.value)) filter_result = list(filter(lambda a: a=="\n", t.value))
t.lexer.lineno += len(filter_result)
t.value = re.sub("( |\t)*\*", "", t.value[3:-2]) t.value = re.sub("( |\t)*\*", "", t.value[3:-2])
while t.value[0] == '\n': while t.value[0] == '\n':
if len(t.value) <= 2: if len(t.value) <= 2:
@ -162,7 +167,7 @@ def t_COMMENT_MULTILINE_DOC(t):
return t return t
def t_COMMENT_MULTILINE(t): def t_COMMENT_MULTILINE(t):
r'/\*(\n|.)*?\*/' r'/\*(\n|.)*?\*/'
t.lexer.lineno += len(filter(lambda a: a=="\n", t.value)) t.lexer.lineno += len(list(filter(lambda a: a=="\n", t.value)))
def t_NEWLINE(t): def t_NEWLINE(t):
r'\n+' r'\n+'
t.lexer.lineno += len(t.value) t.lexer.lineno += len(t.value)
@ -178,23 +183,53 @@ lex.lex()
## @return The new table. ex: ['class', 'Bar::Foo'] ## @return The new table. ex: ['class', 'Bar::Foo']
## ##
def create_compleate_class_name(table): def create_compleate_class_name(table):
if "::" not in "".join(table): debug.verbose("table = " + str(table))
out = table # separate ["<XXX"] in ["<", "XXX"]
else: out = []
# we need to convert it : for name in table:
out = [] if len(name) > 1 \
for name in table: and name[0] == "<":
if len(out) == 0: out.append('<')
out.append(name) out.append(name[1:])
elif name == ":" \ else:
and out[-1].endswith(":"): out.append(name)
out[-1] += name
elif out[-1].endswith("::"):
out[-2] += out[-1] + name
del out[-1]
else:
out.append(name)
table = out table = out
# convert [":", ":"] in ["::"]:
out = []
for name in table:
if len(out) == 0:
out.append(name)
elif name == ":" \
and out[-1] == ":":
out[-1] += name
else:
out.append(name)
table = out
# convert ["|", "|"] in ["||"]:
out = []
for name in table:
if len(out) == 0:
out.append(name)
elif name == "|" \
and out[-1] == "|":
out[-1] += name
else:
out.append(name)
table = out
# convert ["&", "&"] in ["&&"]:
out = []
for name in table:
if len(out) == 0:
out.append(name)
elif name == "&" \
and out[-1] == "&&":
out[-1] += name
else:
out.append(name)
table = out
#
# join operator ...
if 'operator' not in "".join(table): if 'operator' not in "".join(table):
out = table out = table
else: else:
@ -211,27 +246,28 @@ def create_compleate_class_name(table):
out[-1] += name out[-1] += name
else: else:
out.append(name) out.append(name)
debug.verbose(" ==> out = " + str(out))
return out return out
class parse_file(): class parse_file():
def gen_debug_space(self): def gen_debug_space(self):
ret = "[" + str(len(self.braceDepthType)+1) + "]" ret = "[" + str(len(self.brace_depth_type)+1) + "]"
for iii in range(0,len(self.braceDepthType)): for iii in range(0,len(self.brace_depth_type)):
ret += " " ret += " "
return ret return ret
def fusion(self, baseNode): def fusion(self, baseNode):
baseNode.fusion(self.mainNode) baseNode.fusion(self.main_node)
return baseNode return baseNode
def __init__(self, fileName): def __init__(self, fileName):
self.mainNode = Node.MainNode("main-node", "tmp") self.main_node = Node.MainNode("main-node", "tmp")
self.m_elementParseStack = [] self.element_parse_stack = []
debug.debug("Parse file : '" + fileName + "'") debug.debug("Parse file : '" + fileName + "'")
self.headerFileName = fileName self.header_file_name = fileName
self.anon_union_counter = [-1, 0] self.anon_union_counter = [-1, 0]
# load all the file data : # load all the file data :
@ -262,174 +298,201 @@ class parse_file():
###### debug.info(headerFileStr) ###### debug.info(headerFileStr)
self.stack = [] # token stack to find the namespace and the element name ... self.stack = [] # token stack to find the namespace and the element name ...
self.previous = None self.previous = None
self.nameStack = [] # self.name_stack = [] #
self.braceDepth = 0 self.brace_depth = 0
self.braceDepthType = [] self.brace_depth_type = []
self.lastComment = [] self.last_comment = []
self.subModuleCountBrace = 0; self.sub_module_count_brace = 0;
lex.lex() lex.lex()
lex.input(headerFileStr) lex.input(headerFileStr)
self.curLine = 0 self.cur_line = 0
self.curChar = 0 self.cur_char = 0
self.count_pthese = 0
while True: while True:
tok = lex.token() tok = lex.token()
if not tok: if not tok:
break break
debug.verbose("TOK: " + str(tok)) debug.verbose("TOK: " + str(tok))
self.stack.append( tok.value ) self.stack.append( tok.value )
self.curLine = tok.lineno self.cur_line = tok.lineno
self.curChar = tok.lexpos self.cur_char = tok.lexpos
# special case to remove internal function define in header: # special case to remove internal function define in header:
if self.previous_is('function') == True: if self.previous_is('function') == True:
if tok.type == 'OPEN_BRACE': if tok.type == 'OPEN_BRACE':
self.subModuleCountBrace += 1 self.sub_module_count_brace += 1
debug.verbose("openBrace " + str(self.sub_module_count_brace))
elif tok.type == 'CLOSE_BRACE': elif tok.type == 'CLOSE_BRACE':
self.subModuleCountBrace -= 1 self.sub_module_count_brace -= 1
if self.subModuleCountBrace <= 0: debug.verbose("closeBrace " + str(self.sub_module_count_brace) + " line:" + str(self.cur_line))
if self.sub_module_count_brace <= 0:
self.brace_type_pop() self.brace_type_pop()
self.lastComment = [] self.last_comment = []
continue continue
# normal case: # normal case:
if tok.type == 'PRECOMP': if tok.type == 'PRECOMP':
debug.debug("PRECOMP: " + str(tok)) debug.debug("PRECOMP: " + str(tok))
self.stack = [] self.stack = []
self.nameStack = [] self.name_stack = []
self.lastComment = [] self.last_comment = []
# Do nothing for macro ==> many time not needed ... # Do nothing for macro ==> many time not needed ...
continue continue
if tok.type == 'COMMENT_SINGLELINE_DOC_PREVIOUS': if tok.type == 'COMMENT_SINGLELINE_DOC_PREVIOUS':
if self.previous_is('enum') == True: if self.previous_is('enum') == True:
if self.nameStack[-1] == ",": if self.name_stack[-1] == ",":
self.nameStack[-1] = "//!< " + tok.value self.name_stack[-1] = "//!< " + tok.value
self.nameStack.append(",") self.name_stack.append(",")
else: else:
self.nameStack.append("//!< " + tok.value) self.name_stack.append("//!< " + tok.value)
elif self.previous != None \ elif self.previous != None \
and self.previous.get_node_type() == 'variable': and self.previous.get_node_type() == 'variable':
self.previous.add_doc([tok.value]) self.previous.add_doc([tok.value])
else: else:
#self.lastComment.append(tok.value) #self.last_comment.append(tok.value)
pass pass
if tok.type == 'COMMENT_MULTILINE_DOC': if tok.type == 'COMMENT_MULTILINE_DOC':
self.lastComment.append(tok.value) self.last_comment.append(tok.value)
if tok.type == 'COMMENT_SINGLELINE_DOC': if tok.type == 'COMMENT_SINGLELINE_DOC':
self.lastComment.append(tok.value) self.last_comment.append(tok.value)
if tok.type == 'OPEN_BRACE': if tok.type == 'OPEN_BRACE':
# When we open a brace, this is the time to parse the stack ... if self.count_pthese >= 1:
# Clean the stack : (remove \t\r\n , and concatenate the 'xx', ':', ':', 'yy' in 'xx::yy', # special case of lamba declaration inside initialisation of constructor
self.nameStack = create_compleate_class_name(self.nameStack) self.name_stack.append(tok.value)
if len(self.nameStack) <= 0: debug.info("plop 0 " +str(self.count_pthese))
#open brace with no name ...
self.brace_type_push('empty', [])
elif is_a_function(self.nameStack):
# need to parse sub function internal description...
self.subModuleCountBrace = 1
self.brace_type_push('function', self.nameStack)
elif 'namespace' in self.nameStack:
self.brace_type_push('namespace', self.nameStack)
elif 'class' in self.nameStack:
self.brace_type_push('class', self.nameStack)
elif 'enum' in self.nameStack:
self.brace_type_push('enum', self.nameStack)
elif 'struct' in self.nameStack:
self.brace_type_push('struct', self.nameStack)
elif 'typedef' in self.nameStack:
self.brace_type_push('typedef', self.nameStack)
elif 'union' in self.nameStack:
self.brace_type_push('union', self.nameStack)
else: else:
self.brace_type_push('unknow', self.nameStack) # When we open a brace, this is the time to parse the stack ...
self.stack = [] # Clean the stack : (remove \t\r\n , and concatenate the 'xx', ':', ':', 'yy' in 'xx::yy',
self.nameStack = [] self.name_stack = create_compleate_class_name(self.name_stack)
self.lastComment = [] if len(self.name_stack) <= 0:
elif tok.type == 'CLOSE_BRACE': #open brace with no name ...
if len(self.nameStack) != 0: self.brace_type_push('empty', [])
if self.previous_is('enum') == True: elif is_a_function(self.name_stack):
self.brace_type_append('enum list', self.nameStack); # need to parse sub function internal description...
self.sub_module_count_brace = 1
self.brace_type_push('function', self.name_stack)
debug.verbose("openBrace *** " + str(self.name_stack))
elif 'namespace' in self.name_stack:
self.brace_type_push('namespace', self.name_stack)
elif 'class' in self.name_stack:
self.brace_type_push('class', self.name_stack)
elif 'enum' in self.name_stack:
self.brace_type_push('enum', self.name_stack)
elif 'struct' in self.name_stack:
self.brace_type_push('struct', self.name_stack)
elif 'typedef' in self.name_stack:
self.brace_type_push('typedef', self.name_stack)
elif 'using' in self.name_stack:
self.brace_type_push('using', self.name_stack)
elif 'union' in self.name_stack:
self.brace_type_push('union', self.name_stack)
else: else:
debug.warning(self.gen_debug_space() + "end brace DROP : " + str(self.nameStack)); self.brace_type_push('unknow', self.name_stack)
self.stack = [] self.stack = []
self.nameStack = [] self.name_stack = []
self.lastComment = [] self.last_comment = []
self.brace_type_pop() elif tok.type == 'CLOSE_BRACE':
self.nameStack = create_compleate_class_name(self.nameStack) if self.count_pthese >= 1:
debug.info("plop 2 " +str(self.count_pthese))
# special case of lamba declaration inside initialisation of constructor
self.name_stack.append(tok.value)
else:
if len(self.name_stack) != 0:
if self.previous_is('enum') == True:
self.brace_type_append('enum list', self.name_stack);
else:
debug.warning(self.gen_debug_space() + "end brace DROP : " + str(self.name_stack));
self.stack = []
self.name_stack = []
self.last_comment = []
self.brace_type_pop()
self.name_stack = create_compleate_class_name(self.name_stack)
if tok.type == 'OPEN_PAREN': if tok.type == 'OPEN_PAREN':
self.nameStack.append(tok.value) self.count_pthese += 1
self.name_stack.append(tok.value)
elif tok.type == 'CLOSE_PAREN': elif tok.type == 'CLOSE_PAREN':
self.nameStack.append(tok.value) self.count_pthese -= 1
self.name_stack.append(tok.value)
elif tok.type == 'OPEN_SQUARE_BRACKET': elif tok.type == 'OPEN_SQUARE_BRACKET':
self.nameStack.append(tok.value) self.name_stack.append(tok.value)
elif tok.type == 'CLOSE_SQUARE_BRACKET': elif tok.type == 'CLOSE_SQUARE_BRACKET':
self.nameStack.append(tok.value) self.name_stack.append(tok.value)
elif tok.type == 'EQUALS': elif tok.type == 'EQUALS':
self.nameStack.append(tok.value) self.name_stack.append(tok.value)
elif tok.type == 'COMMA': elif tok.type == 'COMMA':
self.nameStack.append(tok.value) self.name_stack.append(tok.value)
elif tok.type == 'BACKSLASH': elif tok.type == 'BACKSLASH':
self.nameStack.append(tok.value) self.name_stack.append(tok.value)
elif tok.type == 'PIPE': elif tok.type == 'PIPE':
self.nameStack.append(tok.value) self.name_stack.append(tok.value)
elif tok.type == 'PERCENT': elif tok.type == 'PERCENT':
self.nameStack.append(tok.value) self.name_stack.append(tok.value)
elif tok.type == 'CARET': elif tok.type == 'CARET':
self.nameStack.append(tok.value) self.name_stack.append(tok.value)
elif tok.type == 'EXCLAMATION': elif tok.type == 'EXCLAMATION':
self.nameStack.append(tok.value) self.name_stack.append(tok.value)
elif tok.type == 'SQUOTE': elif tok.type == 'SQUOTE':
self.nameStack.append(tok.value) self.name_stack.append(tok.value)
elif tok.type == 'NUMBER': elif tok.type == 'NUMBER':
self.nameStack.append(tok.value) self.name_stack.append(tok.value)
elif tok.type == 'MINUS': elif tok.type == 'MINUS':
self.nameStack.append(tok.value) self.name_stack.append(tok.value)
elif tok.type == 'PLUS': elif tok.type == 'PLUS':
self.nameStack.append(tok.value) self.name_stack.append(tok.value)
elif tok.type == 'STRING_LITERAL': elif tok.type == 'STRING_LITERAL':
self.nameStack.append(tok.value) self.name_stack.append(tok.value)
elif tok.type == 'NAME' \ elif tok.type == 'NAME' \
or tok.type == 'AMPERSTAND' \ or tok.type == 'AMPERSTAND' \
or tok.type == 'ASTERISK' \ or tok.type == 'ASTERISK' \
or tok.type == 'CHAR_LITERAL': or tok.type == 'CHAR_LITERAL':
self.nameStack.append(tok.value) self.name_stack.append(tok.value)
elif tok.type == 'COLON': elif tok.type == 'COLON':
if self.nameStack[0] in Node.accessList: if self.name_stack[0] in Node.access_list:
debug.debug(self.gen_debug_space() + "change visibility : " + self.nameStack[0]); debug.debug(self.gen_debug_space() + "change visibility : " + self.name_stack[0]);
self.brace_type_change_access(self.nameStack[0]) self.brace_type_change_access(self.name_stack[0])
self.nameStack = [] self.name_stack = []
self.stack = [] self.stack = []
else : else :
self.nameStack.append(tok.value) self.name_stack.append(tok.value)
elif tok.type == 'SEMI_COLON': elif tok.type == 'SEMI_COLON':
if len(self.nameStack) != 0: if self.count_pthese >= 1:
self.nameStack = create_compleate_class_name(self.nameStack) debug.info("plop 3 " +str(self.count_pthese))
if is_a_function(self.nameStack): # special case of lamba declaration inside initialisation of constructor
self.brace_type_append('function', self.nameStack); self.name_stack.append(tok.value)
elif 'namespace' in self.nameStack: else:
debug.debug(self.gen_debug_space() + "find a namespace DECLARATION : " + str(self.nameStack)); if len(self.name_stack) != 0:
elif 'class' in self.nameStack: self.name_stack = create_compleate_class_name(self.name_stack)
debug.debug(self.gen_debug_space() + "find a class DECLARATION : " + str(self.nameStack)); if is_a_function(self.name_stack):
elif 'enum' in self.nameStack: self.brace_type_append('function', self.name_stack);
debug.debug(self.gen_debug_space() + "find a enum DECLARATION : " + str(self.nameStack)); elif 'namespace' in self.name_stack:
elif 'struct' in self.nameStack: debug.debug(self.gen_debug_space() + "find a namespace DECLARATION : " + str(self.name_stack));
debug.debug(self.gen_debug_space() + "find a struct DECLARATION : " + str(self.nameStack)); elif 'class' in self.name_stack:
elif 'typedef' in self.nameStack: debug.debug(self.gen_debug_space() + "find a class DECLARATION : " + str(self.name_stack));
debug.info(self.gen_debug_space() + "find a typedef DECLARATION : " + str(self.nameStack)); elif 'enum' in self.name_stack:
elif 'union' in self.nameStack: debug.debug(self.gen_debug_space() + "find a enum DECLARATION : " + str(self.name_stack));
debug.debug(self.gen_debug_space() + "find a union DECLARATION : " + str(self.nameStack)); elif 'struct' in self.name_stack:
else: debug.debug(self.gen_debug_space() + "find a struct DECLARATION : " + str(self.name_stack));
if self.previous_is('enum') == True: elif 'typedef' in self.name_stack:
self.brace_type_append('enum list', self.nameStack); debug.warning(self.gen_debug_space() + "find a typedef DECLARATION : " + str(self.name_stack) + " ==> lose it ...");
#self.brace_type_push('typedef', self.name_stack);
elif 'using' in self.name_stack:
debug.info(self.gen_debug_space() + "find a using DECLARATION : " + str(self.name_stack));
self.brace_type_append('using', self.name_stack);
elif 'union' in self.name_stack:
debug.debug(self.gen_debug_space() + "find a union DECLARATION : " + str(self.name_stack));
else: else:
# TODO : Check if it is true in all case : if self.previous_is('enum') == True:
self.brace_type_append('variable', self.nameStack); self.brace_type_append('enum list', self.name_stack);
#debug.warning(self.gen_debug_space() + "variable : " + str(self.nameStack)); else:
self.stack = [] # TODO : Check if it is true in all case :
self.nameStack = [] self.brace_type_append('variable', self.name_stack);
self.lastComment = [] #debug.warning(self.gen_debug_space() + "variable : " + str(self.name_stack));
self.stack = []
self.name_stack = []
self.last_comment = []
#self.debug_display(); #self.debug_display();
def debug_display(self): def debug_display(self):
debug.info("Debug display :") debug.info("Debug display :")
self.mainNode.debug_display(1) self.main_node.debug_display(1)
def create_element(self, type, stack): def create_element(self, type, stack):
ret = None ret = None
@ -438,27 +501,27 @@ class parse_file():
or type == 'enum list': or type == 'enum list':
pass pass
elif type == 'namespace': elif type == 'namespace':
ret = Namespace.Namespace(stack, self.headerFileName, self.curLine, self.lastComment) ret = Namespace.Namespace(stack, self.header_file_name, self.cur_line, self.last_comment)
elif type == 'class': elif type == 'class':
ret = Class.Class(stack, self.headerFileName, self.curLine, self.lastComment) ret = Class.Class(stack, self.header_file_name, self.cur_line, self.last_comment)
elif type == 'struct': elif type == 'struct':
ret = Struct.Struct(stack, self.headerFileName, self.curLine, self.lastComment) ret = Struct.Struct(stack, self.header_file_name, self.cur_line, self.last_comment)
elif type == 'typedef': elif type == 'typedef':
#ret = Namespace.Namespace(stack, self.headerFileName, self.curLine) ret = Typedef.Typedef(stack, self.header_file_name, self.cur_line)
# TODO ... elif type == 'using':
pass ret = Using.Using(stack, self.header_file_name, self.cur_line)
elif type == 'union': elif type == 'union':
ret = Union.Union(stack, self.headerFileName, self.curLine, self.lastComment) ret = Union.Union(stack, self.header_file_name, self.cur_line, self.last_comment)
elif type == 'function': elif type == 'function':
#debug.info(str(self.lastComment)) #debug.info(str(self.last_comment))
if self.get_last_type() == 'class': if self.get_last_type() == 'class':
ret = Methode.Methode(stack, self.headerFileName, self.curLine, self.lastComment, self.braceDepthType[len(self.braceDepthType)-1]['node'].get_name()) ret = Methode.Methode(stack, self.header_file_name, self.cur_line, self.last_comment, self.brace_depth_type[len(self.brace_depth_type)-1]['node'].get_name())
else: else:
ret = Methode.Methode(stack, self.headerFileName, self.curLine, self.lastComment) ret = Methode.Methode(stack, self.header_file_name, self.cur_line, self.last_comment)
elif type == 'enum': elif type == 'enum':
ret = Enum.Enum(stack, self.headerFileName, self.curLine, self.lastComment) ret = Enum.Enum(stack, self.header_file_name, self.cur_line, self.last_comment)
elif type == 'variable': elif type == 'variable':
ret = Variable.Variable(stack, self.headerFileName, self.curLine, self.lastComment) ret = Variable.Variable(stack, self.header_file_name, self.cur_line, self.last_comment)
self.previous = ret self.previous = ret
else: else:
debug.error("unknow type ...") debug.error("unknow type ...")
@ -471,22 +534,22 @@ class parse_file():
'stack' : stack, 'stack' : stack,
'node' : myClassElement 'node' : myClassElement
} }
self.braceDepthType.append(element) self.brace_depth_type.append(element)
#debug.info ("append : " + str(element)) #debug.info ("append : " + str(element))
def brace_type_append_current(self, element, id = -50): def brace_type_append_current(self, element, id = -50):
if id == -50: if id == -50:
id = len(self.braceDepthType)-1 id = len(self.brace_depth_type)-1
if id >= 0: if id >= 0:
while self.braceDepthType[id]['node'] == None: while self.brace_depth_type[id]['node'] == None:
# special case for empty brace, just add it to the upper # special case for empty brace, just add it to the upper
id -=1 id -=1
if id < 0: if id < 0:
break; break;
if id < 0: if id < 0:
self.mainNode.append(element) self.main_node.append(element)
else: else:
self.braceDepthType[id]['node'].append(element) self.brace_depth_type[id]['node'].append(element)
def brace_type_append(self, type, stack): def brace_type_append(self, type, stack):
debug.debug(self.gen_debug_space() + " append a <<" + type + ">> : " + str(stack)); debug.debug(self.gen_debug_space() + " append a <<" + type + ">> : " + str(stack));
@ -498,31 +561,31 @@ class parse_file():
# enum sub list: # enum sub list:
if lastType == 'enum' \ if lastType == 'enum' \
and type == 'enum list': and type == 'enum list':
id = len(self.braceDepthType)-1 id = len(self.brace_depth_type)-1
self.braceDepthType[id]['node'].enum_append(stack) self.brace_depth_type[id]['node'].enum_append(stack)
return return
debug.info("TODO : Parse the special type") debug.info("TODO : Parse the special type")
def brace_type_pop(self): def brace_type_pop(self):
id = len(self.braceDepthType)-1 id = len(self.brace_depth_type)-1
if id < 0: if id < 0:
debug.warning("Try to pop the stack with No more element ...") debug.warning("Try to pop the stack with No more element ...")
return return
if self.braceDepthType[id]['node'] == None: if self.brace_depth_type[id]['node'] == None:
# nothing to add at the upper ... # nothing to add at the upper ...
pass pass
else: else:
# add it on the previous # add it on the previous
self.brace_type_append_current(self.braceDepthType[id]['node'], id-1) self.brace_type_append_current(self.brace_depth_type[id]['node'], id-1)
self.braceDepthType.pop() self.brace_depth_type.pop()
def brace_type_change_access(self, newOne): def brace_type_change_access(self, newOne):
if newOne not in Node.accessList: if newOne not in Node.access_list:
debug.error("unknow access type : " + newOne) debug.error("unknow access type : " + newOne)
return return
id = len(self.braceDepthType)-1 id = len(self.brace_depth_type)-1
if id >= 0: if id >= 0:
while self.braceDepthType[id]['node'] == None: while self.brace_depth_type[id]['node'] == None:
# special case for empty brace, just add it to the upper # special case for empty brace, just add it to the upper
id -=1 id -=1
if id < 0: if id < 0:
@ -530,10 +593,10 @@ class parse_file():
if id < 0: if id < 0:
debug.warning("can not change the main access on the library") debug.warning("can not change the main access on the library")
else: else:
if self.braceDepthType[id]['node'].get_access() == None: if self.brace_depth_type[id]['node'].get_access() == None:
debug.error("Can not set access in other as : 'class' or 'struct' :" + str(self.braceDepthType[id])) debug.error("Can not set access in other as : 'class' or 'struct' :" + str(self.brace_depth_type[id]))
return return
self.braceDepthType[id]['node'].set_access(newOne) self.brace_depth_type[id]['node'].set_access(newOne)
def previous_is(self, type): def previous_is(self, type):
if self.get_last_type() == type: if self.get_last_type() == type:
@ -541,33 +604,33 @@ class parse_file():
return False return False
def get_last_type(self): def get_last_type(self):
if len(self.braceDepthType) > 0: if len(self.brace_depth_type) > 0:
return self.braceDepthType[len(self.braceDepthType)-1]['type'] return self.brace_depth_type[len(self.brace_depth_type)-1]['type']
return None return None
def is_a_function(stack) : def is_a_function(stack) :
# in a function we need to have functionName + ( + ) # in a function we need to have functionName + ( + )
if len(stack) < 3: tmp = copy.deepcopy(stack);
while len(tmp) > 0\
and ( tmp[-1] == 'const'\
or tmp[-1] == 'noexcept'\
or tmp[-1] == 'override'\
or tmp[-1] == 'volatile'):
tmp = tmp[:-1]
if len(tmp) < 3:
return False return False
if ':' in stack: if ':' in tmp:
res = [] res = []
for element in stack: for element in tmp:
if element != ':': if element != ':':
res.append(element) res.append(element)
else: else:
break break
stack = res tmp = res
if stack[len(stack)-2] == '=' \ if tmp[-2] == '=' \
and stack[len(stack)-1] == '0': and tmp[-1] == '0':
stack = stack[:len(stack)-2] tmp = tmp[:-2]
#can end with 2 possibilities : ')', 'const' or ')' #can end with 2 possibilities : ')', 'const' or ')'
if stack[len(stack)-1] == ')' \ if tmp[-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'):
return True return True
return False return False

View File

@ -7,7 +7,7 @@ class Struct(Node.Node):
name = "" name = ""
Node.Node.__init__(self, 'struct', name, file, lineNumber, documentation) Node.Node.__init__(self, 'struct', name, file, lineNumber, documentation)
self.access = "public" self.access = "public"
self.subList = [] self.sub_list = []
def to_str(self) : def to_str(self) :

View File

@ -14,30 +14,78 @@ global_basic_type = ['void', 'bool', \
'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'uint128_t', \ 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'uint128_t', \
'T', 'CLASS_TYPE'] 'T', 'CLASS_TYPE']
global_class_link = { global_class_link = {
"std::string" : "http://www.cplusplus.com/reference/string/string/", "etk::String" : "http://www.cplusplus.com/reference/string/string/",
"std::u16string" : "http://www.cplusplus.com/reference/string/u16string/", "std::u16string" : "http://www.cplusplus.com/reference/string/u16string/",
"std::u32string" : "http://www.cplusplus.com/reference/string/u32string/", "std11::u16string" : "http://www.cplusplus.com/reference/string/u16string/",
"std::wstring" : "http://www.cplusplus.com/reference/string/wstring/", "etk::UString" : "http://www.cplusplus.com/reference/string/u32string/",
"std::vector" : "http://www.cplusplus.com/reference/vector/vector/", "std11::u32string" : "http://www.cplusplus.com/reference/string/u32string/",
"std::list" : "http://www.cplusplus.com/reference/list/list/", "std::wstring" : "http://www.cplusplus.com/reference/string/wstring/",
"std::pair" : "http://www.cplusplus.com/reference/utility/pair/", "etk::Vector" : "http://www.cplusplus.com/reference/vector/vector/",
"std::tuple" : "http://www.cplusplus.com/reference/tuple/tuple/", "std::list" : "http://www.cplusplus.com/reference/list/list/",
"std::shared_ptr": "http://www.cplusplus.com/reference/memory/shared_ptr/", "etk::Pair" : "http://www.cplusplus.com/reference/utility/pair/",
"std::weak_ptr" : "http://www.cplusplus.com/reference/memory/weak_ptr/", "std::tuple" : "http://www.cplusplus.com/reference/tuple/tuple/",
"std::enable_shared_from_this" : "http://www.cplusplus.com/reference/memory/enable_shared_from_this/"
"std::shared_ptr" : "http://www.cplusplus.com/reference/memory/shared_ptr/",
"std11::shared_ptr": "http://www.cplusplus.com/reference/memory/shared_ptr/",
"std::weak_ptr" : "http://www.cplusplus.com/reference/memory/weak_ptr/",
"std11::weak_ptr" : "http://www.cplusplus.com/reference/memory/weak_ptr/",
"std::enable_shared_from_this" : "http://www.cplusplus.com/reference/memory/enable_shared_from_this/",
"std11::enable_shared_from_this" : "http://www.cplusplus.com/reference/memory/enable_shared_from_this/",
"ethread::Mutex" : "http://www.cplusplus.com/reference/mutex/mutex/",
"std11::mutex": "http://www.cplusplus.com/reference/mutex/mutex/",
"std::unique_lock" : "http://www.cplusplus.com/reference/mutex/unique_lock/",
"std11::unique_lock": "http://www.cplusplus.com/reference/mutex/unique_lock/",
"std::chrono::" : "http://www.cplusplus.com/reference/chrono/time_point/",
"std11::chrono::": "http://www.cplusplus.com/reference/chrono/time_point/",
"std::chrono::system_clock::time_point" : "http://www.cplusplus.com/reference/chrono/time_point/",
"std11::chrono::system_clock::time_point" : "http://www.cplusplus.com/reference/chrono/time_point/",
"std::chrono::steady_clock::time_point" : "http://www.cplusplus.com/reference/chrono/time_point/",
"std11::chrono::steady_clock::time_point" : "http://www.cplusplus.com/reference/chrono/time_point/",
"std::chrono::time_point" : "http://www.cplusplus.com/reference/chrono/time_point/",
"std11::chrono::time_point" : "http://www.cplusplus.com/reference/chrono/time_point/",
"std::chrono::system_clock":"http://www.cplusplus.com/reference/chrono/system_clock/",
"std11::chrono::system_clock":"http://www.cplusplus.com/reference/chrono/system_clock/",
"std::chrono::steady_clock":"http://www.cplusplus.com/reference/chrono/steady_clock/",
"std11::chrono::steady_clock":"http://www.cplusplus.com/reference/chrono/steady_clock/",
"std::chrono::duration":"http://www.cplusplus.com/reference/chrono/duration/",
"std11::chrono::duration":"http://www.cplusplus.com/reference/chrono/duration/",
"std::chrono::hours":"http://www.cplusplus.com/reference/chrono/duration/",
"std11::chrono::hours":"http://www.cplusplus.com/reference/chrono/duration/",
"std::chrono::minutes":"http://www.cplusplus.com/reference/chrono/duration/",
"std11::chrono::minutes":"http://www.cplusplus.com/reference/chrono/duration/",
"std::chrono::seconds":"http://www.cplusplus.com/reference/chrono/duration/",
"std11::chrono::seconds":"http://www.cplusplus.com/reference/chrono/duration/",
"std::chrono::milliseconds":"http://www.cplusplus.com/reference/chrono/duration/",
"std11::chrono::milliseconds":"http://www.cplusplus.com/reference/chrono/duration/",
"std::chrono::microseconds":"http://www.cplusplus.com/reference/chrono/duration/",
"std11::chrono::microseconds":"http://www.cplusplus.com/reference/chrono/duration/",
"std::chrono::nanoseconds":"http://www.cplusplus.com/reference/chrono/duration/",
"std11::chrono::nanoseconds":"http://www.cplusplus.com/reference/chrono/duration/",
} }
class Type(): class Type():
def __init__(self, stack=[]): def __init__(self, stack=[]):
self.nameBefore = "" self.name_before = ""
self.name = "" self.name = ""
self.nameAfter = "" self.name_after = ""
self.const = False # the const xxxxx self.const = False # the const xxxxx
self.reference = False self.reference = False
self.constVar = False # the char* const VarName self.const_var = False # the char* const VarName
self.enum = False self.enum = False
self.struct = False self.struct = False
self.mutable = False
self.template_parameter = None
if len(stack) == 0: if len(stack) == 0:
# None type # None type
@ -47,7 +95,7 @@ class Type():
return; return;
# check end const # check end const
if stack[len(stack)-1] == 'const': if stack[len(stack)-1] == 'const':
self.constVar = True self.const_var = True
stack = stack[:len(stack)-1] stack = stack[:len(stack)-1]
# check if element is a reference ... # check if element is a reference ...
if stack[len(stack)-1] == '&': if stack[len(stack)-1] == '&':
@ -64,39 +112,85 @@ class Type():
if stack[0] == 'struct': if stack[0] == 'struct':
self.struct = True self.struct = True
stack = stack[1:] stack = stack[1:]
if stack[0] == 'mutable':
self.mutable = True
stack = stack[1:]
self.nameBefore = "" debug.info("get type : " + str(stack))
self.name_before = ""
self.name = "" self.name = ""
self.nameAfter = "" self.name_after = ""
template_level = 0
template_new_elem = False
for element in stack: for element in stack:
if self.nameAfter != "": if template_level == 0:
self.nameAfter += element if self.name_after != "":
self.name_after += element
continue
if element[0] in ['*', '&']:
if self.name == "":
self.name_before += element
continue
else:
self.name_after += element
continue
else:
if element[0] in [',']:
#Template separator ...
template_new_elem = True
continue
if element[0] == '<':
debug.info(" Start template")
if self.template_parameter == None:
self.template_parameter = []
template_level += 1
continue continue
if element[0] in ['*', '&', '<']: if element[0] == '>':
if self.name == "": template_level -= 1
self.nameBefore += element debug.info(" Stop template")
continue continue
else: if template_level != 0:
self.nameAfter += element if element != "":
continue if template_new_elem == True \
self.name += element or len(self.template_parameter) == 0:
#debug.info("get type : " + str(stack) + " ==> " +self.name) self.template_parameter.append(element)
else:
self.template_parameter[-1] += " " + element
else:
self.name += element
if self.template_parameter == None:
debug.info(" ==> '" + self.name + "'")
else:
debug.info(" ==> '" + self.name + "' : " + str(self.template_parameter))
debug.info(" self.name_before='" + str(self.name_before) + "'")
debug.info(" self.name_after='" + self.name_after + "'")
def to_str(self) : def to_str(self) :
ret = "" ret = ""
if self.const == True: if self.const == True:
ret += "const " ret += "const "
if self.mutable == True:
ret += "mutable "
if self.enum == True: if self.enum == True:
ret += "enum " ret += "enum "
if self.struct == True: if self.struct == True:
ret += "struct " ret += "struct "
ret += self.name_before
ret += self.nameBefore
ret += self.name ret += self.name
ret += self.nameAfter if self.template_parameter != None:
ret += "<"
first_elem = True
for elem in self.template_parameter:
if first_elem == True:
first_elem = False
else:
ret += ", "
ret += elem
ret += ">"
ret += self.name_after
if self.reference == True: if self.reference == True:
ret += " &" ret += " &"
if self.constVar == True: if self.const_var == True:
ret += " const" ret += " const"
return ret return ret
@ -108,16 +202,19 @@ class Type():
if self.const == True: if self.const == True:
ret += "const " ret += "const "
retDecorated += module.display_color("const") + " " retDecorated += module.display_color("const") + " "
if self.mutable == True:
ret += "mutable "
retDecorated += module.display_color("mutable") + " "
if self.enum == True: if self.enum == True:
ret += "enum " ret += "enum "
retDecorated += module.display_color("enum") + " " retDecorated += module.display_color("enum") + " "
if self.struct == True: if self.struct == True:
ret += "struct " ret += "struct "
retDecorated += module.display_color("struct") + " " retDecorated += module.display_color("struct") + " "
ret += self.nameBefore ret += self.name_before
ret += self.name ret += self.name
ret += self.nameAfter ret += self.name_after
retDecorated += self.nameBefore retDecorated += self.name_before
element = module.get_element_with_name(self.name) element = module.get_element_with_name(self.name)
if element == None: if element == None:
@ -134,11 +231,27 @@ class Type():
retDecorated += '<a class="code-type" href="' + link + '">' retDecorated += '<a class="code-type" href="' + link + '">'
retDecorated += self.name retDecorated += self.name
retDecorated += '</a>' retDecorated += '</a>'
retDecorated += re.sub(">","&gt;", re.sub("<","&lt;", self.nameAfter))
if self.template_parameter != None:
retDecorated += "&lt;"
ret += "<"
first_elem = True
for elem in self.template_parameter:
if first_elem == True:
first_elem = False
else:
ret += ", "
retDecorated += ", "
ret += elem
retDecorated += elem
ret += ">"
retDecorated += "&gt;"
retDecorated += self.name_after
if self.reference == True: if self.reference == True:
ret += " &" ret += " &"
retDecorated += " &" retDecorated += " &"
if self.constVar == True: if self.const_var == True:
ret += " const" ret += " const"
retDecorated += " " + module.display_color("const") retDecorated += " " + module.display_color("const")
return [ret, retDecorated] return [ret, retDecorated]

15
monkTypedef.py Normal file
View File

@ -0,0 +1,15 @@
#!/usr/bin/python
import monkDebug as debug
import monkNode as Node
class Typedef(Node.Node):
def __init__(self, stack=[], file="", lineNumber=0, documentation=[]):
name = ""
debug.warning(" typedef : " + str(stack))
Node.Node.__init__(self, 'typedef', name, file, lineNumber, documentation)
def to_str(self) :
return "typedef " + self.name + " { ... };"

19
monkUsing.py Normal file
View File

@ -0,0 +1,19 @@
#!/usr/bin/python
import monkDebug as debug
import monkNode as Node
import monkType as Type
class Using(Node.Node):
def __init__(self, stack=[], file="", lineNumber=0, documentation=[]):
name = stack[1]
self.access = "public"
Node.Node.__init__(self, 'using', name, file, lineNumber, documentation)
self.type = Type.Type(stack[3:])
debug.verbose(" using : " + str(stack) + " name=" + name + " " + self.type.to_str())
def to_str(self) :
return "using " + self.name + " { ... };"
def get_type(self):
return self.type

View File

@ -34,7 +34,7 @@ class Variable(Node.Node):
Node.Node.__init__(self, 'variable', name, file, lineNumber, documentation) Node.Node.__init__(self, 'variable', name, file, lineNumber, documentation)
# force the sublist error generation ... # force the sublist error generation ...
self.subList = None self.sub_list = None
# default variable : # default variable :
self.type = Type.TypeNone() self.type = Type.TypeNone()
self.static = False self.static = False

View File

@ -648,7 +648,7 @@ from compiler import misc, syntax, pycodegen
class GardenSnakeCompiler(object): class GardenSnakeCompiler(object):
def __init__(self): def __init__(self):
self.parser = GardenSnakeParser() self.parser = GardenSnakeParser()
def compile(self, code, filename="<string>"): def compile(self, code, filename="<etk/String.hpp>"):
tree = self.parser.parse(code) tree = self.parser.parse(code)
#print tree #print tree
misc.set_filename(filename, tree) misc.set_filename(filename, tree)

1
version.txt Normal file
View File

@ -0,0 +1 @@
0.1.0