[DEV] auto add tutorial Title and next&previous
This commit is contained in:
parent
9b9a5d3237
commit
6c7b028c50
79
monkHtml.py
79
monkHtml.py
@ -25,6 +25,46 @@ def html_encode(s):
|
|||||||
s = s.replace(code[0], code[1])
|
s = s.replace(code[0], code[1])
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
camelCaseCodes = (
|
||||||
|
('A', ' a'),
|
||||||
|
('B', ' b'),
|
||||||
|
('C', ' c'),
|
||||||
|
('D', ' d'),
|
||||||
|
('E', ' e'),
|
||||||
|
('F', ' f'),
|
||||||
|
('G', ' g'),
|
||||||
|
('H', ' h'),
|
||||||
|
('I', ' i'),
|
||||||
|
('J', ' j'),
|
||||||
|
('K', ' k'),
|
||||||
|
('L', ' l'),
|
||||||
|
('M', ' m'),
|
||||||
|
('N', ' n'),
|
||||||
|
('O', ' o'),
|
||||||
|
('P', ' p'),
|
||||||
|
('Q', ' q'),
|
||||||
|
('R', ' r'),
|
||||||
|
('S', ' s'),
|
||||||
|
('T', ' t'),
|
||||||
|
('U', ' u'),
|
||||||
|
('V', ' v'),
|
||||||
|
('W', ' w'),
|
||||||
|
('X', ' x'),
|
||||||
|
('Y', ' y'),
|
||||||
|
('Z', ' z'),
|
||||||
|
)
|
||||||
|
def camel_case_encode(s):
|
||||||
|
for code in camelCaseCodes:
|
||||||
|
s = s.replace(code[1], code[0])
|
||||||
|
return s
|
||||||
|
def camel_case_decode(s):
|
||||||
|
for code in camelCaseCodes:
|
||||||
|
s = s.replace(code[0], code[1])
|
||||||
|
return s
|
||||||
|
|
||||||
|
def capitalise_first_letter(s):
|
||||||
|
return word[0].upper() + word[1:]
|
||||||
|
|
||||||
def display_doxygen_param(comment, input, output):
|
def display_doxygen_param(comment, input, output):
|
||||||
data = '<tr>'
|
data = '<tr>'
|
||||||
data = '<td>'
|
data = '<td>'
|
||||||
@ -266,13 +306,14 @@ def generate_stupid_index_page(outFolder, header, footer, myLutinDoc):
|
|||||||
file.write(footer)
|
file.write(footer)
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
def generate_page(outFolder, header, footer, element):
|
def generate_page(outFolder, header, footer, element, name_lib=""):
|
||||||
|
debug.print_element("code-doc", name_lib, "<==", element.name)
|
||||||
currentPageSite = element.get_doc_website_page()
|
currentPageSite = element.get_doc_website_page()
|
||||||
namespaceStack = element.get_namespace()
|
namespaceStack = element.get_namespace()
|
||||||
if element.get_node_type() in ['library', 'application', 'namespace', 'class', 'struct', 'enum', 'union']:
|
if element.get_node_type() in ['library', 'application', 'namespace', 'class', 'struct', 'enum', 'union']:
|
||||||
listBase = element.get_all_sub_type(['library', 'application', 'namespace', 'class', 'struct', 'enum', 'union'])
|
listBase = element.get_all_sub_type(['library', 'application', 'namespace', 'class', 'struct', 'enum', 'union'])
|
||||||
for elem in listBase:
|
for elem in listBase:
|
||||||
generate_page(outFolder, header, footer, elem['node'])
|
generate_page(outFolder, header, footer, elem['node'], name_lib)
|
||||||
filename = outFolder + '/' + generate_html_page_name(element)
|
filename = outFolder + '/' + generate_html_page_name(element)
|
||||||
tools.create_directory_of_file(filename);
|
tools.create_directory_of_file(filename);
|
||||||
file = open(filename, "w")
|
file = open(filename, "w")
|
||||||
@ -581,7 +622,7 @@ def generate(myLutinDoc, outFolder) :
|
|||||||
if name == "index":
|
if name == "index":
|
||||||
continue
|
continue
|
||||||
docList += '<ul class="niveau1">'
|
docList += '<ul class="niveau1">'
|
||||||
docList += '<li><a href="' + outputFileName + '">' + name + '</a></li>\n'
|
docList += '<li><a href="' + outputFileName + '">' + camel_case_decode(name).capitalize() + '</a></li>\n'
|
||||||
docList += '</ul>'
|
docList += '</ul>'
|
||||||
if docList != "":
|
if docList != "":
|
||||||
genericHeader += '<h3>Documentation:</h3>'
|
genericHeader += '<h3>Documentation:</h3>'
|
||||||
@ -598,7 +639,7 @@ def generate(myLutinDoc, outFolder) :
|
|||||||
if name == "index":
|
if name == "index":
|
||||||
continue
|
continue
|
||||||
tutorialList += '<ul class="niveau1">'
|
tutorialList += '<ul class="niveau1">'
|
||||||
tutorialList += '<li><a href="tutorial_' + outputFileName + '">' + name + '</a></li>\n'
|
tutorialList += '<li><a href="tutorial_' + outputFileName + '">' + camel_case_decode(name).capitalize() + '</a></li>\n'
|
||||||
tutorialList += '</ul>'
|
tutorialList += '</ul>'
|
||||||
if tutorialList != "":
|
if tutorialList != "":
|
||||||
genericHeader += '<h3>Tutorials:</h3>'
|
genericHeader += '<h3>Tutorials:</h3>'
|
||||||
@ -648,21 +689,41 @@ def generate(myLutinDoc, outFolder) :
|
|||||||
generate_stupid_index_page(outFolder, genericHeader, genericFooter, myLutinDoc)
|
generate_stupid_index_page(outFolder, genericHeader, genericFooter, myLutinDoc)
|
||||||
|
|
||||||
# create the namespace index properties :
|
# create the namespace index properties :
|
||||||
generate_page(outFolder, genericHeader, genericFooter, myDoc)
|
generate_page(outFolder, genericHeader, genericFooter, myDoc, name_lib=myLutinDoc.name )
|
||||||
|
|
||||||
for docInputName,outpath in myLutinDoc.listTutorialFile :
|
for iii in range(0, len(myLutinDoc.listTutorialFile)) :
|
||||||
debug.print_element("doc", myLutinDoc.name, "<==", docInputName)
|
docInputName,outpath = myLutinDoc.listTutorialFile[iii]
|
||||||
|
|
||||||
|
debug.print_element("tutorial", myLutinDoc.name, "<==", docInputName)
|
||||||
outputFileName = outFolder + "/" + outpath.replace('/','_') +".html"
|
outputFileName = outFolder + "/" + outpath.replace('/','_') +".html"
|
||||||
debug.debug("output file : " + outputFileName)
|
debug.debug("output file : " + outputFileName)
|
||||||
tools.create_directory_of_file(outputFileName)
|
tools.create_directory_of_file(outputFileName)
|
||||||
|
name = outputFileName.split('_')[-1][:-5]
|
||||||
inData = tools.file_read_data(docInputName)
|
inData = tools.file_read_data(docInputName)
|
||||||
if inData == "":
|
if inData == "":
|
||||||
continue
|
continue
|
||||||
outData = genericHeader + codeBB.transcode(inData) + genericFooter
|
outData = genericHeader
|
||||||
|
localHeader = ""
|
||||||
|
localHeader += "=?=" + camel_case_decode(name) + "=?=\n___________________________\n"
|
||||||
|
if iii != 0:
|
||||||
|
previousName, previousOutpath = myLutinDoc.listTutorialFile[iii-1]
|
||||||
|
previousName = previousName.split('_')[-1][:-3]
|
||||||
|
previousOutpath = previousOutpath.split('/')[-1]
|
||||||
|
localHeader += "[left][tutorial[" + previousOutpath + " | Previous: " + camel_case_decode(previousName).capitalize() + "]][/left] "
|
||||||
|
if iii != len(myLutinDoc.listTutorialFile)-1:
|
||||||
|
nextName, nextOutpath = myLutinDoc.listTutorialFile[iii+1]
|
||||||
|
nextName = nextName.split('_')[-1][:-3]
|
||||||
|
nextOutpath = nextOutpath.split('/')[-1]
|
||||||
|
localHeader += " [right][tutorial[" + nextOutpath + " | Next: " + camel_case_decode(nextName).capitalize() + "]][/right]"
|
||||||
|
localHeader += "\n"
|
||||||
|
outData += codeBB.transcode(localHeader)
|
||||||
|
#debug.info(localHeader)
|
||||||
|
outData += codeBB.transcode(inData)
|
||||||
|
outData += genericFooter
|
||||||
tools.file_write_data(outputFileName, outData)
|
tools.file_write_data(outputFileName, outData)
|
||||||
|
|
||||||
for docInputName,outpath in myLutinDoc.listDocFile :
|
for docInputName,outpath in myLutinDoc.listDocFile :
|
||||||
debug.print_element("tutorial", myLutinDoc.name, "<==", docInputName)
|
debug.print_element("doc", myLutinDoc.name, "<==", docInputName)
|
||||||
outputFileName = outFolder + outpath + ".html"
|
outputFileName = outFolder + outpath + ".html"
|
||||||
debug.debug("output file : " + outputFileName)
|
debug.debug("output file : " + outputFileName)
|
||||||
tools.create_directory_of_file(outputFileName)
|
tools.create_directory_of_file(outputFileName)
|
||||||
|
@ -131,8 +131,8 @@ class Module:
|
|||||||
for filename in tmpList:
|
for filename in tmpList:
|
||||||
fileCompleteName = os.path.join(root, filename)
|
fileCompleteName = os.path.join(root, filename)
|
||||||
tutorialPath = os.path.join(self.pathGlobalDoc, "tutorial/")
|
tutorialPath = os.path.join(self.pathGlobalDoc, "tutorial/")
|
||||||
debug.verbose(" Find a doc file : '" + fileCompleteName + "'")
|
|
||||||
pathBase = fileCompleteName[len(self.pathGlobalDoc):len(fileCompleteName)-3]
|
pathBase = fileCompleteName[len(self.pathGlobalDoc):len(fileCompleteName)-3]
|
||||||
|
debug.verbose(" Find a doc file : fileCompleteName='" + fileCompleteName + "'")
|
||||||
if fileCompleteName[:len(tutorialPath)] == tutorialPath:
|
if fileCompleteName[:len(tutorialPath)] == tutorialPath:
|
||||||
self.add_tutorial_doc(fileCompleteName, pathBase)
|
self.add_tutorial_doc(fileCompleteName, pathBase)
|
||||||
else:
|
else:
|
||||||
@ -146,7 +146,14 @@ class Module:
|
|||||||
##
|
##
|
||||||
def add_file_doc(self, filename, outPath):
|
def add_file_doc(self, filename, outPath):
|
||||||
debug.debug("adding file in documantation : '" + filename + "'");
|
debug.debug("adding file in documantation : '" + filename + "'");
|
||||||
self.listDocFile.append([filename, outPath])
|
done = False
|
||||||
|
for iii in range(0,len(self.listDocFile)):
|
||||||
|
if self.listDocFile[iii][0] > filename:
|
||||||
|
self.listDocFile.insert(iii, [filename, outPath])
|
||||||
|
done = True
|
||||||
|
break
|
||||||
|
if done == False:
|
||||||
|
self.listDocFile.append([filename, outPath])
|
||||||
|
|
||||||
##
|
##
|
||||||
## @brief Add a documentation file at the parsing system
|
## @brief Add a documentation file at the parsing system
|
||||||
@ -155,8 +162,16 @@ class Module:
|
|||||||
## @return True if no error occured, False otherwise
|
## @return True if no error occured, False otherwise
|
||||||
##
|
##
|
||||||
def add_tutorial_doc(self, filename, outPath):
|
def add_tutorial_doc(self, filename, outPath):
|
||||||
|
count = int(filename.split('/')[-1].split('_')[0])
|
||||||
debug.debug("adding file in documantation : '" + filename + "'");
|
debug.debug("adding file in documantation : '" + filename + "'");
|
||||||
self.listTutorialFile.append([filename, outPath])
|
done = False
|
||||||
|
for iii in range(0,len(self.listTutorialFile)):
|
||||||
|
if self.listTutorialFile[iii][0] > filename:
|
||||||
|
self.listTutorialFile.insert(iii, [filename, outPath])
|
||||||
|
done = True
|
||||||
|
break
|
||||||
|
if done == False:
|
||||||
|
self.listTutorialFile.append([filename, outPath])
|
||||||
|
|
||||||
##
|
##
|
||||||
## @brief Add a file at the parsing system
|
## @brief Add a file at the parsing system
|
||||||
|
Loading…
x
Reference in New Issue
Block a user