[DEV] generated code is now usable

This commit is contained in:
Edouard DUPIN 2013-12-27 21:35:30 +01:00
parent 378ba0b8fa
commit 7d217467dc
8 changed files with 360 additions and 143 deletions

View File

@ -83,6 +83,11 @@ def transcode(value):
value,
flags=re.DOTALL)
value = re.sub(r'\[note\](.*?)\[/note\]',
r'<br/><b>Note:</b><pre>\1</pre>',
value,
flags=re.DOTALL)
value = re.sub(r'____(.*?)\n',
r'<hr>',
value,

View File

@ -4,6 +4,33 @@ import sys
import monkTools
import re
listRegExp = [
[ r'&lt;!\-\-!(.*?)\-\-&gt;', 'code-doxygen'],
[ r'&lt;!\-\-(.*?)\-\-&gt;', 'code-comment'],
[ r'"((\\"|.)*?)"', 'code-text-quote'],
[ r"'(('|.)*?)'", 'code-text-quote'],
[ r'&lt;/[0-9a-zA-Z_]+|&lt;[0-9a-zA-Z_]+|/&gt;|&gt;',
'code-function-name']
]
def transcode(value):
return value
inValue = value
outValue = ""
haveFindSomething = False;
for reg1, color in listRegExp:
result = re.search(reg1, inValue, re.DOTALL)
while result != None:
haveFindSomething = True
# sub parse the start :
outValue += transcode(inValue[:result.start()])
# transform local
outValue += '<span class="' + color + '">'
outValue += result.group()
outValue += '</span>'
# change the input value
inValue = inValue[result.end():]
# Search again ...
result = re.search(reg1, inValue, re.DOTALL)
outValue += inValue
return outValue

View File

@ -11,20 +11,27 @@ import monkNode as node
def display_doxygen_param(comment, input, output):
data = "<b>Parameter"
data = '<tr>'
data = '<td>'
data += "<b>Parameter"
if input == True:
data += " [input]"
if output == True:
data += " [output]"
data += ":</b> "
data += ":</b>"
data += '</td>'
#extract first element:
val = comment.find(" ")
var = comment[:val]
endComment = comment[val:]
data += '<td>'
# TODO : Check if it exist in the parameter list ...
data += "<span class=\"code-argument\">" + var + "</span> " + endComment
data += "<br/>"
data += "<span class=\"code-argument\">" + var + "</span> "
data += '</td>'
data += '<td>'
data += codeBB.transcode(endComment)
data += '</td>'
data += '</tr>\n'
return data
@ -40,8 +47,8 @@ def parse_doxygen(data) :
# nothing to do : Nomale case of the first \n
None
elif element[:6] == "brief ":
data2 += element[6:]
data2 += "<br/>"
data2 += codeBB.transcode(element[6:])
data2 += '<br/>'
for element in streams:
if element[:1] == "\n" \
@ -49,11 +56,12 @@ def parse_doxygen(data) :
# nothing to do : Nomale case of the first \n
None
elif element[:5] == "note ":
data2 += "<b>Notes:</b> "
data2 += element[5:]
data2 += "<br/> "
data2 += '<b>Note:</b> '
data2 += codeBB.transcode(element[5:])
data2 += '<br/> '
data3 = ''
dataReturn = ''
for element in streams:
if element[:1] == "\n" \
or element[:2] == "\n\n":
@ -69,13 +77,22 @@ def parse_doxygen(data) :
elif element[:6] == "param ":
data3 += display_doxygen_param(element[6:], False, False)
elif element[:7] == "return ":
data3 += "<b>Return:</b> "
data3 += element[7:]
data3 += "<br/>"
if data3 != '':
data2 += "<ul>\n"
if dataReturn != "":
dataReturn += '<br/>'
dataReturn += element[7:]
if data3 != '' \
or dataReturn != '':
data2 += '<ul>\n'
data2 += '<table class="parameter-list">\n'
data2 += data3
data2 += "</ul>\n"
if dataReturn != "":
data2 += '<tr><td>'
data2 += '<b>Return: </b>'
data2 += '</td><td></td><td>'
data2 += codeBB.transcode(dataReturn)
data2 += '</td></tr>'
data2 += '</table>\n'
data2 += '</ul>\n'
return data2
def white_space(size) :
@ -135,6 +152,8 @@ def calculate_methode_size(list):
def write_methode(element, namespaceStack, displaySize = None, link = True):
if element['node'].get_request_hidden() == True:
return
if displaySize == None:
displaySize = calculate_methode_size([element])
ret = ""
@ -337,15 +356,34 @@ def generate_page(outFolder, header, footer, element):
if len(listBase) != 0:
# display all functions :
file.write('<h2>Detail:</h2>\n')
allDetailDoc = ""
lastDoc = ""
for subElement in listBase:
file.write('<h3><a id="' + str(subElement['node'].get_uid()) + '">' + subElement['node'].get_name() + '</a></h3>')
file.write('<pre>\n');
file.write(write_methode(subElement, namespaceStack, link = False))
file.write('</pre>\n');
#debug.info(str(element['node'].get_doc()));
file.write(parse_doxygen(subElement['node'].get_doc()));
file.write('<br/>\n');
file.write('<hr/>\n');
file.write('<a id="' + str(subElement['node'].get_uid()) + '"/>')
if lastDoc != "" \
and subElement['node'].get_request_in_previous() == True:
allDetailDoc += write_methode(subElement, namespaceStack, link = False)
else:
if lastDoc != "":
allDetailDoc += '</pre>\n'
allDetailDoc += lastDoc
allDetailDoc += '<br/>\n'
allDetailDoc += '<hr/>\n'
file.write(allDetailDoc);
allDetailDoc = ""
lastDoc = ""
allDetailDoc += '<h3>' + subElement['node'].get_name() + '</h3>'
allDetailDoc += '<pre>\n'
allDetailDoc += write_methode(subElement, namespaceStack, link = False)
lastDoc = parse_doxygen(subElement['node'].get_doc()) + '\n'
if lastDoc != "":
allDetailDoc += '</pre>\n'
allDetailDoc += lastDoc
allDetailDoc += '<br/>\n'
allDetailDoc += '<hr/>\n'
file.write(allDetailDoc);
allDetailDoc = ""
lastDoc = ""
if element.get_node_type() == 'enum':
myElementList = element.get_enum_list()
@ -420,12 +458,71 @@ def generate(myLutinDoc, outFolder) :
genericHeader += '<body>\n'
genericHeader += ' <div class="navbar navbar-fixed-top">\n'
genericHeader += ' <div class="container">\n'
genericHeader += ' <h1>' + myDoc.get_name() + ' Library</h1>\n'
if myDoc.get_node_type() == 'library':
genericHeader += ' <h1><a href="index.html">' + myDoc.get_name() + ' library</a></h1>\n'
else:
genericHeader += ' <h1><a href="index.html">' + myDoc.get_name() + '</a></h1>\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'
# TODO : add Generic doc main point.
if len(myLutinDoc.listDocFile) > 0:
genericHeader += '<h3>Documentation:</h3>'
genericHeader += '<div id="menu">\n'
for docInputName,outpath in myLutinDoc.listDocFile:
outputFileName = outFolder + "/" + outpath.replace('/','_') +".html"
outputFileName = outputFileName.split('/')[-1]
name = outputFileName.split('_')[-1][:-5]
if name == "index":
continue
genericHeader += '<ul class="niveau1">'
genericHeader += '<li><a href="' + outputFileName + '">' + name + '</a></li>\n'
genericHeader += '</ul>'
genericHeader += '</div>\n'
# TODO : add Tutorial doc main point.
if len(myLutinDoc.listTutorialFile) > 0:
genericHeader += '<h3>Tutorials:</h3>'
genericHeader += '<div id="menu">\n'
for docInputName,outpath in myLutinDoc.listTutorialFile:
outputFileName = outFolder + "/" + outpath+".html"
outputFileName = outputFileName.split('/')[-1]
name = outputFileName.split('_')[-1][:-5]
if name == "index":
continue
genericHeader += '<ul class="niveau1">'
genericHeader += '<li><a href="tutorial_' + outputFileName + '">' + name + '</a></li>\n'
genericHeader += '</ul>'
genericHeader += '</div>\n'
localWebsite = myLutinDoc.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'
for modd in allModule:
if modd.type == 'application':
continue
if modd.name == myLutinDoc.name:
continue
genericHeader += '<ul class="niveau1">'
link = node.get_doc_website_page_relative(localWebsite, modd.get_website())
if 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"
@ -440,7 +537,7 @@ def generate(myLutinDoc, outFolder) :
# create the namespace index properties :
generate_page(outFolder, genericHeader, genericFooter, myDoc)
for docInputName,outpath in myLutinDoc.listDocFile :
for docInputName,outpath in myLutinDoc.listTutorialFile :
debug.print_element("doc", myLutinDoc.name, "<==", docInputName)
outputFileName = outFolder + "/" + outpath.replace('/','_') +".html"
debug.debug("output file : " + outputFileName)
@ -451,9 +548,9 @@ def generate(myLutinDoc, outFolder) :
outData = genericHeader + codeBB.transcode(inData) + genericFooter
monkTools.file_write_data(outputFileName, outData)
for docInputName,outpath in myLutinDoc.listTutorialFile :
for docInputName,outpath in myLutinDoc.listDocFile :
debug.print_element("tutorial", myLutinDoc.name, "<==", docInputName)
outputFileName = outFolder + "/" + outpath+".html"
outputFileName = outFolder + outpath + ".html"
debug.debug("output file : " + outputFileName)
monkTools.create_directory_of_file(outputFileName)
inData = monkTools.file_read_data(docInputName)

View File

@ -126,9 +126,9 @@ class Module:
debug.verbose(" Find a doc file : '" + fileCompleteName + "'")
pathBase = fileCompleteName[len(self.pathGlobalDoc):len(fileCompleteName)-3]
if fileCompleteName[:len(tutorialPath)] == tutorialPath:
self.add_file_doc(fileCompleteName, pathBase)
else:
self.add_tutorial_doc(fileCompleteName, pathBase)
else:
self.add_file_doc(fileCompleteName, pathBase)
##
## @brief Add a documentation file at the parsing system

View File

@ -17,7 +17,7 @@ class Node():
global genericUID
genericUID+=1
self.uid = genericUID
self.documenatationCode = documentation
self.documenatationCode = []
self.nodeType = type
self.name = name
self.doc = None
@ -28,6 +28,9 @@ class Node():
# 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.add_doc(documentation)
def to_str(self):
return ""
@ -41,6 +44,22 @@ class Node():
def get_name(self):
return self.name
def add_doc(self, doc):
for element in doc:
self.documenatationCode.append(element)
if element.find("@not-in-doc") != -1 :
self.hiddenRequest = True
if element.find("@previous") != -1 :
self.previousRequest = True
def get_request_hidden(self):
return self.hiddenRequest
def get_request_in_previous(self):
return self.previousRequest
def get_displayable_name(self):
ret = ""
for namespace in self.namespace:
@ -62,7 +81,8 @@ class Node():
isFirst = False
ret += req
return ret
if self.nodeType not in ['methode']:
return ""
#try to get previous element :
if len(self.namespace) == 0:
return ""

View File

@ -55,14 +55,15 @@ body {
text-shadow: 0 1px 0 #ce4213;
padding: 10px 20px 10px;
margin-left: -20px;
//overflow:scroll;
//overflow-x:hidden;
overflow:scroll;
overflow-y:auto;
overflow-x:hidden;
}
/*
.navbar ul {
font-size: 15px;
};
*/
.navbar-fixed-top a {
text-decoration: none;
color: #000000;
}
h1, h2, h3, h4, h5, h6 {
display: block;
margin: 10px 0;
@ -100,6 +101,11 @@ pre {
padding-right:10px;
}
.parameter-list td {
padding-left:5px;
padding-right:5px;
}
.code-function {
text-decoration:none;
color:#09857e;

View File

@ -1,147 +1,62 @@
/* CSS Document */
/*----------------MENU-----------------*/
div#menu div{
margin-top: 0px;
background: #6699FF;
div#menu {
border-left: 4px solid #8d2d0d;
border-bottom: 4px solid #8d2d0d;
padding-left: 4px;
padding-bottom: 4px;
}
/* permet l'affichage du haut du menu*/
div#menu h2{
color: #000000;
FONT-FAMILY: Arial;
FONT-SIZE: 9pt;
text-align:left;
margin: 0;
padding: 3px;
padding-left: 6px;
background: #1a62db;
background: #d44413;
}
div#menu h3{
margin: 0;
padding: 6px;
background: #6699FF;
background: #d44413;
}
div#menu a{
color: #000000;
bgcolor=#6699FF;
bgcolor=#d44413;
FONT-FAMILY: Arial;
FONT-SIZE: 9pt;
}
div#menu li {
position: relative;
list-style:none;
margin:0px;
border-bottom: 1px solid #0008ab;
}
div#menu li.sousmenu {
background: url(sous_menu.gif) 95% 50% no-repeat;
}
div#menu li:hover {
background: #0008ab;
}
div#menu li.sousmenu:hover {
background: #0008ab;
}
div#menu ul ul {
position: absolute;
top: 0px;
width:160px;
border-top: 1px solid #d44413;
}
/*TAILLE PREMIERE COLONNE*/
div#menu {
float: center;
width: 200px;
text-align:left;
}
div#menu ul {
left: 30px;
margin: 0;
padding: 0;
width: 200px;
background: #6699FF;
border: 0px solid;
}
div#menu ul ul {
left: 199px;
display:none;
background: #FFFFFF;
}
div#menu li a {
display: block;
padding: 2px 0px 2px 4px;
text-decoration: none;
width: 191px;
border-left: 3px solid #6699FF;
}
div#menu form {
border-left: 8px solid #6699FF;
background: #6699FF;
FONT-FAMILY: Arial;
margin:0px;
FONT-SIZE: 8pt;
}
div#menu texte {
border-left: 8px solid #6699FF;
FONT-FAMILY: Arial;
FONT-SIZE: 9pt;
font-weight:bold;
border-bottom: 1px solid #6699FF;
width:160px;
border-left: 4px solid #8d2d0d;
}
/*TAILLE DEUXIEME COLONE*/
div#menu ul.niveau1 ul {
left: 200px;
height: 500px;
border: 1px solid #0008ab;
border-left: 20px solid #d44413;
background: #1a62db;
/*
overflow:scroll;
overflow-y:auto;
overflow-x:hidden;
*/
}
div#menu ul.niveau1 li {
background: #6699FF;
}
div#menu ul.niveau1 li.sousmenu:hover ul.niveau2 {
width:219px;
display:block;
background: #b43a10;
}
/*TAILLE TROISIEME COLONNE*/
div#menu ul.niveau2 ul {
left: 219px;
height: 500px;
}
div#menu ul.niveau2 li a {
width: 200px;
}
div#menu ul.niveau2 li.sousmenu:hover ul.niveau3 {
width:10em;
display:block;
}
/*TAILLE Quatrieme COLONNE*/
div#menu ul.niveau3 ul {
left: 369px;
height: 500px;
}
div#menu ul.niveau3 li a {
width: 200px;
}
div#menu ul.niveau3 li.sousmenu:hover ul.niveau4 {
width:10em;
display:block;
}
/*TAILLE DEUXIEME COLONE BIS????*/
/*COULEUR DES BORDURES*/
div#menu li a:hover {
border-left-color: #000ADE;
background: #6699FF;
border-left-color: #ff3800;
font-weight:bold;
}

147
theme/menu_dynamic.css Normal file
View File

@ -0,0 +1,147 @@
/* CSS Document */
/*----------------MENU-----------------*/
div#menu div{
margin-top: 0px;
background: #6699FF;
}
/* permet l'affichage du haut du menu*/
div#menu h2{
color: #000000;
FONT-FAMILY: Arial;
FONT-SIZE: 9pt;
text-align:left;
margin: 0;
padding: 3px;
padding-left: 6px;
background: #1a62db;
}
div#menu h3{
margin: 0;
padding: 6px;
background: #6699FF;
}
div#menu a{
color: #000000;
bgcolor=#6699FF;
FONT-FAMILY: Arial;
FONT-SIZE: 9pt;
}
div#menu li {
position: relative;
list-style:none;
margin:0px;
border-bottom: 1px solid #0008ab;
}
div#menu li.sousmenu {
background: url(sous_menu.gif) 95% 50% no-repeat;
}
div#menu li:hover {
background: #0008ab;
}
div#menu li.sousmenu:hover {
background: #0008ab;
}
div#menu ul ul {
position: absolute;
top: 0px;
}
/*TAILLE PREMIERE COLONNE*/
div#menu {
float: center;
width: 200px;
text-align:left;
}
div#menu ul {
margin: 0;
padding: 0;
width: 200px;
background: #6699FF;
border: 0px solid;
}
div#menu ul ul {
left: 199px;
display:none;
background: #FFFFFF;
}
div#menu li a {
display: block;
padding: 2px 0px 2px 4px;
text-decoration: none;
width: 191px;
border-left: 3px solid #6699FF;
}
div#menu form {
border-left: 8px solid #6699FF;
background: #6699FF;
FONT-FAMILY: Arial;
margin:0px;
FONT-SIZE: 8pt;
}
div#menu texte {
border-left: 8px solid #6699FF;
FONT-FAMILY: Arial;
FONT-SIZE: 9pt;
font-weight:bold;
border-bottom: 1px solid #6699FF;
}
/*TAILLE DEUXIEME COLONE*/
div#menu ul.niveau1 ul {
left: 200px;
height: 500px;
border: 1px solid #0008ab;
background: #1a62db;
/*
overflow:scroll;
overflow-y:auto;
overflow-x:hidden;
*/
}
div#menu ul.niveau1 li {
background: #6699FF;
}
div#menu ul.niveau1 li.sousmenu:hover ul.niveau2 {
width:219px;
display:block;
}
/*TAILLE TROISIEME COLONNE*/
div#menu ul.niveau2 ul {
left: 219px;
height: 500px;
}
div#menu ul.niveau2 li a {
width: 200px;
}
div#menu ul.niveau2 li.sousmenu:hover ul.niveau3 {
width:10em;
display:block;
}
/*TAILLE Quatrieme COLONNE*/
div#menu ul.niveau3 ul {
left: 369px;
height: 500px;
}
div#menu ul.niveau3 li a {
width: 200px;
}
div#menu ul.niveau3 li.sousmenu:hover ul.niveau4 {
width:10em;
display:block;
}
/*TAILLE DEUXIEME COLONE BIS????*/
/*COULEUR DES BORDURES*/
div#menu li a:hover {
border-left-color: #000ADE;
background: #6699FF;
font-weight:bold;
}