[DEV] better display of operator and some other special case
This commit is contained in:
parent
b6c956edef
commit
13d1eb1cc6
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.pyc
|
59
README.md
Normal file
59
README.md
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
MONK
|
||||||
|
====
|
||||||
|
|
||||||
|
`Monk` is a generic dicumentation maker is a FREE software tool.
|
||||||
|
|
||||||
|
This is a tool to generate the binary and application static documentation.
|
||||||
|
It is designed to support the github gh-pages, the it is a no-server-side interaction.
|
||||||
|
|
||||||
|
|
||||||
|
Create a monk doc
|
||||||
|
=================
|
||||||
|
|
||||||
|
Set the monk module maker with the name :
|
||||||
|
monk_xxxxx.py
|
||||||
|
xxx : represent the name of the module/application and must be lower case and no special characters
|
||||||
|
|
||||||
|
you can see exemple for some type in :
|
||||||
|
ewol : library
|
||||||
|
edn : application
|
||||||
|
|
||||||
|
Build your documantation:
|
||||||
|
./monk.py
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (c)
|
||||||
|
=============
|
||||||
|
|
||||||
|
2011, Edouard DUPIN
|
||||||
|
|
||||||
|
License (DSB)
|
||||||
|
=============
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in
|
||||||
|
the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
|
||||||
|
3. The name of the author may not be used to endorse or promote
|
||||||
|
products derived from this software without specific prior
|
||||||
|
written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||||
|
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
32
licence_BSD.txt
Normal file
32
licence_BSD.txt
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
Copyright (c) 2011, Edouard DUPIN
|
||||||
|
|
||||||
|
License (DSB)
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in
|
||||||
|
the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
|
||||||
|
3. The name of the author may not be used to endorse or promote
|
||||||
|
products derived from this software without specific prior
|
||||||
|
written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||||
|
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.L
|
2
monk.py
2
monk.py
@ -76,7 +76,7 @@ def start():
|
|||||||
debug.warning("Can not understand argument : '" + argument.get_option_name() + "'")
|
debug.warning("Can not understand argument : '" + argument.get_option_name() + "'")
|
||||||
usage()
|
usage()
|
||||||
else:
|
else:
|
||||||
module = monkModule.get_module(argument.GetArg())
|
module = monkModule.get_module(argument.get_arg())
|
||||||
module.parse_code()
|
module.parse_code()
|
||||||
module.generate()
|
module.generate()
|
||||||
actionDone=True
|
actionDone=True
|
||||||
|
83
monkHtml.py
83
monkHtml.py
@ -15,50 +15,17 @@ global_class_link = {
|
|||||||
"std::vector" : "http://www.cplusplus.com/reference/vector/vector/"
|
"std::vector" : "http://www.cplusplus.com/reference/vector/vector/"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def display_color(val):
|
||||||
def replace_type(match):
|
|
||||||
value = "<span class=\"code-type\">" + match.group() + "</span>"
|
|
||||||
return value
|
|
||||||
|
|
||||||
def replace_storage_keyword(match):
|
|
||||||
value = "<span class=\"code-storage-keyword\">" + match.group() + "</span>"
|
|
||||||
return value
|
|
||||||
|
|
||||||
def display_color(valBase):
|
|
||||||
# storage keyword :
|
# storage keyword :
|
||||||
p = re.compile("(inline|const|class|virtual|private|public|protected|friend|const|extern|auto|register|static|volatile|typedef|struct|union|enum)")
|
val = re.sub(r'(inline|const|class|virtual|private|public|protected|friend|const|extern|auto|register|static|volatile|typedef|struct|union|enum)',
|
||||||
val = p.sub(replace_storage_keyword, valBase)
|
r'<span class="code-storage-keyword">\1</span>',
|
||||||
|
val)
|
||||||
# type :
|
# type :
|
||||||
p = re.compile("(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))")
|
val = re.sub(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))',
|
||||||
val = p.sub(replace_type, val)
|
r'<span class="code-type">\1</span>',
|
||||||
return val, len(valBase)
|
val)
|
||||||
|
return val
|
||||||
|
|
||||||
def display_type(type, myDoc):
|
|
||||||
type = type.replace("inline ", "")
|
|
||||||
lenght = 0;
|
|
||||||
isFirst = True
|
|
||||||
out = ''
|
|
||||||
# we split all the element in list sepa=rated with space to keep class... and standard c+ class
|
|
||||||
for element in type.split(' '):
|
|
||||||
if isFirst == False:
|
|
||||||
out += " "
|
|
||||||
lenght += 1
|
|
||||||
isFirst = False
|
|
||||||
# check if the element in internal at the current lib
|
|
||||||
name, link = myDoc.get_class_link(element)
|
|
||||||
if len(link) != 0:
|
|
||||||
out += "<a href=\"" + link + "\" class=\"code-type\">" + name + "</a>"
|
|
||||||
lenght += len(element)
|
|
||||||
# Ckeck if the variable in a standard class:
|
|
||||||
elif element in global_class_link.keys():
|
|
||||||
out += "<a href=\"" + global_class_link[element] + "\" class=\"code-type\">" + element + "</a>"
|
|
||||||
lenght += len(element)
|
|
||||||
else:
|
|
||||||
data, lenghtTmp = display_color(element)
|
|
||||||
out += data
|
|
||||||
lenght += lenghtTmp
|
|
||||||
# get every subelement class :
|
|
||||||
return [out,lenght]
|
|
||||||
|
|
||||||
def display_doxygen_param(comment, input, output):
|
def display_doxygen_param(comment, input, output):
|
||||||
data = "<b>Parameter"
|
data = "<b>Parameter"
|
||||||
@ -131,30 +98,6 @@ def white_space(size) :
|
|||||||
ret += " "
|
ret += " "
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def calsulateSizeFunction(function, size) :
|
|
||||||
if len(function["name"]) > size:
|
|
||||||
return len(function["name"])+1
|
|
||||||
return size
|
|
||||||
|
|
||||||
def calsulateSizeReturn(function, size) :
|
|
||||||
if len(function["rtnType"]) > size:
|
|
||||||
return len(function["rtnType"])+1
|
|
||||||
return size
|
|
||||||
|
|
||||||
|
|
||||||
def addSub(tree, filterSubNamespace=False):
|
|
||||||
return ""
|
|
||||||
|
|
||||||
|
|
||||||
# ##############################################################
|
|
||||||
# NEW function ...
|
|
||||||
# ##############################################################
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def generate_menu(element, namespaceStack=[], level=1):
|
def generate_menu(element, namespaceStack=[], level=1):
|
||||||
listBase = element.get_all_sub_type(['namespace'])
|
listBase = element.get_all_sub_type(['namespace'])
|
||||||
if len(listBase) == 0:
|
if len(listBase) == 0:
|
||||||
@ -228,9 +171,11 @@ def write_methode(element, namespaceStack, displaySize = None, link = True):
|
|||||||
if retType != "":
|
if retType != "":
|
||||||
retType2 = re.sub("<","<", retType)
|
retType2 = re.sub("<","<", retType)
|
||||||
retType2 = re.sub(">",">", retType2)
|
retType2 = re.sub(">",">", retType2)
|
||||||
|
retType2 = display_color(retType2)
|
||||||
ret += retType2
|
ret += retType2
|
||||||
ret += " "
|
ret += " "
|
||||||
ret += white_space(displaySize[0] - len(retType))
|
retType += " "
|
||||||
|
ret += white_space(displaySize[0] - len(retType)+1)
|
||||||
name = element['node'].get_name()
|
name = element['node'].get_name()
|
||||||
if link == True:
|
if link == True:
|
||||||
ret += '<a class="code-function" href="#' + str(element['node'].get_uid()) + '">' + name + '</a>'
|
ret += '<a class="code-function" href="#' + str(element['node'].get_uid()) + '">' + name + '</a>'
|
||||||
@ -244,7 +189,7 @@ def write_methode(element, namespaceStack, displaySize = None, link = True):
|
|||||||
ret += ',<br/>'
|
ret += ',<br/>'
|
||||||
ret += white_space(displaySize[0] + displaySize[1] +5)
|
ret += white_space(displaySize[0] + displaySize[1] +5)
|
||||||
first = False
|
first = False
|
||||||
retParam = param.get_type().to_str()
|
retParam = display_color(param.get_type().to_str())
|
||||||
if retParam != "":
|
if retParam != "":
|
||||||
ret += retParam
|
ret += retParam
|
||||||
ret += " "
|
ret += " "
|
||||||
@ -253,7 +198,7 @@ def write_methode(element, namespaceStack, displaySize = None, link = True):
|
|||||||
if element['node'].get_virtual_pure() == True:
|
if element['node'].get_virtual_pure() == True:
|
||||||
ret += ' = 0'
|
ret += ' = 0'
|
||||||
if element['node'].get_constant() == True:
|
if element['node'].get_constant() == True:
|
||||||
ret += ' const'
|
ret += display_color(' const')
|
||||||
|
|
||||||
ret += ';'
|
ret += ';'
|
||||||
ret += '<br/>'
|
ret += '<br/>'
|
||||||
@ -283,8 +228,6 @@ def generate_page(outFolder, header, footer, element, namespaceStack=[]):
|
|||||||
namespaceStack.pop()
|
namespaceStack.pop()
|
||||||
else:
|
else:
|
||||||
generate_page(outFolder, header, footer, elem['node'], namespaceStack)
|
generate_page(outFolder, header, footer, elem['node'], namespaceStack)
|
||||||
|
|
||||||
|
|
||||||
filename = outFolder + '/' + generate_html_page_name(element, namespaceStack)
|
filename = outFolder + '/' + generate_html_page_name(element, namespaceStack)
|
||||||
monkTools.create_directory_of_file(filename);
|
monkTools.create_directory_of_file(filename);
|
||||||
file = open(filename, "w")
|
file = open(filename, "w")
|
||||||
|
@ -5,7 +5,7 @@ import monkType as Type
|
|||||||
import monkVariable as Variable
|
import monkVariable as Variable
|
||||||
|
|
||||||
class Methode(Node.Node):
|
class Methode(Node.Node):
|
||||||
def __init__(self, stack=[], file="", lineNumber=0, documentation=[]):
|
def __init__(self, stack=[], file="", lineNumber=0, documentation=[], className = ""):
|
||||||
name = ""
|
name = ""
|
||||||
type = 'methode'
|
type = 'methode'
|
||||||
self.virtual = False
|
self.virtual = False
|
||||||
@ -44,7 +44,7 @@ class Methode(Node.Node):
|
|||||||
|
|
||||||
namePos = -1
|
namePos = -1
|
||||||
|
|
||||||
debug.verbose("methode parse : " + str(stack))
|
debug.debug("methode parse : " + str(stack))
|
||||||
for iii in range(0, len(stack)-2):
|
for iii in range(0, len(stack)-2):
|
||||||
if stack[iii+1] == '(':
|
if stack[iii+1] == '(':
|
||||||
name = stack[iii]
|
name = stack[iii]
|
||||||
@ -52,12 +52,14 @@ class Methode(Node.Node):
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if namePos == 0:
|
if namePos == 0:
|
||||||
debug.verbose("start with '" + str(name[0]) + "'")
|
debug.debug("start with '" + str(name[0]) + "'")
|
||||||
if name[0] == '~':
|
if name[0] == '~':
|
||||||
type = 'destructor'
|
if className == name[1:]:
|
||||||
|
type = 'destructor'
|
||||||
else:
|
else:
|
||||||
type = 'constructor'
|
if className == name:
|
||||||
debug.verbose("methode name : " + name)
|
type = 'constructor'
|
||||||
|
debug.debug("methode name : " + name)
|
||||||
Node.Node.__init__(self, type, name, file, lineNumber, documentation)
|
Node.Node.__init__(self, type, name, file, lineNumber, documentation)
|
||||||
|
|
||||||
self.returnType = Type.TypeNone()
|
self.returnType = Type.TypeNone()
|
||||||
@ -65,11 +67,11 @@ class Methode(Node.Node):
|
|||||||
|
|
||||||
# create the return Type (Can be Empty)
|
# create the return Type (Can be Empty)
|
||||||
retTypeStack = stack[:namePos]
|
retTypeStack = stack[:namePos]
|
||||||
debug.verbose("return : " + str(retTypeStack))
|
debug.debug("return : " + str(retTypeStack))
|
||||||
self.returnType = Type.Type(retTypeStack)
|
self.returnType = Type.Type(retTypeStack)
|
||||||
|
|
||||||
parameterStack = stack[namePos+2:len(stack)-1]
|
parameterStack = stack[namePos+2:len(stack)-1]
|
||||||
debug.verbose("parameter : " + str(parameterStack))
|
debug.debug("parameter : " + str(parameterStack))
|
||||||
paramTmp = []
|
paramTmp = []
|
||||||
braceOpen = 0
|
braceOpen = 0
|
||||||
for element in parameterStack:
|
for element in parameterStack:
|
||||||
|
16
monkParse.py
16
monkParse.py
@ -200,13 +200,15 @@ def create_compleate_class_name(table):
|
|||||||
for name in table:
|
for name in table:
|
||||||
if len(out) == 0:
|
if len(out) == 0:
|
||||||
out.append(name)
|
out.append(name)
|
||||||
elif name in ['<','>','='] \
|
elif out[-1][:8] == 'operator' \
|
||||||
and out[-1][:8] == 'operator' \
|
and name != '(':
|
||||||
and len(out[-1])-8 < 2:
|
if out[-1] == 'operator':
|
||||||
|
out[-1] += ' '
|
||||||
|
if out[-1][-1] not in [' ', '<','>','=', '-', '!', '+', '*', '&', '|', '/']:
|
||||||
|
out[-1] += ' '
|
||||||
out[-1] += name
|
out[-1] += name
|
||||||
else:
|
else:
|
||||||
out.append(name)
|
out.append(name)
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
@ -282,6 +284,7 @@ class parse_file():
|
|||||||
self.subModuleCountBrace -= 1
|
self.subModuleCountBrace -= 1
|
||||||
if self.subModuleCountBrace <= 0:
|
if self.subModuleCountBrace <= 0:
|
||||||
self.brace_type_pop()
|
self.brace_type_pop()
|
||||||
|
self.lastComment = []
|
||||||
continue
|
continue
|
||||||
# normal case:
|
# normal case:
|
||||||
if tok.type == 'PRECOMP':
|
if tok.type == 'PRECOMP':
|
||||||
@ -433,7 +436,10 @@ class parse_file():
|
|||||||
ret = Union.Union(stack, self.headerFileName, self.curLine, self.lastComment)
|
ret = Union.Union(stack, self.headerFileName, self.curLine, self.lastComment)
|
||||||
elif type == 'function':
|
elif type == 'function':
|
||||||
#debug.info(str(self.lastComment))
|
#debug.info(str(self.lastComment))
|
||||||
ret = Methode.Methode(stack, self.headerFileName, self.curLine, self.lastComment)
|
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())
|
||||||
|
else:
|
||||||
|
ret = Methode.Methode(stack, self.headerFileName, self.curLine, self.lastComment)
|
||||||
elif type == 'enum':
|
elif type == 'enum':
|
||||||
ret = Enum.Enum(stack, self.headerFileName, self.curLine, self.lastComment)
|
ret = Enum.Enum(stack, self.headerFileName, self.curLine, self.lastComment)
|
||||||
elif type == 'variable':
|
elif type == 'variable':
|
||||||
|
@ -7,6 +7,7 @@ class Variable(Node.Node):
|
|||||||
def __init__(self, stack=[], file="", lineNumber=0, documentation=[]):
|
def __init__(self, stack=[], file="", lineNumber=0, documentation=[]):
|
||||||
debug.debug("Parse variable : " + str(stack))
|
debug.debug("Parse variable : " + str(stack))
|
||||||
name = ""
|
name = ""
|
||||||
|
type = []
|
||||||
if '=' in stack:
|
if '=' in stack:
|
||||||
plop = []
|
plop = []
|
||||||
for element in stack:
|
for element in stack:
|
||||||
@ -26,14 +27,12 @@ class Variable(Node.Node):
|
|||||||
stack = res
|
stack = res
|
||||||
|
|
||||||
if len(stack) < 2:
|
if len(stack) < 2:
|
||||||
if stack[0] == 'void':
|
type = stack
|
||||||
pass
|
|
||||||
else:
|
|
||||||
debug.error("Can not parse variable : " + str(stack))
|
|
||||||
else:
|
else:
|
||||||
name = stack[len(stack)-1]
|
name = stack[len(stack)-1]
|
||||||
|
type = stack[:len(stack)-1]
|
||||||
|
|
||||||
Node.Node.__init__(self, 'variable', stack[len(stack)-1], file, lineNumber, documentation)
|
Node.Node.__init__(self, 'variable', name, file, lineNumber, documentation)
|
||||||
# force the sublist error generation ...
|
# force the sublist error generation ...
|
||||||
self.subList = None
|
self.subList = None
|
||||||
# default variable :
|
# default variable :
|
||||||
@ -41,21 +40,18 @@ class Variable(Node.Node):
|
|||||||
self.static = False
|
self.static = False
|
||||||
self.external = False
|
self.external = False
|
||||||
self.volatile = False
|
self.volatile = False
|
||||||
#empty name ... ==> this is really bad ...
|
|
||||||
if name == "":
|
|
||||||
return
|
|
||||||
|
|
||||||
if 'static' in stack:
|
if 'static' in type:
|
||||||
self.static = True
|
self.static = True
|
||||||
stack = [value for value in stack if value != 'static']
|
type = [value for value in type if value != 'static']
|
||||||
if 'volatile' in stack:
|
if 'volatile' in stack:
|
||||||
self.volatile = True
|
self.volatile = True
|
||||||
stack = [value for value in stack if value != 'volatile']
|
type = [value for value in type if value != 'volatile']
|
||||||
if 'external' in stack:
|
if 'external' in stack:
|
||||||
self.external = True
|
self.external = True
|
||||||
stack = [value for value in stack if value != 'external']
|
type = [value for value in type if value != 'external']
|
||||||
|
|
||||||
self.type = Type.Type(stack[:len(stack)-1])
|
self.type = Type.Type(type)
|
||||||
|
|
||||||
debug.verbose("find variable : " + self.to_str())
|
debug.verbose("find variable : " + self.to_str())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user