[DEV] correct display

This commit is contained in:
Edouard DUPIN 2019-09-30 18:38:46 +02:00
parent e2ca9ebddc
commit 8b4bb1692d
11 changed files with 240 additions and 53 deletions

View File

@ -14,13 +14,13 @@ from realog import debug
my_args = arguments.Arguments()
my_args.add("h", "help", desc="display this help")
my_args.add_section("option", "Can be set one time in all case")
my_args.add("v", "verbose", list=[["0","None"],["1","error"],["2","warning"],["3","info"],["4","debug"],["5","verbose"]], desc="Display makefile debug level (verbose) default =2")
my_args.add("v", "verbose", haveParam=True, list=[["0","None"],["1","error"],["2","warning"],["3","info"],["4","debug"],["5","verbose"]], desc="Display makefile debug level (verbose) default =2")
my_args.add("C", "color", desc="Display makefile output in color")
my_args.add_section("cible", "generate in order set")
local_argument = my_args.parse()
debug.set_level(6)
#debug.set_level(6)
##
## @brief Display the help of this makefile

View File

@ -42,7 +42,7 @@ import re
## @param[in] value String to transform.
## @return Transformed string.
##
def transcode(value, _base_path):
def transcode(value, _base_path = ""):
value = re.sub(r'\n:',
r'\n:INDENT:',

View File

@ -24,21 +24,38 @@ def transcode(value, _base_path):
value = re.sub(r'!\[https://(.*?)\][ \t]*\((.*?)\)',
r'<img src="https://\2" alt="\1"/>',
value)
value = re.sub(r'!\[(.*?)\][ \t]*\((.*?)\?w=([0-9]+)%\)',
r'<img src="' + base_path + r'\2" alt="\1" width="\3%"/>',
p = re.compile('!\[(.*?)\][ \t]*\((.*?)\)')
value = p.sub(replace_image,
value)
value = re.sub(r'!\[(.*?)\][ \t]*\((.*?)\?w=([0-9]+)px\)',
r'<img src="' + base_path + r'\2" alt="\1" width="\3px"/>',
value)
value = re.sub(r'!\[(.*?)\][ \t]*\((.*?)\?h=([0-9]+)px\)',
r'<img src="' + base_path + r'\2" alt="\1" height="\3px"/>',
value)
value = re.sub(r'!\[(.*?)\][ \t]*\((.*?)\?w=([0-9]+)px&h=([0-9]+)px\)',
r'<img src="' + base_path + r'\2" alt="\1" width="\3px" height="\4px"/>',
value)
value = re.sub(r'!\[(.*?)\][ \t]*\((.*?)\)',
r'<img src="' + base_path + r'\2" alt="\1"/>',
value = re.sub(r':BASE_PATH:',
r'' + base_path,
value)
return value
def replace_image(match):
if match.group() == "":
return ""
debug.verbose("Image parse: " + str(match.group()))
value = '<img src=":BASE_PATH:'
value += match.groups()[1].replace("/", "__")
value += '" '
alt_properties = match.groups()[0].split("|")
alt = False
for elem in alt_properties:
if alt == False:
alt = True
value += 'alt="' + elem + '" '
continue
key_alt, value_alt = elem.split("=")
if key_alt == "width":
value += 'width="' + value_alt + '" '
elif key_alt == "height":
value += 'height="' + value_alt + '" '
else:
debug.warning("not manage element '" + key_alt + "' in '" + str(match.group()) + "'")
value += '/>'
return value

View File

@ -34,48 +34,85 @@ import re
## @return Transformed string.
##
def transcode(value, _base_path = ""):
value = re.sub(r'\n(( - )|( \* )|( # )|(\* ))',
r'\n:INDENT_1:[STAR]',
value)
value = re.sub(r'\n(( - \[ \] )|( \* \[ \] )|( # \[ \] )|(\* \[ \] ))',
r'\n:INDENT_1:[CHECK_BOX_0]',
value)
value = re.sub(r'\n(( - \[(x|X)\] )|( \* \[(x|X)\] )|( # \[(x|X)\] )|(\* \[(x|X)\] ))',
value = re.sub(r'\n(( - \[x\] )|( \* \[x\] )|( # \[x\] )|(\* \[x\] ))',
r'\n:INDENT_1:[CHECK_BOX_1]',
value)
value = re.sub(r'\n( |\t)(( - )|( \* )|( # )|(\* ))',
r'\n:INDENT_1::INDENT_2:[STAR]',
value = re.sub(r'\n(( - \[X\] )|( \* \[X\] )|( # \[X\] )|(\* \[X\] ))',
r'\n:INDENT_1:[CHECK_BOX_2]',
value)
value = re.sub(r'\n(( - )|( \* )|( # )|(\* ))',
r'\n:INDENT_1:[TICK]',
value)
value = re.sub(r'\n(( - )|( \* )|( # )|(\* ))',
r'\n:INDENT_1:[STAR]',
value)
value = re.sub(r'\n(( - )|( \* )|( # )|(\* ))',
r'\n:INDENT_1:[SHARP]',
value)
value = re.sub(r'\n(( - )|( \* )|( # )|(\* ))',
r'\n:INDENT_1:[STAR]',
value)
value = re.sub(r'\n( |\t)(( - \[ \] )|( \* \[ \] )|( # \[ \] )|(\* \[ \] ))',
r'\n:INDENT_1::INDENT_2:[CHECK_BOX_0]',
value)
value = re.sub(r'\n( |\t)(( - \[(x|X)\] )|( \* \[(x|X)\] )|( # \[(x|X)\] )|(\* \[(x|X)\] ))',
value = re.sub(r'\n( |\t)(( - \[x\] )|( \* \[x\] )|( # \[x\] )|(\* \[x\] ))',
r'\n:INDENT_1::INDENT_2:[CHECK_BOX_1]',
value)
value = re.sub(r'\n( |\t\t)(( - )|( \* )|( # )|(\* ))',
r'\n:INDENT_1::INDENT_2::INDENT_3:[STAR]',
value = re.sub(r'\n( |\t)(( - \[X\] )|( \* \[X\] )|( # \[x\] )|(\* \[x\] ))',
r'\n:INDENT_1::INDENT_2:[CHECK_BOX_2]',
value)
value = re.sub(r'\n( |\t)(( - )|( \* )|( # )|(\* ))',
r'\n:INDENT_1::INDENT_2:[STAR]',
value)
value = re.sub(r'\n( |\t\t)(( - \[ \] )|( \* \[ \] )|( # \[ \] )|(\* \[ \] ))',
r'\n:INDENT_1::INDENT_2::INDENT_3:[CHECK_BOX_0]',
value)
value = re.sub(r'\n( |\t\t)(( - \[(x|X)\] )|( \* \[(x|X)\] )|( # \[(x|X)\] )|(\* \[(x|X)\] ))',
value = re.sub(r'\n( |\t\t)(( - \[x\] )|( \* \[x\] )|( # \[x\] )|(\* \[x\] ))',
r'\n:INDENT_1::INDENT_2::INDENT_3:[CHECK_BOX_1]',
value)
value = re.sub(r'\n( |\t\t)(( - \[X\] )|( \* \[X\] )|( # \[X\] )|(\* \[X\] ))',
r'\n:INDENT_1::INDENT_2::INDENT_3:[CHECK_BOX_2]',
value)
value = re.sub(r'\n( |\t\t)(( - )|( \* )|( # )|(\* ))',
r'\n:INDENT_1::INDENT_2::INDENT_3:[STAR]',
value)
p = re.compile('((\:INDENT_1\:(.*?)\n)*)',
flags=re.DOTALL)
value = p.sub(replace_wiki_identation_1,
value)
value = re.sub(r'\[STAR\](.*?)\n',
r'<li>\1</li>',
r'<li class="list-star">\1</li>',
value,
flags=re.DOTALL)
value = re.sub(r'\[SHARP\](.*?)\n',
r'<li class="list-sharp">\1</li>',
value,
flags=re.DOTALL)
value = re.sub(r'\[TICK\](.*?)\n',
r'<li class="list-tick">\1</li>',
value,
flags=re.DOTALL)
value = re.sub(r'\[NUMBER\](.*?)\n',
r'<li class="list-number">\1</li>',
value,
flags=re.DOTALL)
value = re.sub(r'\[CHECK_BOX_2\](.*?)\n',
#r'<li class="list-check-box"><input type="checkbox" checked=""/>\1</li>',
r'<li class="list-check-box-tick">\1</li>',
value,
flags=re.DOTALL)
value = re.sub(r'\[CHECK_BOX_1\](.*?)\n',
r'<li><input type="checkbox" checked=""/>\1</li>',
#r'<li class="list-check-box"><input type="checkbox" checked=""/>\1</li>',
r'<li class="list-check-box-check">\1</li>',
value,
flags=re.DOTALL)
value = re.sub(r'\[CHECK_BOX_0\](.*?)\n',
r'<li><input type="checkbox"/>\1</li>',
#r'<li class="list-check-box"><input type="checkbox"/>\1</li>',
r'<li class="list-check-box">\1</li>',
value,
flags=re.DOTALL)

View File

@ -15,13 +15,10 @@ import re
## En bref sa tend a marcher comme sur un Wiki...
##
## result:
## +-------------------------------------+
## | colone 1 |
## +------------------+------------------+
## | colone 1 | |
## | ---------------- | ---------------- |
## | ligne 1 | colone 2 ligne 1 |
## +------------------+------------------+
## | colone 1 ligne 1 | colone 2 ligne 2 |
## +------------------+------------------+
##
## @param[in] value String to transform.
## @return Transformed string.
@ -34,29 +31,41 @@ def transcode(value, _base_path):
value)
return value
table_index = 0
def replace_table(match):
global table_index
table_index = 0
if match.group() == "":
return ""
#debug.verbose("plop: " + str(match.group()))
value = "<table>"
debug.warning("=============================: " + str(match.group()))
value = '<table class="doc_table">'
value_global = re.sub(r'\n\|([\t -]*\|)+',
r'',
match.group())
#value_global = match.group()
debug.warning("=============================: " + str(value_global))
p = re.compile('\n(.*)')
value += p.sub(replace_table_line,
match.group())
value_global)
value += "</table>"
return value
def replace_table_line(match):
global table_index
if match.group() == "":
return ""
debug.warning("parse LINE ... : '" + str(match.group()) + "'")
debug.warning("parse LINE ... : '" + str(match.group()) + "' ==> " + str(table_index))
value = "<tr>"
tmpppp = match.group().replace("\n", "").split('|')
for elem in tmpppp:
if len(elem) == 0:
continue
if table_index == 0:
value += "<th>" + elem + "</th>"
else:
value += "<td>" + elem + "</td>"
value += "</tr>"
table_index += 1
debug.warning(" ==> out " + value)
return value

View File

@ -4,6 +4,11 @@ import sys
from monk import tools
import re
h2counter = 1
h3counter = 1
h4counter = 1
h5counter = 1
h6counter = 1
##
## @brief Transcode .
@ -17,18 +22,28 @@ import re
## @return Transformed string.
##
def transcode(value, _base_path):
value = "\n" + value
value_start = "==Z==!!START!!==Z=="
value = value_start + value
value = re.sub(r'@tableofcontents',
r'',
value)
value = re.sub(r'\n(.*?)(( |\t)*\{.*\})*\n====*',
r'\n<h1>\1</h1>',
value = re.sub(value_start + r'(.*?)(( |\t)*\{.*\})*\n====*',
value_start + r'<h1>\1</h1>',
value)
value = re.sub(r'\n(.*?)(( |\t)*\{.*\})*\n===*',
r'\n<h2>\1</h2>',
value)
value = re.sub(r'\n(.*?)(( |\t)*\{.*\})*\n---*',
r'\n<h2>\1</h2>',
r'\n<h3>\1</h3>',
value)
value = re.sub(r'\n(.*?)(( |\t)*\{.*\})*\n\+\+\+*',
r'\n<h4>\1</h4>',
value)
value = re.sub(r'\n(.*?)(( |\t)*\{.*\})*\n~~~*',
r'\n<h5>\1</h5>',
value)
value = re.sub(r'\n###### (.*?)(( |\t)*\{.*\})* ######',
@ -66,8 +81,31 @@ def transcode(value, _base_path):
r'\n<h2>\1</h2>',
value)
value = value[1:]
value = re.sub(value_start,
r'',
value)
return value
def transcode_clean_empty_line_after(value, _base_path):
value = re.sub(r'</h6>[\n \t]*<br/>',
r'</h6>',
value)
value = re.sub(r'</h5>[\n \t]*<br/>',
r'</h5>',
value)
value = re.sub(r'</h4>[\n \t]*<br/>',
r'</h4>',
value)
value = re.sub(r'</h3>[\n \t]*<br/>',
r'</h3>',
value)
value = re.sub(r'</h2>[\n \t]*<br/>',
r'</h2>',
value)
value = re.sub(r'</h1>[\n \t]*<br/>',
r'</h1>',
value)
return value

View File

@ -38,6 +38,7 @@ def transcode(value, _base_path = ""):
value = MD_IndentAndDot.transcode(value, _base_path)
value = MD_Code.transcode(value, _base_path)
value = MD_lineReturn.transcode(value, _base_path)
value = MD_Title.transcode_clean_empty_line_after(value, _base_path)
value = MD_Text.transcode(value, _base_path)
"""
value = BB_Text.transcode(value, _base_path)

View File

@ -338,7 +338,7 @@ def generate_page(my_lutin_doc, out_folder, element, name_lib=""):
if element.get_node_type() in ['library', 'application', 'namespace', 'class', 'struct', 'enum', 'union', 'using']:
listBase = element.get_all_sub_type(['library', 'application', 'namespace', 'class', 'struct', 'enum', 'union', 'using'])
for elem in listBase:
generate_page(out_folder, header, footer, elem['node'], name_lib)
generate_page(my_lutin_doc, out_folder, elem['node'], name_lib)
filename = out_folder + '/' + generate_html_page_name(element)
tools.create_directory_of_file(filename);
file = open(filename, "w")
@ -728,7 +728,7 @@ def create_generic_header(my_lutin_doc, out_folder) :
if name == "index":
continue
tutorialList += '<ul class="niveau1">'
tutorialList += '<li><a href="tutorial_' + output_file_name + '">' + capitalise_first_letter(camel_case_decode(name)) + '</a></li>\n'
tutorialList += '<li><a href="tutorial__' + output_file_name + '">' + capitalise_first_letter(camel_case_decode(name)) + '</a></li>\n'
tutorialList += '</ul>'
if tutorialList != "":
generic_header += '<h3>Tutorials:</h3>'
@ -855,7 +855,7 @@ def generate(my_lutin_doc, out_folder) :
outData += codeBB.transcode(inData)
elif doc_input_name[-2:] == "md":
outData += codeMarkDown.transcode(inData)
outData += genericFooter
outData += create_generic_footer(my_lutin_doc, out_folder)
tools.file_write_data(output_file_name, outData)
for list_value in [my_lutin_doc.list_doc_file, my_lutin_doc.list_test_file, my_lutin_doc.list_manual_file]:
for doc_input_name,outpath in list_value :

View File

@ -354,6 +354,7 @@ class parse_file():
if tok.type == 'COMMENT_SINGLELINE_DOC':
self.last_comment.append(tok.value)
if tok.type == 'OPEN_BRACE':
debug.verbose("OPEN_BRACE ==> start")
if self.count_pthese >= 1:
# special case of lamba declaration inside initialisation of constructor
self.name_stack.append(tok.value)
@ -372,6 +373,8 @@ class parse_file():
debug.verbose("openBrace *** " + str(self.name_stack))
elif 'namespace' in self.name_stack:
self.brace_type_push('namespace', self.name_stack)
elif 'enum' in self.name_stack and 'class' in self.name_stack:
self.brace_type_push('enum', self.name_stack)
elif 'class' in self.name_stack:
self.brace_type_push('class', self.name_stack)
elif 'enum' in self.name_stack:
@ -389,6 +392,7 @@ class parse_file():
self.stack = []
self.name_stack = []
self.last_comment = []
debug.verbose("OPEN_BRACE ==> END")
elif tok.type == 'CLOSE_BRACE':
if self.count_pthese >= 1:
debug.info("plop 2 " +str(self.count_pthese))
@ -454,7 +458,7 @@ class parse_file():
self.name_stack.append(tok.value)
elif tok.type == 'SEMI_COLON':
if self.count_pthese >= 1:
debug.info("plop 3 " +str(self.count_pthese))
debug.info("plop 3 " + str(self.count_pthese))
# special case of lamba declaration inside initialisation of constructor
self.name_stack.append(tok.value)
else:

View File

@ -24,6 +24,28 @@ body {
display: block;
};
/*
body::before {
counter-reset: hhindexer;
}
h2::before {
content: counter(hhindexer) ".\0000a0\0000a0";
counter-increment: hhindexer;
counter-reset: hhhindexer;
}
h3::before {
content: counter(hhindexer) "." counter(hhhindexer) ".\0000a0\0000a0";
counter-increment: hhhindexer;
counter-reset: hhhhindexer;
}
h4::before {
content: counter(hhindexer) "." counter(hhhindexer) "." counter(hhhhindexer) ".\0000a0\0000a0";
counter-increment: hhhhindexer;
}
*/
.navbar {
z-index: 1;
overflow: visible;
@ -68,6 +90,7 @@ body {
color: #000000;
}
h1, h2, h3, h4, h5, h6 {
display: block;
margin: 10px 0;
@ -78,6 +101,26 @@ h1, h2, h3, h4, h5, h6 {
text-rendering: optimizelegibility;
}
h1 {
margin: 20px 0px 10px 0;
font-size: 20px;
}
h2 {
margin: 15px 0px 10px 0;
font-size: 18px;
}
h3 {
font-size: 16px;
}
h4, h5, h6 {
font-size: 14px;
}
p {
margin: 0 0 10px;
display: block;
@ -231,12 +274,19 @@ pre {
table {
border-collapse:collapse;
}
td {
table.doc_table td {
padding:4px;
border:1px solid #000;
vertical-align:top;
}
table.doc_table th {
padding:4px;
border:1px solid #000;
background: #7fac1e;
vertical-align:top;
}
#my-table {
width:30%;
border-collapse:collapse;
@ -247,3 +297,34 @@ td {
border:1px solid #000;
vertical-align:top;
}
.list-star {
list-style-type: circle;
}
.list-tick {
//list-style-type: '- ';
list-style-type: disc;
}
.list-sharp {
list-style-type: square;
}
.list-number {
list-style-type: decimal;
}
.list-check-box {
list-style-type: "\2610\0020";
}
.list-check-box-check {
list-style-type: "\2612\0020";
}
.list-check-box-tick {
list-style-type: "\2611\0020";
}

View File

@ -22,7 +22,7 @@ def create_directory_of_file(file):
def remove_folder_and_sub_folder(path):
if os.path.isdir(path):
debug.verbose("remove folder : '" + path + "'")
debug.verbose("remove folder: '" + path + "'")
shutil.rmtree(path)
def remove_file(path):