[DEV] update documantation generator

This commit is contained in:
Edouard DUPIN 2014-09-01 22:07:49 +02:00
parent 449652f589
commit 9b9a5d3237
6 changed files with 169 additions and 45 deletions

View File

@ -13,6 +13,21 @@ def concatenate_template(list):
# TODO ... # TODO ...
return list return list
def splitList(list):
base = []
out = []
for elem in list:
if elem == ",":
out.append(base)
base = []
else:
base.append(elem)
if len(base) != 0:
out.append(base)
base = []
return out
class Class(Node.Node): class Class(Node.Node):
def __init__(self, stack=[], file="", lineNumber=0, documentation=[]): def __init__(self, stack=[], file="", lineNumber=0, documentation=[]):
# check input : # check input :
@ -20,20 +35,31 @@ class Class(Node.Node):
debug.error("Can not parse class : " + str(stack)) debug.error("Can not parse class : " + str(stack))
return return
#check if it is a template class: #check if it is a template class:
templateDeclatation = []
if stack[0] == "template": if stack[0] == "template":
debug.debug("find a template class: " + str(stack)) debug.debug("find a template class: " + str(stack))
#remove template properties ==> not manage for now ... #remove template properties ==> not manage for now ...
propertyTemplate = stack[1:stack.index("class")-1] idEnd = 2
level = 1
for tmpClassElem in stack[2:]:
if tmpClassElem[0] == '<':
level+=1
elif tmpClassElem[0] == '>':
level-=1
if level == 0:
break
idEnd+=1
propertyTemplate = stack[1:idEnd]
propertyTemplate[0] = propertyTemplate[0][1:] propertyTemplate[0] = propertyTemplate[0][1:]
stack = stack[stack.index("class"):] templateDeclatation = splitList(propertyTemplate)
stack = stack[idEnd+1:]
# TODO : add the template properties back ... # TODO : add the template properties back ...
debug.debug("template property : " + str(propertyTemplate)) debug.debug("template property : " + str(templateDeclatation))
else:
self.template = []
if len(stack) < 2: if len(stack) < 2:
debug.error("Can not parse class 2 : " + str(stack)) debug.error("Can not parse class 2 : " + str(stack))
return return
Node.Node.__init__(self, 'class', stack[1], file, lineNumber, documentation) Node.Node.__init__(self, 'class', stack[1], file, lineNumber, documentation)
self.template = templateDeclatation
self.subList = [] self.subList = []
self.access = "private" self.access = "private"
# heritage list : # heritage list :
@ -74,13 +100,24 @@ class Class(Node.Node):
list = concatenate_template(stack[3:]) list = concatenate_template(stack[3:])
debug.verbose("inherit : " + str(list)) debug.verbose("inherit : " + str(list))
access = "private" access = "private"
classProperty = []
for element in list: for element in list:
if element in ['private', 'protected', 'public']: if element in ['private', 'protected', 'public']:
access = element access = element
elif element == ',': elif element == ',':
pass concatenate = ""
for classProp in classProperty:
concatenate += classProp
self.inherit.append({'access' : access, 'class' : concatenate})
classProperty = []
else: else:
self.inherit.append({'access' : access, 'class' : element}) classProperty.append(element)
if len(classProperty) != 0:
concatenate = ""
for classProp in classProperty:
concatenate += classProp
self.inherit.append({'access' : access, 'class' : concatenate})
classProperty = []
debug.verbose("class : " + self.to_str()) debug.verbose("class : " + self.to_str())
@ -105,11 +142,11 @@ class Class(Node.Node):
parent = module.get_element_with_name(self.inherit[0]['class']) parent = module.get_element_with_name(self.inherit[0]['class'])
cparent = [] cparent = []
if parent != None: if parent != None:
debug.verbose(" plop : " + self.name + " " + str(parent) + " " + parent.get_name()) debug.verbose("Prent : " + self.name + " " + str(parent) + " " + parent.get_name())
cparent = parent.get_parents() cparent = parent.get_parents()
pass pass
#heritage = parent. #heritage = parent.
cparent.append(self.inherit[0]) cparent.append(self.inherit)
return cparent return cparent
def get_whith_specific_parrent(self, parrentName): def get_whith_specific_parrent(self, parrentName):

View File

@ -9,6 +9,21 @@ import collections
import monkModule as module import monkModule as module
import monkNode as node import monkNode as node
htmlCodes = (
('&', '&amp;'),
("'", '&#39;'),
('"', '&quot;'),
('>', '&gt;'),
('<', '&lt;')
)
def html_decode(s):
for code in htmlCodes:
s = s.replace(code[1], code[0])
return s
def html_encode(s):
for code in htmlCodes:
s = s.replace(code[0], code[1])
return s
def display_doxygen_param(comment, input, output): def display_doxygen_param(comment, input, output):
data = '<tr>' data = '<tr>'
@ -143,11 +158,11 @@ def calculate_methode_size(list):
methodeSize = 0; methodeSize = 0;
haveVirtual = False haveVirtual = False
for element in list: for element in list:
if ( element['node'].get_node_type() == 'methode' \ if element['node'].get_node_type() == 'methode' \
or element['node'].get_node_type() == 'constructor' \ or element['node'].get_node_type() == 'constructor' \
or element['node'].get_node_type() == 'desctructor') \ or element['node'].get_node_type() == 'destructor':
and element['node'].get_virtual() == True: if element['node'].get_virtual() == True:
haveVirtual = True haveVirtual = True
if element['node'].get_node_type() == 'variable': if element['node'].get_node_type() == 'variable':
retType = element['node'].get_type().to_str() retType = element['node'].get_type().to_str()
else: else:
@ -365,44 +380,52 @@ def generate_page(outFolder, header, footer, element):
# generate herirage list : # generate herirage list :
if element.get_node_type() == 'class': if element.get_node_type() == 'class':
parent = element.get_parents() parentAll = element.get_parents()
debug.verbose("parrent of " + element.get_name() + " : " + str(parent)) debug.verbose("parrent of " + element.get_name() + " : " + str(parentAll))
child = module.get_whith_specific_parrent(element.get_displayable_name(), ) child = module.get_whith_specific_parrent(element.get_displayable_name(), )
if len(parent) != 0 \ if len(parentAll) != 0 \
or len(child) != 0: or len(child) != 0:
file.write('<h2>Object Hierarchy:<h2>\n') file.write('<h2>Object Hierarchy:<h2>\n')
file.write('<pre>\n'); file.write('<pre>\n');
level = 0 level = 0
parent.append({'access':'me', 'class':element.get_displayable_name()}) for parent in parentAll:
for parentElem in parent: for parentElem in parent:
access = "" access = ""
if parentElem['access'] == 'public': if parentElem['access'] == 'public':
access = "+" access = "+"
elif parentElem['access'] == 'protected': elif parentElem['access'] == 'protected':
access = "#" access = "#"
elif parentElem['access'] == 'private': elif parentElem['access'] == 'private':
access = "-" access = "-"
tmpLen = level * 7 tmpLen = level * 7
if tmpLen > 0: if tmpLen > 0:
tmpLen -= 5 tmpLen -= 5
file.write(white_space(tmpLen)) file.write(white_space(tmpLen))
if level != 0: if level != 0:
file.write('+--> ') file.write('+--> ')
file.write(access) file.write(access)
if parentElem['access'] == 'me':
file.write(parentElem['class'])
else:
classPointer = module.get_element_with_name(parentElem['class']) classPointer = module.get_element_with_name(parentElem['class'])
if classPointer != None: if classPointer != None:
link = classPointer.get_doc_website_page() link = classPointer.get_doc_website_page()
link = node.get_doc_website_page_relative(currentPageSite, link) link = node.get_doc_website_page_relative(currentPageSite, link)
file.write('<a href="' + link + '">') file.write('<a href="' + link + '">')
file.write(parentElem['class']) file.write(html_encode(parentElem['class']))
#debug.warning("nodeName " + html_encode(parentElem['class']) )
if classPointer != None: if classPointer != None:
file.write('</a>') file.write('</a>')
file.write('<br/>') file.write('<br/>')
level += 1 level += 1
# write local class:
tmpLen = level * 7
if tmpLen > 0:
tmpLen -= 5
file.write(white_space(tmpLen))
if level != 0:
file.write('+--> ')
file.write(element.get_displayable_name())
file.write('<br/>')
level += 1
# all child not in application : # all child not in application :
for childElem in child: for childElem in child:
tmpLen = level * 7 tmpLen = level * 7

View File

@ -30,6 +30,7 @@ class Node():
self.moduleLink = None # this is a link on the main application node or library node (usefull to get the website ...) 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.hiddenRequest = False # @not-in-doc
self.previousRequest = False # @previous self.previousRequest = False # @previous
self.template = []
self.add_doc(documentation) self.add_doc(documentation)
def to_str(self): def to_str(self):
@ -42,7 +43,22 @@ class Node():
return self.nodeType return self.nodeType
def get_name(self): def get_name(self):
return self.name ret = ""
if self.template != []:
ret += "template&lt;"
first = True
for elem in self.template:
if first == True:
first = False
else:
ret += ", "
if len(elem) >= 2:
ret += elem[1]
else:
ret += elem[0]
ret += "&gt "
ret += self.name
return ret
def get_UID(self): def get_UID(self):
return self.uid return self.uid
@ -108,7 +124,7 @@ class Node():
return "" return ""
for myParent in reversed(parents): for myParent in reversed(parents):
element = module.get_element_with_name(myParent['class']) element = module.get_element_with_name(myParent[0]['class'])
if element == None: if element == None:
continue continue
heveMethode, pointerMethode = element.have_methode(self.name) heveMethode, pointerMethode = element.have_methode(self.name)
@ -233,6 +249,19 @@ class Node():
ret += "NO_NAME_" + str(self.uid) ret += "NO_NAME_" + str(self.uid)
else: else:
ret += self.name ret += self.name
if self.template != []:
ret += "__template_"
first = True
for elem in self.template:
if first == True:
first = False
else:
ret += "_"
if len(elem) >= 2:
ret += elem[1]
else:
ret += elem[0]
ret += "__"
ret += '.html' ret += '.html'
return ret return ret

View File

@ -18,7 +18,13 @@ global_class_link = {
"std::u16string" : "http://www.cplusplus.com/reference/string/u16string/", "std::u16string" : "http://www.cplusplus.com/reference/string/u16string/",
"std::u32string" : "http://www.cplusplus.com/reference/string/u32string/", "std::u32string" : "http://www.cplusplus.com/reference/string/u32string/",
"std::wstring" : "http://www.cplusplus.com/reference/string/wstring/", "std::wstring" : "http://www.cplusplus.com/reference/string/wstring/",
"std::vector" : "http://www.cplusplus.com/reference/vector/vector/" "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/"
} }

View File

@ -0,0 +1,23 @@
namespace testMonk {
class ClassNormal {
public:
ClassNormal();
virtual ~ClassNormal();
};
class ClassHeritageSimple : public testMonk::ClassNormal {
public:
ClassHeritageSimple();
virtual ~ClassHeritageSimple();
};
class ClassHeritageDouble : public testMonk::ClassNormal, public testMonk::ClassHeritageSimple {
public:
ClassHeritageDouble();
virtual ~ClassHeritageDouble();
};
class ClassHeritagetemplate : public std::enable_shared_from_this<ClassHeritagetemplate> {
public:
ClassHeritagetemplate();
virtual ~ClassHeritagetemplate();
};
}

View File

@ -1,8 +1,14 @@
namespace testMonk { namespace testMonk {
template<typename T> class classTemplate { template<typename T> class ClassTemplate {
public: public:
classTemplate(); ClassTemplate();
~classTemplate(); ~ClassTemplate();
};
template<typename T, class T2> class ClassTemplateMultiple {
public:
ClassTemplateMultiple();
~ClassTemplateMultiple();
testMonk::ClassTemplate<classPlop> m_essay ponterClass
}; };
} }