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):
if type == "c++":
if type == "c++" \
or type == "cpp":
value = codeHLcpp.transcode(value)
elif type == "java":
value = codeHLJava.transcode(value)

View File

@ -16,8 +16,6 @@ listRegExp = [
'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))',
'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])',
'code-member'],
[ r'(( |\t)_[A-Za-z_0-9]*)',
@ -37,7 +35,9 @@ listRegExp = [
[ r'(true|TRUE|false|FALSE)',
'<code-operator'],
[ 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):

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@ class Struct(Node.Node):
name = ""
Node.Node.__init__(self, 'struct', name, file, lineNumber, documentation)
self.access = "public"
self.subList = []
self.sub_list = []
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', \
'T', 'CLASS_TYPE']
global_class_link = {
"std::string" : "http://www.cplusplus.com/reference/string/string/",
"std::u16string" : "http://www.cplusplus.com/reference/string/u16string/",
"std::u32string" : "http://www.cplusplus.com/reference/string/u32string/",
"std::wstring" : "http://www.cplusplus.com/reference/string/wstring/",
"std::vector" : "http://www.cplusplus.com/reference/vector/vector/",
"std::list" : "http://www.cplusplus.com/reference/list/list/",
"std::pair" : "http://www.cplusplus.com/reference/utility/pair/",
"std::tuple" : "http://www.cplusplus.com/reference/tuple/tuple/",
"std::shared_ptr": "http://www.cplusplus.com/reference/memory/shared_ptr/",
"std::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/"
"etk::String" : "http://www.cplusplus.com/reference/string/string/",
"std::u16string" : "http://www.cplusplus.com/reference/string/u16string/",
"std11::u16string" : "http://www.cplusplus.com/reference/string/u16string/",
"etk::UString" : "http://www.cplusplus.com/reference/string/u32string/",
"std11::u32string" : "http://www.cplusplus.com/reference/string/u32string/",
"std::wstring" : "http://www.cplusplus.com/reference/string/wstring/",
"etk::Vector" : "http://www.cplusplus.com/reference/vector/vector/",
"std::list" : "http://www.cplusplus.com/reference/list/list/",
"etk::Pair" : "http://www.cplusplus.com/reference/utility/pair/",
"std::tuple" : "http://www.cplusplus.com/reference/tuple/tuple/",
"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():
def __init__(self, stack=[]):
self.nameBefore = ""
self.name_before = ""
self.name = ""
self.nameAfter = ""
self.name_after = ""
self.const = False # the const xxxxx
self.reference = False
self.constVar = False # the char* const VarName
self.const_var = False # the char* const VarName
self.enum = False
self.struct = False
self.mutable = False
self.template_parameter = None
if len(stack) == 0:
# None type
@ -47,7 +95,7 @@ class Type():
return;
# check end const
if stack[len(stack)-1] == 'const':
self.constVar = True
self.const_var = True
stack = stack[:len(stack)-1]
# check if element is a reference ...
if stack[len(stack)-1] == '&':
@ -64,39 +112,85 @@ class Type():
if stack[0] == 'struct':
self.struct = True
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.nameAfter = ""
self.name_after = ""
template_level = 0
template_new_elem = False
for element in stack:
if self.nameAfter != "":
self.nameAfter += element
if template_level == 0:
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
if element[0] in ['*', '&', '<']:
if self.name == "":
self.nameBefore += element
continue
else:
self.nameAfter += element
continue
self.name += element
#debug.info("get type : " + str(stack) + " ==> " +self.name)
if element[0] == '>':
template_level -= 1
debug.info(" Stop template")
continue
if template_level != 0:
if element != "":
if template_new_elem == True \
or len(self.template_parameter) == 0:
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) :
ret = ""
if self.const == True:
ret += "const "
if self.mutable == True:
ret += "mutable "
if self.enum == True:
ret += "enum "
if self.struct == True:
ret += "struct "
ret += self.nameBefore
ret += self.name_before
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:
ret += " &"
if self.constVar == True:
if self.const_var == True:
ret += " const"
return ret
@ -108,16 +202,19 @@ class Type():
if self.const == True:
ret += "const "
retDecorated += module.display_color("const") + " "
if self.mutable == True:
ret += "mutable "
retDecorated += module.display_color("mutable") + " "
if self.enum == True:
ret += "enum "
retDecorated += module.display_color("enum") + " "
if self.struct == True:
ret += "struct "
retDecorated += module.display_color("struct") + " "
ret += self.nameBefore
ret += self.name_before
ret += self.name
ret += self.nameAfter
retDecorated += self.nameBefore
ret += self.name_after
retDecorated += self.name_before
element = module.get_element_with_name(self.name)
if element == None:
@ -134,11 +231,27 @@ class Type():
retDecorated += '<a class="code-type" href="' + link + '">'
retDecorated += self.name
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:
ret += " &"
retDecorated += " &"
if self.constVar == True:
if self.const_var == True:
ret += " const"
retDecorated += " " + module.display_color("const")
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)
# force the sublist error generation ...
self.subList = None
self.sub_list = None
# default variable :
self.type = Type.TypeNone()
self.static = False

View File

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

1
version.txt Normal file
View File

@ -0,0 +1 @@
0.1.0