[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() + "'")
|
||||
usage()
|
||||
else:
|
||||
module = monkModule.get_module(argument.GetArg())
|
||||
module = monkModule.get_module(argument.get_arg())
|
||||
module.parse_code()
|
||||
module.generate()
|
||||
actionDone=True
|
||||
|
83
monkHtml.py
83
monkHtml.py
@ -15,50 +15,17 @@ global_class_link = {
|
||||
"std::vector" : "http://www.cplusplus.com/reference/vector/vector/"
|
||||
}
|
||||
|
||||
|
||||
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):
|
||||
def display_color(val):
|
||||
# storage keyword :
|
||||
p = re.compile("(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)
|
||||
val = re.sub(r'(inline|const|class|virtual|private|public|protected|friend|const|extern|auto|register|static|volatile|typedef|struct|union|enum)',
|
||||
r'<span class="code-storage-keyword">\1</span>',
|
||||
val)
|
||||
# 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 = p.sub(replace_type, val)
|
||||
return val, len(valBase)
|
||||
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))',
|
||||
r'<span class="code-type">\1</span>',
|
||||
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):
|
||||
data = "<b>Parameter"
|
||||
@ -131,30 +98,6 @@ def white_space(size) :
|
||||
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):
|
||||
listBase = element.get_all_sub_type(['namespace'])
|
||||
if len(listBase) == 0:
|
||||
@ -228,9 +171,11 @@ def write_methode(element, namespaceStack, displaySize = None, link = True):
|
||||
if retType != "":
|
||||
retType2 = re.sub("<","<", retType)
|
||||
retType2 = re.sub(">",">", retType2)
|
||||
retType2 = display_color(retType2)
|
||||
ret += retType2
|
||||
ret += " "
|
||||
ret += white_space(displaySize[0] - len(retType))
|
||||
retType += " "
|
||||
ret += white_space(displaySize[0] - len(retType)+1)
|
||||
name = element['node'].get_name()
|
||||
if link == True:
|
||||
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 += white_space(displaySize[0] + displaySize[1] +5)
|
||||
first = False
|
||||
retParam = param.get_type().to_str()
|
||||
retParam = display_color(param.get_type().to_str())
|
||||
if retParam != "":
|
||||
ret += retParam
|
||||
ret += " "
|
||||
@ -253,7 +198,7 @@ def write_methode(element, namespaceStack, displaySize = None, link = True):
|
||||
if element['node'].get_virtual_pure() == True:
|
||||
ret += ' = 0'
|
||||
if element['node'].get_constant() == True:
|
||||
ret += ' const'
|
||||
ret += display_color(' const')
|
||||
|
||||
ret += ';'
|
||||
ret += '<br/>'
|
||||
@ -283,8 +228,6 @@ def generate_page(outFolder, header, footer, element, namespaceStack=[]):
|
||||
namespaceStack.pop()
|
||||
else:
|
||||
generate_page(outFolder, header, footer, elem['node'], namespaceStack)
|
||||
|
||||
|
||||
filename = outFolder + '/' + generate_html_page_name(element, namespaceStack)
|
||||
monkTools.create_directory_of_file(filename);
|
||||
file = open(filename, "w")
|
||||
|
@ -5,7 +5,7 @@ import monkType as Type
|
||||
import monkVariable as Variable
|
||||
|
||||
class Methode(Node.Node):
|
||||
def __init__(self, stack=[], file="", lineNumber=0, documentation=[]):
|
||||
def __init__(self, stack=[], file="", lineNumber=0, documentation=[], className = ""):
|
||||
name = ""
|
||||
type = 'methode'
|
||||
self.virtual = False
|
||||
@ -44,7 +44,7 @@ class Methode(Node.Node):
|
||||
|
||||
namePos = -1
|
||||
|
||||
debug.verbose("methode parse : " + str(stack))
|
||||
debug.debug("methode parse : " + str(stack))
|
||||
for iii in range(0, len(stack)-2):
|
||||
if stack[iii+1] == '(':
|
||||
name = stack[iii]
|
||||
@ -52,12 +52,14 @@ class Methode(Node.Node):
|
||||
break;
|
||||
|
||||
if namePos == 0:
|
||||
debug.verbose("start with '" + str(name[0]) + "'")
|
||||
debug.debug("start with '" + str(name[0]) + "'")
|
||||
if name[0] == '~':
|
||||
type = 'destructor'
|
||||
if className == name[1:]:
|
||||
type = 'destructor'
|
||||
else:
|
||||
type = 'constructor'
|
||||
debug.verbose("methode name : " + name)
|
||||
if className == name:
|
||||
type = 'constructor'
|
||||
debug.debug("methode name : " + name)
|
||||
Node.Node.__init__(self, type, name, file, lineNumber, documentation)
|
||||
|
||||
self.returnType = Type.TypeNone()
|
||||
@ -65,11 +67,11 @@ class Methode(Node.Node):
|
||||
|
||||
# create the return Type (Can be Empty)
|
||||
retTypeStack = stack[:namePos]
|
||||
debug.verbose("return : " + str(retTypeStack))
|
||||
debug.debug("return : " + str(retTypeStack))
|
||||
self.returnType = Type.Type(retTypeStack)
|
||||
|
||||
parameterStack = stack[namePos+2:len(stack)-1]
|
||||
debug.verbose("parameter : " + str(parameterStack))
|
||||
debug.debug("parameter : " + str(parameterStack))
|
||||
paramTmp = []
|
||||
braceOpen = 0
|
||||
for element in parameterStack:
|
||||
|
16
monkParse.py
16
monkParse.py
@ -200,13 +200,15 @@ def create_compleate_class_name(table):
|
||||
for name in table:
|
||||
if len(out) == 0:
|
||||
out.append(name)
|
||||
elif name in ['<','>','='] \
|
||||
and out[-1][:8] == 'operator' \
|
||||
and len(out[-1])-8 < 2:
|
||||
elif out[-1][:8] == 'operator' \
|
||||
and name != '(':
|
||||
if out[-1] == 'operator':
|
||||
out[-1] += ' '
|
||||
if out[-1][-1] not in [' ', '<','>','=', '-', '!', '+', '*', '&', '|', '/']:
|
||||
out[-1] += ' '
|
||||
out[-1] += name
|
||||
else:
|
||||
out.append(name)
|
||||
|
||||
return out
|
||||
|
||||
|
||||
@ -282,6 +284,7 @@ class parse_file():
|
||||
self.subModuleCountBrace -= 1
|
||||
if self.subModuleCountBrace <= 0:
|
||||
self.brace_type_pop()
|
||||
self.lastComment = []
|
||||
continue
|
||||
# normal case:
|
||||
if tok.type == 'PRECOMP':
|
||||
@ -433,7 +436,10 @@ class parse_file():
|
||||
ret = Union.Union(stack, self.headerFileName, self.curLine, self.lastComment)
|
||||
elif type == 'function':
|
||||
#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':
|
||||
ret = Enum.Enum(stack, self.headerFileName, self.curLine, self.lastComment)
|
||||
elif type == 'variable':
|
||||
|
@ -7,6 +7,7 @@ class Variable(Node.Node):
|
||||
def __init__(self, stack=[], file="", lineNumber=0, documentation=[]):
|
||||
debug.debug("Parse variable : " + str(stack))
|
||||
name = ""
|
||||
type = []
|
||||
if '=' in stack:
|
||||
plop = []
|
||||
for element in stack:
|
||||
@ -26,14 +27,12 @@ class Variable(Node.Node):
|
||||
stack = res
|
||||
|
||||
if len(stack) < 2:
|
||||
if stack[0] == 'void':
|
||||
pass
|
||||
else:
|
||||
debug.error("Can not parse variable : " + str(stack))
|
||||
type = stack
|
||||
else:
|
||||
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 ...
|
||||
self.subList = None
|
||||
# default variable :
|
||||
@ -41,21 +40,18 @@ class Variable(Node.Node):
|
||||
self.static = False
|
||||
self.external = False
|
||||
self.volatile = False
|
||||
#empty name ... ==> this is really bad ...
|
||||
if name == "":
|
||||
return
|
||||
|
||||
if 'static' in stack:
|
||||
if 'static' in type:
|
||||
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:
|
||||
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:
|
||||
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())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user