[DEV] update documantation generator
This commit is contained in:
parent
449652f589
commit
9b9a5d3237
55
monkClass.py
55
monkClass.py
@ -13,6 +13,21 @@ def concatenate_template(list):
|
||||
# TODO ...
|
||||
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):
|
||||
def __init__(self, stack=[], file="", lineNumber=0, documentation=[]):
|
||||
# check input :
|
||||
@ -20,20 +35,31 @@ class Class(Node.Node):
|
||||
debug.error("Can not parse class : " + str(stack))
|
||||
return
|
||||
#check if it is a template class:
|
||||
templateDeclatation = []
|
||||
if stack[0] == "template":
|
||||
debug.debug("find a template class: " + str(stack))
|
||||
#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:]
|
||||
stack = stack[stack.index("class"):]
|
||||
templateDeclatation = splitList(propertyTemplate)
|
||||
stack = stack[idEnd+1:]
|
||||
# TODO : add the template properties back ...
|
||||
debug.debug("template property : " + str(propertyTemplate))
|
||||
else:
|
||||
self.template = []
|
||||
debug.debug("template property : " + str(templateDeclatation))
|
||||
if len(stack) < 2:
|
||||
debug.error("Can not parse class 2 : " + str(stack))
|
||||
return
|
||||
Node.Node.__init__(self, 'class', stack[1], file, lineNumber, documentation)
|
||||
self.template = templateDeclatation
|
||||
self.subList = []
|
||||
self.access = "private"
|
||||
# heritage list :
|
||||
@ -74,13 +100,24 @@ class Class(Node.Node):
|
||||
list = concatenate_template(stack[3:])
|
||||
debug.verbose("inherit : " + str(list))
|
||||
access = "private"
|
||||
classProperty = []
|
||||
for element in list:
|
||||
if element in ['private', 'protected', 'public']:
|
||||
access = element
|
||||
elif element == ',':
|
||||
pass
|
||||
concatenate = ""
|
||||
for classProp in classProperty:
|
||||
concatenate += classProp
|
||||
self.inherit.append({'access' : access, 'class' : concatenate})
|
||||
classProperty = []
|
||||
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())
|
||||
|
||||
@ -105,11 +142,11 @@ class Class(Node.Node):
|
||||
parent = module.get_element_with_name(self.inherit[0]['class'])
|
||||
cparent = []
|
||||
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()
|
||||
pass
|
||||
#heritage = parent.
|
||||
cparent.append(self.inherit[0])
|
||||
cparent.append(self.inherit)
|
||||
return cparent
|
||||
|
||||
def get_whith_specific_parrent(self, parrentName):
|
||||
|
83
monkHtml.py
83
monkHtml.py
@ -9,6 +9,21 @@ import collections
|
||||
import monkModule as module
|
||||
import monkNode as node
|
||||
|
||||
htmlCodes = (
|
||||
('&', '&'),
|
||||
("'", '''),
|
||||
('"', '"'),
|
||||
('>', '>'),
|
||||
('<', '<')
|
||||
)
|
||||
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):
|
||||
data = '<tr>'
|
||||
@ -143,11 +158,11 @@ def calculate_methode_size(list):
|
||||
methodeSize = 0;
|
||||
haveVirtual = False
|
||||
for element in list:
|
||||
if ( element['node'].get_node_type() == 'methode' \
|
||||
or element['node'].get_node_type() == 'constructor' \
|
||||
or element['node'].get_node_type() == 'desctructor') \
|
||||
and element['node'].get_virtual() == True:
|
||||
haveVirtual = True
|
||||
if element['node'].get_node_type() == 'methode' \
|
||||
or element['node'].get_node_type() == 'constructor' \
|
||||
or element['node'].get_node_type() == 'destructor':
|
||||
if element['node'].get_virtual() == True:
|
||||
haveVirtual = True
|
||||
if element['node'].get_node_type() == 'variable':
|
||||
retType = element['node'].get_type().to_str()
|
||||
else:
|
||||
@ -365,44 +380,52 @@ def generate_page(outFolder, header, footer, element):
|
||||
|
||||
# generate herirage list :
|
||||
if element.get_node_type() == 'class':
|
||||
parent = element.get_parents()
|
||||
debug.verbose("parrent of " + element.get_name() + " : " + str(parent))
|
||||
parentAll = element.get_parents()
|
||||
debug.verbose("parrent of " + element.get_name() + " : " + str(parentAll))
|
||||
child = module.get_whith_specific_parrent(element.get_displayable_name(), )
|
||||
if len(parent) != 0 \
|
||||
if len(parentAll) != 0 \
|
||||
or len(child) != 0:
|
||||
file.write('<h2>Object Hierarchy:<h2>\n')
|
||||
file.write('<pre>\n');
|
||||
level = 0
|
||||
parent.append({'access':'me', 'class':element.get_displayable_name()})
|
||||
for parentElem in parent:
|
||||
access = ""
|
||||
if parentElem['access'] == 'public':
|
||||
access = "+"
|
||||
elif parentElem['access'] == 'protected':
|
||||
access = "#"
|
||||
elif parentElem['access'] == 'private':
|
||||
access = "-"
|
||||
tmpLen = level * 7
|
||||
if tmpLen > 0:
|
||||
tmpLen -= 5
|
||||
file.write(white_space(tmpLen))
|
||||
if level != 0:
|
||||
file.write('+--> ')
|
||||
file.write(access)
|
||||
if parentElem['access'] == 'me':
|
||||
file.write(parentElem['class'])
|
||||
else:
|
||||
for parent in parentAll:
|
||||
for parentElem in parent:
|
||||
access = ""
|
||||
if parentElem['access'] == 'public':
|
||||
access = "+"
|
||||
elif parentElem['access'] == 'protected':
|
||||
access = "#"
|
||||
elif parentElem['access'] == 'private':
|
||||
access = "-"
|
||||
tmpLen = level * 7
|
||||
if tmpLen > 0:
|
||||
tmpLen -= 5
|
||||
file.write(white_space(tmpLen))
|
||||
if level != 0:
|
||||
file.write('+--> ')
|
||||
file.write(access)
|
||||
classPointer = module.get_element_with_name(parentElem['class'])
|
||||
if classPointer != None:
|
||||
link = classPointer.get_doc_website_page()
|
||||
link = node.get_doc_website_page_relative(currentPageSite, 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:
|
||||
file.write('</a>')
|
||||
|
||||
file.write('<br/>')
|
||||
|
||||
file.write('<br/>')
|
||||
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 :
|
||||
for childElem in child:
|
||||
tmpLen = level * 7
|
||||
|
33
monkNode.py
33
monkNode.py
@ -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.hiddenRequest = False # @not-in-doc
|
||||
self.previousRequest = False # @previous
|
||||
self.template = []
|
||||
self.add_doc(documentation)
|
||||
|
||||
def to_str(self):
|
||||
@ -42,7 +43,22 @@ class Node():
|
||||
return self.nodeType
|
||||
|
||||
def get_name(self):
|
||||
return self.name
|
||||
ret = ""
|
||||
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 += self.name
|
||||
return ret
|
||||
|
||||
def get_UID(self):
|
||||
return self.uid
|
||||
@ -108,7 +124,7 @@ class Node():
|
||||
return ""
|
||||
|
||||
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:
|
||||
continue
|
||||
heveMethode, pointerMethode = element.have_methode(self.name)
|
||||
@ -233,6 +249,19 @@ class Node():
|
||||
ret += "NO_NAME_" + str(self.uid)
|
||||
else:
|
||||
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'
|
||||
return ret
|
||||
|
||||
|
@ -18,7 +18,13 @@ global_class_link = {
|
||||
"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::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/"
|
||||
}
|
||||
|
||||
|
||||
|
23
test/class.h
23
test/class.h
@ -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();
|
||||
};
|
||||
}
|
@ -1,8 +1,14 @@
|
||||
|
||||
namespace testMonk {
|
||||
template<typename T> class classTemplate {
|
||||
template<typename T> class ClassTemplate {
|
||||
public:
|
||||
classTemplate();
|
||||
~classTemplate();
|
||||
ClassTemplate();
|
||||
~ClassTemplate();
|
||||
};
|
||||
template<typename T, class T2> class ClassTemplateMultiple {
|
||||
public:
|
||||
ClassTemplateMultiple();
|
||||
~ClassTemplateMultiple();
|
||||
testMonk::ClassTemplate<classPlop> m_essay ponterClass
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user