From e2ca9ebddc7f06ed7f089339ab1f7595eda65f12 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 30 Sep 2019 00:10:25 +0200 Subject: [PATCH] [DEV] update to new documention model --- monk/__init__.py | 38 +-- monk/codeBB/BB_Code.py | 4 +- monk/codeBB/BB_Image.py | 4 +- monk/codeBB/BB_IndentAndDot.py | 4 +- monk/codeBB/BB_Link.py | 4 +- monk/codeBB/BB_Specification.py | 4 +- monk/codeBB/BB_Table.py | 4 +- monk/codeBB/BB_Text.py | 4 +- monk/codeBB/BB_Title.py | 4 +- monk/codeBB/BB_comment.py | 4 +- monk/codeBB/BB_lineReturn.py | 4 +- monk/codeBB/__init__.py | 52 ++++ monk/codeBB/codeBB.py | 52 ---- monk/codeHL/codeHL.py | 2 +- monk/codeHL/codeHLBBcode.py | 2 +- monk/codeHL/codeHLJava.py | 2 +- monk/codeHL/codeHLPython.py | 2 +- monk/codeHL/codeHLXML.py | 2 +- monk/codeHL/codeHLcpp.py | 2 +- monk/codeHL/codeHLjson.py | 31 ++- monk/codeHL/codeHLshell.py | 2 +- monk/codeMarkDown/MD_Code.py | 7 +- monk/codeMarkDown/MD_Image.py | 31 ++- monk/codeMarkDown/MD_IndentAndDot.py | 93 ++++++- monk/codeMarkDown/MD_Link.py | 56 ++-- monk/codeMarkDown/MD_ResultSelection.py | 32 +++ monk/codeMarkDown/MD_Specification.py | 4 +- monk/codeMarkDown/MD_Table.py | 48 +++- monk/codeMarkDown/MD_Text.py | 7 +- monk/codeMarkDown/MD_Title.py | 4 +- monk/codeMarkDown/MD_comment.py | 4 +- monk/codeMarkDown/MD_lineReturn.py | 4 +- .../{codeMarkDown.py => __init__.py} | 35 +-- monk/module.py | 117 +++++++-- monk/monkClass.py | 4 +- monk/monkEnum.py | 2 +- monk/monkHtml.py | 245 ++++++++++++------ monk/monkMethode.py | 8 +- monk/monkNamespace.py | 2 +- monk/monkNode.py | 2 + monk/monkParse.py | 20 +- monk/monkStruct.py | 2 +- monk/monkType.py | 4 +- monk/monkTypedef.py | 2 +- monk/monkUnion.py | 2 +- monk/monkUsing.py | 4 +- monk/monkVariable.py | 4 +- {theme => monk/theme}/base.css | 52 +++- {theme => monk/theme}/menu.css | 22 +- {theme => monk/theme}/menu_dynamic.css | 0 setup.py | 3 +- test/monk_testMonk.py | 6 +- 52 files changed, 741 insertions(+), 312 deletions(-) create mode 100644 monk/codeBB/__init__.py create mode 100644 monk/codeMarkDown/MD_ResultSelection.py rename monk/codeMarkDown/{codeMarkDown.py => __init__.py} (54%) rename {theme => monk/theme}/base.css (75%) rename {theme => monk/theme}/menu.css (67%) rename {theme => monk/theme}/menu_dynamic.css (100%) diff --git a/monk/__init__.py b/monk/__init__.py index a8fb297..43bbc45 100755 --- a/monk/__init__.py +++ b/monk/__init__.py @@ -20,6 +20,8 @@ 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) + ## ## @brief Display the help of this makefile ## @@ -77,33 +79,33 @@ def start(): debug.warning("Can not understand argument : '" + argument.get_option_name() + "'") usage() else: - module = module.get_module(argument.get_arg()) - module.parse_code() - module.generate() + module_value = module.get_module(argument.get_arg()) + module_value.parse_code() + module_value.generate() actionDone=True # if no action done : we do "all" ... if actionDone==False: #Must generate all docs : moduleElements = module.get_all_module() - for module in moduleElements: - module.parse_code() - for module in moduleElements: - module.generate() + for module_value in moduleElements: + module_value.parse_code() + for module_value in moduleElements: + module_value.generate() ## ## @brief When the user use with make.py we initialise ourself ## -if __name__ == '__main__': - sys.path.append(tools.get_run_folder()) - # Import all sub path without out and archive - for folder in os.listdir("."): - if os.path.isdir(folder)==True: - if folder.lower()!="android" \ - and folder.lower()!="archive" \ - and folder.lower()!="out" : - debug.debug("Automatic load path: '" + folder + "'") - module.import_path(folder) - start() +#if __name__ == '__main__': +sys.path.append(tools.get_run_folder()) +# Import all sub path without out and archive +for folder in os.listdir("."): + if os.path.isdir(folder)==True: + if folder.lower()!="android" \ + and folder.lower()!="archive" \ + and folder.lower()!="out" : + debug.debug("Automatic load path: '" + folder + "'") + module.import_path(folder) +start() diff --git a/monk/codeBB/BB_Code.py b/monk/codeBB/BB_Code.py index 9a0100c..018bf91 100644 --- a/monk/codeBB/BB_Code.py +++ b/monk/codeBB/BB_Code.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import codeHL import re @@ -16,7 +16,7 @@ import re ## @param[in] value String to transform. ## @return Transformed string. ## -def transcode(value): +def transcode(value, _base_path): #value = re.sub(r'\[code(( |\t|\n|\r)+style=(.*))?\](.*?)\[/code\]', value = re.sub(r'\[code(( |\t|\n|\r)+style=(.*?))?\](.*?)\[/code\]', replace_code, #r'
\4
', diff --git a/monk/codeBB/BB_Image.py b/monk/codeBB/BB_Image.py index 344ade6..8cc23c2 100644 --- a/monk/codeBB/BB_Image.py +++ b/monk/codeBB/BB_Image.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re @@ -12,7 +12,7 @@ import re ## @param[in] value String to transform. ## @return Transformed string. ## -def transcode(value): +def transcode(value, _base_path): return value diff --git a/monk/codeBB/BB_IndentAndDot.py b/monk/codeBB/BB_IndentAndDot.py index f5acdbf..5a1fca0 100644 --- a/monk/codeBB/BB_IndentAndDot.py +++ b/monk/codeBB/BB_IndentAndDot.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re @@ -42,7 +42,7 @@ import re ## @param[in] value String to transform. ## @return Transformed string. ## -def transcode(value): +def transcode(value, _base_path): value = re.sub(r'\n:', r'\n:INDENT:', diff --git a/monk/codeBB/BB_Link.py b/monk/codeBB/BB_Link.py index 5d9faab..fce8b5e 100644 --- a/monk/codeBB/BB_Link.py +++ b/monk/codeBB/BB_Link.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re @@ -14,7 +14,7 @@ import re ## @param[in] value String to transform. ## @return Transformed string. ## -def transcode(value): +def transcode(value, _base_path): # named link : [[http://plop.html | link name]] diff --git a/monk/codeBB/BB_Specification.py b/monk/codeBB/BB_Specification.py index 8c38845..fb7ce0c 100644 --- a/monk/codeBB/BB_Specification.py +++ b/monk/codeBB/BB_Specification.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re @@ -10,7 +10,7 @@ import re ## @param[in] value String to transform. ## @return Transformed string. ## -def transcode(value): +def transcode(value, _base_path): return value diff --git a/monk/codeBB/BB_Table.py b/monk/codeBB/BB_Table.py index 2144253..b56cadb 100644 --- a/monk/codeBB/BB_Table.py +++ b/monk/codeBB/BB_Table.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re @@ -35,7 +35,7 @@ import re ## @param[in] value String to transform. ## @return Transformed string. ## -def transcode(value): +def transcode(value, _base_path): return value diff --git a/monk/codeBB/BB_Text.py b/monk/codeBB/BB_Text.py index 9a1d672..0a40196 100644 --- a/monk/codeBB/BB_Text.py +++ b/monk/codeBB/BB_Text.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re @@ -21,7 +21,7 @@ import re ## @param[in] string String to transform. ## @return Transformed string. ## -def transcode(value): +def transcode(value, _base_path): value = re.sub(r'\[b\](.*?)\[/b\]', r'\1', diff --git a/monk/codeBB/BB_Title.py b/monk/codeBB/BB_Title.py index b612c2d..4ae0e91 100644 --- a/monk/codeBB/BB_Title.py +++ b/monk/codeBB/BB_Title.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re @@ -16,7 +16,7 @@ import re ## @param[in] value String to transform. ## @return Transformed string. ## -def transcode(value): +def transcode(value, _base_path): value = re.sub(r'=\?=(.*?)=\?=', r'

\1

', diff --git a/monk/codeBB/BB_comment.py b/monk/codeBB/BB_comment.py index 0dda159..db15128 100644 --- a/monk/codeBB/BB_comment.py +++ b/monk/codeBB/BB_comment.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re @@ -11,7 +11,7 @@ import re ## @param[in] value String to transform. ## @return Transformed string. ## -def transcode(value): +def transcode(value, _base_path): value = re.sub(r'\/\*(.*?)\*\/', r'', diff --git a/monk/codeBB/BB_lineReturn.py b/monk/codeBB/BB_lineReturn.py index 64a94d8..a571743 100644 --- a/monk/codeBB/BB_lineReturn.py +++ b/monk/codeBB/BB_lineReturn.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re @@ -11,7 +11,7 @@ import re ## @param[in] value String to transform. ## @return Transformed string. ## -def transcode(value): +def transcode(value, _base_path): value = re.sub(r'\r\n', r'\n', diff --git a/monk/codeBB/__init__.py b/monk/codeBB/__init__.py new file mode 100644 index 0000000..975cc6a --- /dev/null +++ b/monk/codeBB/__init__.py @@ -0,0 +1,52 @@ +#!/usr/bin/python +from realog import debug +import sys +from monk import tools +import re +import BB_Title +import BB_Text +import BB_IndentAndDot +import BB_Link +import BB_Image +import BB_Table + +import BB_comment +import BB_lineReturn +import BB_Code +import BB_Specification + +## +## @brief Transcode input data in the corect format. +## @param[in] string String to transform. +## @return Transformed string. +## +def transcode(value, _base_path = ""): + # remove html property + value = re.sub(r'<', r'<', value) + value = re.sub(r'>', r'>', value) + value = BB_comment.transcode(value, _base_path) + value = BB_Title.transcode(value, _base_path) + value = BB_Text.transcode(value, _base_path) + value = BB_IndentAndDot.transcode(value, _base_path) + value = BB_Link.transcode(value, _base_path) + value = BB_Image.transcode(value, _base_path) + value = BB_Table.transcode(value, _base_path) + value = BB_Code.transcode(value, _base_path) + value = BB_Specification.transcode(value, _base_path) + value = BB_lineReturn.transcode(value, _base_path) + return value + +## +## @brief transcode a BBcode file in a html file +## @return True if the file is transformed +## +def transcode_file(inputFileName, outputFileName): + inData = tools.file_read_data(inputFileName) + if inData == "": + return False + outData = transcode(inData) + debug.warning(" out: " + outputFileName) + tools.file_write_data(outputFileName, outData) + return True + + diff --git a/monk/codeBB/codeBB.py b/monk/codeBB/codeBB.py index 0802d8f..e69de29 100644 --- a/monk/codeBB/codeBB.py +++ b/monk/codeBB/codeBB.py @@ -1,52 +0,0 @@ -#!/usr/bin/python -from realog import debug -import sys -import monkTools -import re -import BB_Title -import BB_Text -import BB_IndentAndDot -import BB_Link -import BB_Image -import BB_Table - -import BB_comment -import BB_lineReturn -import BB_Code -import BB_Specification - -## -## @brief Transcode input data in the corect format. -## @param[in] string String to transform. -## @return Transformed string. -## -def transcode(value): - # remove html property - value = re.sub(r'<', r'<', value) - value = re.sub(r'>', r'>', value) - value = BB_comment.transcode(value) - value = BB_Title.transcode(value) - value = BB_Text.transcode(value) - value = BB_IndentAndDot.transcode(value) - value = BB_Link.transcode(value) - value = BB_Image.transcode(value) - value = BB_Table.transcode(value) - value = BB_Code.transcode(value) - value = BB_Specification.transcode(value) - value = BB_lineReturn.transcode(value) - return value - -## -## @brief transcode a BBcode file in a html file -## @return True if the file is transformed -## -def transcode_file(inputFileName, outputFileName): - inData = monkTools.file_read_data(inputFileName) - if inData == "": - return False - outData = transcode(inData) - debug.warning(" out: " + outputFileName) - monkTools.file_write_data(outputFileName, outData) - return True - - diff --git a/monk/codeHL/codeHL.py b/monk/codeHL/codeHL.py index de23e87..b5988f0 100644 --- a/monk/codeHL/codeHL.py +++ b/monk/codeHL/codeHL.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import codeHLcpp import codeHLBBcode import codeHLJava diff --git a/monk/codeHL/codeHLBBcode.py b/monk/codeHL/codeHLBBcode.py index 12e7b32..f7f3748 100644 --- a/monk/codeHL/codeHLBBcode.py +++ b/monk/codeHL/codeHLBBcode.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re diff --git a/monk/codeHL/codeHLJava.py b/monk/codeHL/codeHLJava.py index 12e7b32..f7f3748 100644 --- a/monk/codeHL/codeHLJava.py +++ b/monk/codeHL/codeHLJava.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re diff --git a/monk/codeHL/codeHLPython.py b/monk/codeHL/codeHLPython.py index 12e7b32..f7f3748 100644 --- a/monk/codeHL/codeHLPython.py +++ b/monk/codeHL/codeHLPython.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re diff --git a/monk/codeHL/codeHLXML.py b/monk/codeHL/codeHLXML.py index 4411211..711adba 100644 --- a/monk/codeHL/codeHLXML.py +++ b/monk/codeHL/codeHLXML.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re listRegExp = [ diff --git a/monk/codeHL/codeHLcpp.py b/monk/codeHL/codeHLcpp.py index 54b95dd..77ecd9f 100644 --- a/monk/codeHL/codeHLcpp.py +++ b/monk/codeHL/codeHLcpp.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re listRegExp = [ diff --git a/monk/codeHL/codeHLjson.py b/monk/codeHL/codeHLjson.py index 3210137..6b97553 100644 --- a/monk/codeHL/codeHLjson.py +++ b/monk/codeHL/codeHLjson.py @@ -1,10 +1,37 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re +listRegExp = [ + [ r'"((\\"|.)*?)"', 'code-text-quote'], + [ r"'(('|.)*?)'", 'code-text-quote'], + [ r'(true|false|null)', + 'code-type'], + [ r'(((0(x|X)[0-9a-fA-F]*)|(\d+\.?\d*|\.\d+)((e|E)(\+|\-)?\d+)?)(L|l|UL|ul|u|U|F|f)?)', + 'code-type'] +] 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 += '' + outValue += result.group() + outValue += '' + + # change the input value + inValue = inValue[result.end():] + # Search again ... + result = re.search(reg1, inValue, re.DOTALL) + outValue += inValue + return outValue diff --git a/monk/codeHL/codeHLshell.py b/monk/codeHL/codeHLshell.py index 6831448..569a2b6 100644 --- a/monk/codeHL/codeHLshell.py +++ b/monk/codeHL/codeHLshell.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re listRegExp = [ diff --git a/monk/codeMarkDown/MD_Code.py b/monk/codeMarkDown/MD_Code.py index 7c4ebf8..89eab2e 100644 --- a/monk/codeMarkDown/MD_Code.py +++ b/monk/codeMarkDown/MD_Code.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import codeHL import re @@ -16,7 +16,7 @@ import re ## @param[in] value String to transform. ## @return Transformed string. ## -def transcode(value): +def transcode(value, _base_path): #value = re.sub(r'\[code(( |\t|\n|\r)+style=(.*))?\](.*?)\[/code\]', """ value = re.sub(r'```(( |\t|\n|\r){\.(.*?))?\}(.*?)\```', @@ -24,6 +24,9 @@ def transcode(value): value, flags=re.DOTALL) """ + value = re.sub(r'```(.*?)```', + r'\1', + value) value = re.sub(r'```(( |\t|\n|\r)*(\{\.(.*?)\}))?(.*?)\```', replace_code, #r'
\4
', value, diff --git a/monk/codeMarkDown/MD_Image.py b/monk/codeMarkDown/MD_Image.py index 344ade6..e8ad189 100644 --- a/monk/codeMarkDown/MD_Image.py +++ b/monk/codeMarkDown/MD_Image.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re @@ -12,8 +12,33 @@ import re ## @param[in] value String to transform. ## @return Transformed string. ## -def transcode(value): - +def transcode(value, _base_path): + if len(_base_path) != 0: + base_path = (_base_path + '/').replace('/','__') + else: + base_path = "" + # named image : ![hover Value](http://sdfsdf.svg) + value = re.sub(r'!\[http://(.*?)\][ \t]*\((.*?)\)', + r'\1', + value) + value = re.sub(r'!\[https://(.*?)\][ \t]*\((.*?)\)', + r'\1', + value) + value = re.sub(r'!\[(.*?)\][ \t]*\((.*?)\?w=([0-9]+)%\)', + r'\1', + value) + value = re.sub(r'!\[(.*?)\][ \t]*\((.*?)\?w=([0-9]+)px\)', + r'\1', + value) + value = re.sub(r'!\[(.*?)\][ \t]*\((.*?)\?h=([0-9]+)px\)', + r'\1', + value) + value = re.sub(r'!\[(.*?)\][ \t]*\((.*?)\?w=([0-9]+)px&h=([0-9]+)px\)', + r'\1', + value) + value = re.sub(r'!\[(.*?)\][ \t]*\((.*?)\)', + r'\1', + value) return value diff --git a/monk/codeMarkDown/MD_IndentAndDot.py b/monk/codeMarkDown/MD_IndentAndDot.py index 7865960..183055e 100644 --- a/monk/codeMarkDown/MD_IndentAndDot.py +++ b/monk/codeMarkDown/MD_IndentAndDot.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re @@ -33,28 +33,99 @@ import re ## @param[in] value String to transform. ## @return Transformed string. ## -def transcode(value): - value = re.sub(r'\n(( - )|( * )|( # ))', - r'\n:INDENT:[STAR]', +def transcode(value, _base_path = ""): + value = re.sub(r'\n(( - )|( \* )|( # )|(\* ))', + r'\n:INDENT_1:[STAR]', value) - p = re.compile('((\:INDENT\:(.*?)\n)*)', + 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)\] ))', + r'\n:INDENT_1:[CHECK_BOX_1]', + value) + value = re.sub(r'\n( |\t)(( - )|( \* )|( # )|(\* ))', + r'\n:INDENT_1::INDENT_2:[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)\] ))', + 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) + 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)\] ))', + r'\n:INDENT_1::INDENT_2::INDENT_3:[CHECK_BOX_1]', + value) + p = re.compile('((\:INDENT_1\:(.*?)\n)*)', flags=re.DOTALL) - value = p.sub(replace_wiki_identation, + value = p.sub(replace_wiki_identation_1, value) + value = re.sub(r'\[STAR\](.*?)\n', r'
  • \1
  • ', value, flags=re.DOTALL) + value = re.sub(r'\[CHECK_BOX_1\](.*?)\n', + r'
  • \1
  • ', + value, + flags=re.DOTALL) + value = re.sub(r'\[CHECK_BOX_0\](.*?)\n', + r'
  • \1
  • ', + value, + flags=re.DOTALL) + + return value -def replace_wiki_identation(match): +def replace_wiki_identation_1(match): if match.group() == "": return "" #debug.verbose("plop: " + str(match.group())) - value = "" + + p = re.compile('((\:INDENT_2\:(.*?)\n)*)', + flags=re.DOTALL) + value = p.sub(replace_wiki_identation_2, + value) + + return value + +def replace_wiki_identation_2(match): + if match.group() == "": + return "" + #debug.verbose("plop: " + str(match.group())) + value = "" + + p = re.compile('((\:INDENT_3\:(.*?)\n)*)', + flags=re.DOTALL) + value = p.sub(replace_wiki_identation_3, + value) + + return value + +def replace_wiki_identation_3(match): + if match.group() == "": + return "" + #debug.verbose("plop: " + str(match.group())) + value = "" + return value + + diff --git a/monk/codeMarkDown/MD_Link.py b/monk/codeMarkDown/MD_Link.py index 5d9faab..1419aa9 100644 --- a/monk/codeMarkDown/MD_Link.py +++ b/monk/codeMarkDown/MD_Link.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re @@ -14,9 +14,9 @@ import re ## @param[in] value String to transform. ## @return Transformed string. ## -def transcode(value): - +def transcode(value, _base_path): + """ # named link : [[http://plop.html | link name]] value = re.sub(r'\[\[http://(.*?) \| (.*?)\]\]', r'\2', @@ -26,6 +26,15 @@ def transcode(value): value = re.sub(r'\[\[http://(.*?)\]\]', r'http://\1', value) + # named link : [[https://plop.html | link name]] + value = re.sub(r'\[\[https://(.*?) \| (.*?)\]\]', + r'\2', + value) + + # direct link : [[https://plop.html]] + value = re.sub(r'\[\[https://(.*?)\]\]', + r'http://\1', + value) # direct lib link : [lib[libname]] value = re.sub(r'\[lib\[(.*?) \| (.*?)\]\]', @@ -43,27 +52,42 @@ def transcode(value): value = re.sub(r'\[(lib|class|methode)\[(.*?)\]\]', replace_link_class, value) - """ - p = re.compile('\[\[(.*?)(|(.*?))\]\])', - flags=re.DOTALL) + if len(_base_path) != 0: + base_path = (_base_path + '/').replace('/','__') + else: + base_path = "" + # named image : ![hover Value](http://sdfsdf.svg) + value = re.sub(r'\[(.*?)\][ \t]*\(http://(.*?)\)', + r'\1', + value) + value = re.sub(r'\[(.*?)\][ \t]*\(https://(.*?)\)', + r'\1', + value) + """ + value = re.sub(r'\[(.*?)\][ \t]*\((.*?)\.md\)', + r'\1', + value) + """ + p = re.compile('\[(.*?)\][ \t]*\((.*?)\.md\)') value = p.sub(replace_link, value) - """ + p = re.compile('\[(.*?)\][ \t]*\((.*?)\)') + value = p.sub(replace_link, + value) + return value -""" + def replace_link(match): if match.group() == "": return "" - #debug.verbose("plop: " + str(match.group())) - value = "" - return transcode(value) -""" + debug.verbose("plop: " + str(match.group())) + value = '' + return value + def replace_link_class(match): if match.group() == "": diff --git a/monk/codeMarkDown/MD_ResultSelection.py b/monk/codeMarkDown/MD_ResultSelection.py new file mode 100644 index 0000000..1a6ab97 --- /dev/null +++ b/monk/codeMarkDown/MD_ResultSelection.py @@ -0,0 +1,32 @@ +#!/usr/bin/python +from realog import debug +import sys +from monk import tools +import re + + +## +## @brief Transcode +## commencez les lignes par: +## +def transcode(value, _base_path = ""): + p = re.compile('\[([a-zA-Z0-9_-\| ]*)\]', + flags=re.DOTALL) + value = p.sub(replace_result_list, + value) + return value + + +def replace_result_list(match): + if match.group() == "": + return "" + debug.warning("parse RESULT ... : '" + str(match.group()) + "'") + value = '' + tmpppp = match.group().replace("]", "").replace("[", "").replace("\n", "").split('|') + for elem in tmpppp: + if len(elem) == 0: + continue + value += '" + value += "
    ' + elem + "
    " + debug.warning(" ==> out " + value) + return value diff --git a/monk/codeMarkDown/MD_Specification.py b/monk/codeMarkDown/MD_Specification.py index 8c38845..fb7ce0c 100644 --- a/monk/codeMarkDown/MD_Specification.py +++ b/monk/codeMarkDown/MD_Specification.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re @@ -10,7 +10,7 @@ import re ## @param[in] value String to transform. ## @return Transformed string. ## -def transcode(value): +def transcode(value, _base_path): return value diff --git a/monk/codeMarkDown/MD_Table.py b/monk/codeMarkDown/MD_Table.py index 2144253..f641628 100644 --- a/monk/codeMarkDown/MD_Table.py +++ b/monk/codeMarkDown/MD_Table.py @@ -1,20 +1,15 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re ## ## @brief Transcode table: -## { | tableau_type_1 -## | [b]colone 1[/b] -## ligne 1 -## | colone 2 ligne 1 -## |--- -## | colone 1 ligne 1 -## | colone 2 ligne 2 -## |} +## | colone 1 || +## | ligne 1 | colone 2 ligne 1 | +## | colone 1 ligne 1 | colone 2 ligne 2| ## Avec autant de ligne et de colone que vous voullez.. ## Il est possible de faire des retour a la ligne dans une case du tableau... ## En bref sa tend a marcher comme sur un Wiki... @@ -28,15 +23,40 @@ import re ## | colone 1 ligne 1 | colone 2 ligne 2 | ## +------------------+------------------+ ## -## TODO : Create simple table like : -## | 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. ## -def transcode(value): +def transcode(value, _base_path): + p = re.compile('((\n\|(.*)\|)*)', + flags=re.DOTALL) + value = p.sub(replace_table, + value) return value + +def replace_table(match): + if match.group() == "": + return "" + #debug.verbose("plop: " + str(match.group())) + value = "" + p = re.compile('\n(.*)') + value += p.sub(replace_table_line, + match.group()) + value += "
    " + return value + +def replace_table_line(match): + if match.group() == "": + return "" + debug.warning("parse LINE ... : '" + str(match.group()) + "'") + value = "" + tmpppp = match.group().replace("\n", "").split('|') + for elem in tmpppp: + if len(elem) == 0: + continue + value += "" + elem + "" + value += "" + debug.warning(" ==> out " + value) + return value diff --git a/monk/codeMarkDown/MD_Text.py b/monk/codeMarkDown/MD_Text.py index a70d840..2740b7f 100644 --- a/monk/codeMarkDown/MD_Text.py +++ b/monk/codeMarkDown/MD_Text.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re @@ -21,7 +21,7 @@ import re ## @param[in] string String to transform. ## @return Transformed string. ## -def transcode(value): +def transcode(value, _base_path): value = re.sub(r'\*\*(.*?)\*\*', r'\1', @@ -36,11 +36,12 @@ def transcode(value): r'\1', value, flags=re.DOTALL) + """ value = re.sub(r'_(.*?)_', r'\1', value, flags=re.DOTALL) - + """ value = re.sub(r'____(.*?)\n', r'
    ', value, diff --git a/monk/codeMarkDown/MD_Title.py b/monk/codeMarkDown/MD_Title.py index d010915..53a9074 100644 --- a/monk/codeMarkDown/MD_Title.py +++ b/monk/codeMarkDown/MD_Title.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re @@ -16,7 +16,7 @@ import re ## @param[in] value String to transform. ## @return Transformed string. ## -def transcode(value): +def transcode(value, _base_path): value = "\n" + value diff --git a/monk/codeMarkDown/MD_comment.py b/monk/codeMarkDown/MD_comment.py index c37f610..8558e06 100644 --- a/monk/codeMarkDown/MD_comment.py +++ b/monk/codeMarkDown/MD_comment.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re _comment_code = "[comment]:" @@ -11,7 +11,7 @@ _comment_code = "[comment]:" ## @param[in] value String to transform. ## @return Transformed string. ## -def transcode(value): +def transcode(value, _base_path): out = ""; for elem in value.split("\n"): if len(elem) >= len(_comment_code) \ diff --git a/monk/codeMarkDown/MD_lineReturn.py b/monk/codeMarkDown/MD_lineReturn.py index 64a94d8..a571743 100644 --- a/monk/codeMarkDown/MD_lineReturn.py +++ b/monk/codeMarkDown/MD_lineReturn.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re @@ -11,7 +11,7 @@ import re ## @param[in] value String to transform. ## @return Transformed string. ## -def transcode(value): +def transcode(value, _base_path): value = re.sub(r'\r\n', r'\n', diff --git a/monk/codeMarkDown/codeMarkDown.py b/monk/codeMarkDown/__init__.py similarity index 54% rename from monk/codeMarkDown/codeMarkDown.py rename to monk/codeMarkDown/__init__.py index b482734..3fa67c2 100644 --- a/monk/codeMarkDown/codeMarkDown.py +++ b/monk/codeMarkDown/__init__.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug import sys -import monkTools +from monk import tools import re """ import BB_Link @@ -15,13 +15,17 @@ import MD_IndentAndDot import MD_Title import MD_comment import MD_lineReturn +import MD_Image import MD_Code +import MD_Link +import MD_Table +import MD_ResultSelection ## ## @brief Transcode input data in the corect format. ## @param[in] string String to transform. ## @return Transformed string. ## -def transcode(value): +def transcode(value, _base_path = ""): # remove html property value = re.sub(r'&', r'&', value) value = re.sub(r'<', r'<', value) @@ -29,19 +33,20 @@ def transcode(value): value = re.sub(r'\r\n', r'\n', value) value = re.sub(r'\n\r', r'\n', value) value = re.sub(r'\r', r'\n', value) - value = MD_comment.transcode(value) - value = MD_Title.transcode(value) - value = MD_IndentAndDot.transcode(value) - value = MD_Code.transcode(value) - value = MD_lineReturn.transcode(value) - value = MD_Text.transcode(value) + value = MD_comment.transcode(value, _base_path) + value = MD_Title.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_Text.transcode(value, _base_path) """ - value = BB_Text.transcode(value) - value = BB_Link.transcode(value) - value = BB_Image.transcode(value) - value = BB_Table.transcode(value) - value = BB_Specification.transcode(value) + value = BB_Text.transcode(value, _base_path) + value = BB_Specification.transcode(value, _base_path) """ + value = MD_Table.transcode(value, _base_path) + value = MD_Image.transcode(value, _base_path) + value = MD_Link.transcode(value, _base_path) + value = MD_ResultSelection.transcode(value, _base_path) value = MD_Code.transcode_part2(value) return value @@ -50,12 +55,12 @@ def transcode(value): ## @return True if the file is transformed ## def transcode_file(inputFileName, outputFileName): - inData = monkTools.file_read_data(inputFileName) + inData = tools.file_read_data(inputFileName) if inData == "": return False outData = transcode(inData) debug.warning(" out: " + outputFileName) - monkTools.file_write_data(outputFileName, outData) + tools.file_write_data(outputFileName, outData) return True diff --git a/monk/module.py b/monk/module.py index 7fc2d3d..89e7608 100644 --- a/monk/module.py +++ b/monk/module.py @@ -4,10 +4,10 @@ import os import inspect import fnmatch from realog import debug -import monkTools as tools -import monkNode as Node -import monkParse as Parse -import monkHtml +from . import tools +from . import monkNode as Node +from . import monkParse as Parse +from . import monkHtml import re import json @@ -30,7 +30,10 @@ class Module: # Name of the module self.name=moduleName self.list_doc_file = [] + self.list_image_file = [] self.list_tutorial_file = [] + self.list_manual_file = [] + self.list_test_file = [] self.web_site = "" self.web_source = "" self.path_parsing = "" @@ -115,9 +118,9 @@ class Module: tmpList = fnmatch.filter(filenames, "*.hpp") # Import the module : for filename in tmpList: - fileCompleteName = os.path.join(root, filename) - debug.debug(" Find a file : '" + fileCompleteName + "'") - self.add_file(fileCompleteName) + file_complete_name = os.path.join(root, filename) + debug.debug(" Find a file : '" + file_complete_name + "'") + self.add_file(file_complete_name) # all file is parset ==> now we create the namespacing of all elements: self.structure_lib.set_namespace() self.structure_lib.set_module_link(self) @@ -130,19 +133,36 @@ class Module: tmpList = fnmatch.filter(filenames, "*.md") # Import the module : for filename in tmpList: - fileCompleteName = os.path.join(root, filename) - tutorialPath = os.path.join(self.path_global_doc, "tutorial/") - pathBase = fileCompleteName[len(self.path_global_doc):len(fileCompleteName)-3] - while len(pathBase) > 0 \ - and pathBase[0] == '/': - pathBase = pathBase[1:] - debug.verbose(" Find a doc file : fileCompleteName='" + fileCompleteName + "'") - if fileCompleteName[:len(tutorialPath)] == tutorialPath: - debug.warning("add_tutorial_doc : '" + fileCompleteName + "' ==> '" + pathBase + "'") - self.add_tutorial_doc(fileCompleteName, pathBase) + file_complete_name = os.path.join(root, filename) + tutorial_path = os.path.join(self.path_global_doc, "tutorial/") + test_path = os.path.join(self.path_global_doc, "test/") + manual_path = os.path.join(self.path_global_doc, "manual/") + path_base = file_complete_name[len(self.path_global_doc):len(file_complete_name)-3] + while len(path_base) > 0 \ + and path_base[0] == '/': + path_base = path_base[1:] + debug.verbose(" Find a doc file : file_complete_name='" + file_complete_name + "'") + if file_complete_name[:len(tutorial_path)] == tutorial_path: + debug.warning("add_tutorial_doc : '" + file_complete_name + "' ==> '" + path_base + "'") + self.add_tutorial_doc(file_complete_name, path_base) + elif file_complete_name[:len(test_path)] == test_path: + debug.warning("add_test_doc : '" + file_complete_name + "' ==> '" + path_base + "'") + self.add_test_doc(file_complete_name, path_base) + elif file_complete_name[:len(manual_path)] == manual_path: + debug.warning("add_user_manual_doc : '" + file_complete_name + "' ==> '" + path_base + "'") + self.add_user_manual_doc(file_complete_name, path_base) else: - debug.warning("add_file_doc : '" + fileCompleteName + "' ==> '" + pathBase + "'") - self.add_file_doc(fileCompleteName, pathBase) + debug.warning("add_file_doc : '" + file_complete_name + "' ==> '" + path_base + "'") + self.add_file_doc(file_complete_name, path_base) + for root, dirnames, filenames in os.walk(self.path_global_doc): + for filename in filenames: + if not filename.endswith(('.jpg', '.JPG', '.jpeg', '.JPEG', '.png', '.PNG', '.svg', '.SVG', '.gif', '.GIF', '.tga', '.TGA')): + continue + file_complete_name = os.path.join(root, filename) + path_base = file_complete_name[len(self.path_global_doc)+1:] + debug.verbose(" Find a doc file : file_complete_name='" + file_complete_name + "'") + debug.warning("add_image_doc: '" + file_complete_name + "' ==> '" + path_base + "'") + self.add_image_doc(file_complete_name, path_base) ## ## @brief Sort a list of n element containing a list of element (order with the first) @@ -181,6 +201,24 @@ class Module: self.list_doc_file.append([filename, outPath]) self.list_doc_file = self.sort_list_first_elem(self.list_doc_file) + ## + ## @brief Add a documentation image file to copy to the output + ## @param[in] filename File To add in the output documentation. + ## @param[in] outPath output system file. + ## @return True if no error occured, False otherwise + ## + def add_image_doc(self, filename, outPath): + debug.debug("adding file in documantation : '" + filename + "'"); + done = False + for iii in range(0,len(self.list_image_file)): + if self.list_image_file[iii][0] > filename: + self.list_image_file.insert(iii, [filename, outPath]) + done = True + break + if done == False: + self.list_image_file.append([filename, outPath]) + self.list_image_file = self.sort_list_first_elem(self.list_image_file) + ## ## @brief Add a documentation file at the parsing system ## @param[in] filename File To add at the parsing element system. @@ -188,7 +226,7 @@ class Module: ## @return True if no error occured, False otherwise ## def add_tutorial_doc(self, filename, outPath): - count = int(filename.split('/')[-1].split('_')[0]) + #count = int(filename.split('/')[-1].split('_')[0]) debug.debug("adding file in documantation : '" + filename + "'"); done = False for iii in range(0,len(self.list_tutorial_file)): @@ -201,6 +239,45 @@ class Module: self.list_tutorial_file = self.sort_list_first_elem(self.list_tutorial_file) + ## + ## @brief Add a documentation file at the parsing system + ## @param[in] filename File To add at the parsing element system. + ## @param[in] outPath output system file. + ## @return True if no error occured, False otherwise + ## + def add_user_manual_doc(self, filename, outPath): + #count = int(filename.split('/')[-1].split('_')[0]) + debug.debug("adding file in user manual documantation : '" + filename + "'"); + done = False + for iii in range(0,len(self.list_tutorial_file)): + if self.list_manual_file[iii][0] > filename: + self.list_manual_file.insert(iii, [filename, outPath]) + done = True + break + if done == False: + self.list_manual_file.append([filename, outPath]) + self.list_manual_file = self.sort_list_first_elem(self.list_manual_file) + + ## + ## @brief Add a documentation file at the parsing system + ## @param[in] filename File To add at the parsing element system. + ## @param[in] outPath output system file. + ## @return True if no error occured, False otherwise + ## + def add_test_doc(self, filename, outPath): + #count = int(filename.split('/')[-1].split('_')[0]) + debug.debug("adding file in test documantation : '" + filename + "'"); + done = False + for iii in range(0,len(self.list_tutorial_file)): + if self.list_test_file[iii][0] > filename: + self.list_test_file.insert(iii, [filename, outPath]) + done = True + break + if done == False: + self.list_test_file.append([filename, outPath]) + self.list_test_file = self.sort_list_first_elem(self.list_test_file) + + ## ## @brief Add a file at the parsing system ## @param[in] filename File To add at the parsing element system. diff --git a/monk/monkClass.py b/monk/monkClass.py index ed44ea4..56c450d 100644 --- a/monk/monkClass.py +++ b/monk/monkClass.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug -import monkNode as Node -import monkModule as module +from . import monkNode as Node +from . import module ## diff --git a/monk/monkEnum.py b/monk/monkEnum.py index 758cd10..65f4613 100644 --- a/monk/monkEnum.py +++ b/monk/monkEnum.py @@ -1,6 +1,6 @@ #!/usr/bin/python from realog import debug -import monkNode as Node +from . import monkNode as Node class Enum(Node.Node): def __init__(self, stack=[], file="", lineNumber=0, documentation=[]): diff --git a/monk/monkHtml.py b/monk/monkHtml.py index dbbe2fe..b150cb9 100644 --- a/monk/monkHtml.py +++ b/monk/monkHtml.py @@ -5,11 +5,11 @@ from . import tools #import CppHeaderParser import os import re -import codeBB -import codeMarkDown +from . import codeBB +from . import codeMarkDown import collections -import monkModule as module -import monkNode as node +from . import module +from . import monkNode as node htmlCodes = ( ('&', '&'), @@ -310,9 +310,12 @@ def write_methode(element, namespaceStack, displaySize = None, link = True): ret += '
    ' return ret -def generate_stupid_index_page(outFolder, header, footer, my_lutin_doc): +def generate_stupid_index_page(my_lutin_doc, out_folder): + header = create_generic_header(my_lutin_doc, out_folder) + footer = create_generic_footer(my_lutin_doc, out_folder) + # create index.hml : - filename = outFolder + "/index.html" + filename = out_folder + "/index.html" tools.create_directory_of_file(filename); file = open(filename, "w") file.write(header) @@ -324,15 +327,19 @@ def generate_stupid_index_page(outFolder, header, footer, my_lutin_doc): file.write(footer) file.close(); -def generate_page(outFolder, header, footer, element, name_lib=""): +def generate_page(my_lutin_doc, out_folder, element, name_lib=""): + + header = create_generic_header(my_lutin_doc, out_folder) + footer = create_generic_footer(my_lutin_doc, out_folder) + debug.print_element("code-doc", name_lib, "<==", element.name) currentPageSite = element.get_doc_website_page() namespaceStack = element.get_namespace() 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(outFolder, header, footer, elem['node'], name_lib) - filename = outFolder + '/' + generate_html_page_name(element) + generate_page(out_folder, header, footer, elem['node'], name_lib) + filename = out_folder + '/' + generate_html_page_name(element) tools.create_directory_of_file(filename); file = open(filename, "w") file.write(header) @@ -627,11 +634,10 @@ def generate_page(outFolder, header, footer, element, name_lib=""): - -def generate(my_lutin_doc, outFolder) : +def create_generic_header(my_lutin_doc, out_folder) : my_doc = my_lutin_doc.get_base_doc_node() - tools.copy_file(tools.get_current_path(__file__)+"/theme/base.css", outFolder+"/base.css") - tools.copy_file(tools.get_current_path(__file__)+"/theme/menu.css", outFolder+"/menu.css") + tools.copy_file(tools.get_current_path(__file__)+"/theme/base.css", out_folder+"/base.css") + tools.copy_file(tools.get_current_path(__file__)+"/theme/menu.css", out_folder+"/menu.css") # create common header generic_header = '\n' generic_header += '\n' @@ -650,40 +656,79 @@ def generate(my_lutin_doc, outFolder) : generic_header += '

    ' + my_doc.get_name() + '

    \n' if my_lutin_doc.get_website_sources() != '': generic_header += '

       [ sources ]

    \n' - generic_header += '

    API:

    ' - generic_header += ' \n' + + api_menu = generate_menu(my_doc) + if len(api_menu) != 0: + generic_header += '

    API:

    ' + generic_header += ' \n' + # TODO : add Generic doc main point. - if len(my_lutin_doc.list_doc_file) > 0: - docList = "" - for docInputName,outpath in my_lutin_doc.list_doc_file: - outputFileName = outFolder + "/" + outpath.replace('/','_') +".html" - outputFileName = outputFileName.split('/')[-1] - name = outputFileName.split('_')[-1][:-5] + if len(my_lutin_doc.list_manual_file) > 0: + manual_list = "" + for doc_input_name,outpath in my_lutin_doc.list_manual_file: + output_file_name = out_folder + "/" + outpath.replace('/','__') +".html" + output_file_name = output_file_name.split('/')[-1] + name = output_file_name.split('_')[-1][:-5] if name == "index": continue - docList += '' - if docList != "": + manual_list += '' + if manual_list != "": + generic_header += '

    User manual:

    ' + generic_header += '\n' + + # TODO : add Generic doc main point. + if len(my_lutin_doc.list_doc_file) > 0: + doc_list = "" + for doc_input_name,outpath in my_lutin_doc.list_doc_file: + output_file_name = out_folder + "/" + outpath.replace('/','__') +".html" + output_file_name = output_file_name.split('/')[-1] + base_name_rework = output_file_name.split('__')[-1] + name_list = base_name_rework.split('_') + debug.warning(str(name_list)) + if len(name_list) >= 2: + name = base_name_rework[len(name_list[0])+1:].replace("_", " ") + else: + name = base_name_rework + name = name[:-5] + debug.warning(name) + + if name == "index": + continue + doc_list += '' + if doc_list != "": generic_header += '

    Documentation:

    ' generic_header += '\n' + # TODO : add Tutorial doc main point. if len(my_lutin_doc.list_tutorial_file) > 0: tutorialList = "" - for docInputName,outpath in my_lutin_doc.list_tutorial_file: - outputFileName = outFolder + "/" + outpath+".html" - outputFileName = outputFileName.split('/')[-1] - name = outputFileName.split('_')[-1][:-5] + for doc_input_name,outpath in my_lutin_doc.list_tutorial_file: + output_file_name = out_folder + "/" + outpath+".html" + output_file_name = output_file_name.split('/')[-1] + base_name_rework = output_file_name.split('__')[-1] + name_list = base_name_rework.split('_') + #debug.warning(str(name_list)) + if len(name_list) >= 2: + name = base_name_rework[len(name_list[0])+1:].replace("_", " ") + else: + name = base_name_rework + name = name[:-5] if name == "index": continue tutorialList += '' if tutorialList != "": generic_header += '

    Tutorials:

    ' @@ -691,6 +736,30 @@ def generate(my_lutin_doc, outFolder) : generic_header += tutorialList generic_header += '\n' + if len(my_lutin_doc.list_test_file) > 0: + test_list = "" + for doc_input_name,outpath in my_lutin_doc.list_test_file: + output_file_name = out_folder + "/" + outpath.replace('/','__') +".html" + output_file_name = output_file_name.split('/')[-1] + base_name_rework = output_file_name.split('__')[-1] + name_list = base_name_rework.split('_') + #debug.warning(str(name_list)) + if len(name_list) >= 2: + name = base_name_rework[len(name_list[0])+1:].replace("_", " ") + else: + name = base_name_rework + name = name[:-5] + #debug.error(str(name)) + if name == "index": + continue + test_list += '' + if test_list != "": + generic_header += '

    Tests process:

    ' + generic_header += '\n' localWebsite = my_lutin_doc.get_website() # add other libs entry point : @@ -719,10 +788,19 @@ def generate(my_lutin_doc, outFolder) : generic_header += "
    \n" generic_header += "
    \n" generic_header += "
    \n" + generic_header += '\n' generic_header += " \n" generic_header += " \n" generic_header += "
    \n" + return generic_header + +def create_generic_footer(my_lutin_doc, out_folder) : + my_doc = my_lutin_doc.get_base_doc_node() + tools.copy_file(tools.get_current_path(__file__)+"/theme/base.css", out_folder+"/base.css") + tools.copy_file(tools.get_current_path(__file__)+"/theme/menu.css", out_folder+"/menu.css") + + generic_footer = "
    \n" googleData = tools.file_read_data("google-analytics.txt") if googleData != "": @@ -731,63 +809,78 @@ def generate(my_lutin_doc, outFolder) : generic_footer += "\n" generic_footer += "\n" + return generic_footer + +def generate(my_lutin_doc, out_folder) : + my_doc = my_lutin_doc.get_base_doc_node() + tools.copy_file(tools.get_current_path(__file__)+"/theme/base.css", out_folder+"/base.css") + tools.copy_file(tools.get_current_path(__file__)+"/theme/menu.css", out_folder+"/menu.css") + # create index.hml: - generate_stupid_index_page(outFolder, generic_header, generic_footer, my_lutin_doc) + generate_stupid_index_page(my_lutin_doc, out_folder) # create the namespace index properties: - generate_page(outFolder, generic_header, generic_footer, my_doc, name_lib=my_lutin_doc.name) + generate_page(my_lutin_doc, out_folder, my_doc, name_lib=my_lutin_doc.name) for iii in range(0, len(my_lutin_doc.list_tutorial_file)) : - docInputName,outpath = my_lutin_doc.list_tutorial_file[iii] + doc_input_name,outpath = my_lutin_doc.list_tutorial_file[iii] - debug.print_element("tutorial", my_lutin_doc.name, "<==", docInputName) + debug.print_element("tutorial", my_lutin_doc.name, "<==", doc_input_name) if outpath[0] == '/': outpath = outpath[1:] - outputFileName = os.path.join(outFolder, outpath.replace('/','_') + ".html") - debug.debug("output file : " + outputFileName + " out path=" + outFolder + " baseName=" + outpath) - tools.create_directory_of_file(outputFileName) - name = outputFileName.split('_')[-1][:-5] - inData = tools.file_read_data(docInputName) + output_file_name = os.path.join(out_folder, outpath.replace('/','__') + ".html") + debug.debug("output file : " + output_file_name + " out path=" + out_folder + " baseName=" + outpath) + tools.create_directory_of_file(output_file_name) + name = output_file_name.split('_')[-1][:-5] + inData = tools.file_read_data(doc_input_name) if inData == "": continue - outData = generic_header - localHeader = "" - localHeader += "=?=" + camel_case_decode(name) + "=?=\n___________________________\n" + outData = create_generic_header(my_lutin_doc, out_folder) + local_header = "" + local_header += "=?=" + camel_case_decode(name) + "=?=\n___________________________\n" if iii != 0: - previousName, previousOutpath = my_lutin_doc.list_tutorial_file[iii-1] - previousName = previousName.split('_')[-1][:-3] - previousOutpath = previousOutpath.split('/')[-1] - localHeader += "[left][tutorial[" + previousOutpath + " | Previous: " + capitalise_first_letter(camel_case_decode(previousName)) + "]][/left] " + previous_name, previous_out_path = my_lutin_doc.list_tutorial_file[iii-1] + previous_name = previous_name.split('_')[-1][:-3] + previous_out_path = previous_out_path.split('/')[-1] + local_header += "[left][tutorial[" + previous_out_path + " | Previous: " + capitalise_first_letter(camel_case_decode(previous_name)) + "]][/left] " if iii != len(my_lutin_doc.list_tutorial_file)-1: - nextName, nextOutpath = my_lutin_doc.list_tutorial_file[iii+1] - nextName = nextName.split('_')[-1][:-3] - nextOutpath = nextOutpath.split('/')[-1] - localHeader += " [right][tutorial[" + nextOutpath + " | Next: " + capitalise_first_letter(camel_case_decode(nextName)) + "]][/right]" - localHeader += "\n" - outData += codeBB.transcode(localHeader) - #debug.info(localHeader) - if docInputName[-2:] == "bb": + next_name, next_out_path = my_lutin_doc.list_tutorial_file[iii+1] + next_name = next_name.split('_')[-1][:-3] + next_out_path = next_out_path.split('/')[-1] + local_header += " [right][tutorial[" + next_out_path + " | Next: " + capitalise_first_letter(camel_case_decode(next_name)) + "]][/right]" + local_header += "\n" + outData += codeBB.transcode(local_header) + #debug.info(local_header) + if doc_input_name[-2:] == "bb": outData += codeBB.transcode(inData) - elif docInputName[-2:] == "md": + elif doc_input_name[-2:] == "md": outData += codeMarkDown.transcode(inData) outData += genericFooter - tools.file_write_data(outputFileName, outData) + 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 : + debug.print_element("doc", my_lutin_doc.name, "<==", doc_input_name) + base_path = os.path.dirname(outpath) + + output_file_name = out_folder + outpath.replace('/','__') + ".html" + debug.debug("output file : " + output_file_name) + tools.create_directory_of_file(output_file_name) + inData = tools.file_read_data(doc_input_name) + if inData == "": + continue + outData = create_generic_header(my_lutin_doc, out_folder) + if doc_input_name[-2:] == "bb": + outData += codeBB.transcode(inData, base_path) + elif doc_input_name[-2:] == "md": + outData += codeMarkDown.transcode(inData, base_path) + outData += create_generic_footer(my_lutin_doc, out_folder) + tools.file_write_data(output_file_name, outData) - for docInputName,outpath in my_lutin_doc.list_doc_file : - debug.print_element("doc", my_lutin_doc.name, "<==", docInputName) - outputFileName = outFolder + outpath + ".html" - debug.debug("output file : " + outputFileName) - tools.create_directory_of_file(outputFileName) - inData = tools.file_read_data(docInputName) - if inData == "": - continue - outData = generic_header - if docInputName[-2:] == "bb": - outData += codeBB.transcode(inData) - elif docInputName[-2:] == "md": - outData += codeMarkDown.transcode(inData) - outData += generic_footer - tools.file_write_data(outputFileName, outData) + + for image_input_name,outpath in my_lutin_doc.list_image_file: + debug.print_element("image", my_lutin_doc.name, "<==", image_input_name) + output_file_name = out_folder + outpath.replace('/','__') + tools.copy_file(image_input_name, output_file_name) diff --git a/monk/monkMethode.py b/monk/monkMethode.py index 92fc510..33c2579 100644 --- a/monk/monkMethode.py +++ b/monk/monkMethode.py @@ -1,8 +1,8 @@ ##!/usr/bin/python from realog import debug -import monkNode as Node -import monkType as Type -import monkVariable as Variable +from . import monkNode as Node +from . import monkType as Type +from . import monkVariable as Variable class Methode(Node.Node): def __init__(self, stack=[], file="", lineNumber=0, documentation=[], className = ""): @@ -65,7 +65,7 @@ class Methode(Node.Node): while len(stack) > 0\ and ( stack[0] == 'virtual'\ or stack[0] == 'static'\ - or stack[0] == 'inline'):: + or stack[0] == 'inline'): if stack[0] == 'virtual': self.virtual = True stack = stack[1:] diff --git a/monk/monkNamespace.py b/monk/monkNamespace.py index 61d3cb3..df20fdd 100644 --- a/monk/monkNamespace.py +++ b/monk/monkNamespace.py @@ -1,6 +1,6 @@ #!/usr/bin/python from realog import debug -import monkNode as Node +from . import monkNode as Node class Namespace(Node.Node): def __init__(self, stack=[], file="", lineNumber=0, documentation=[]): diff --git a/monk/monkNode.py b/monk/monkNode.py index 479d8b1..cae62f0 100644 --- a/monk/monkNode.py +++ b/monk/monkNode.py @@ -226,6 +226,8 @@ class Node(): def get_doc_website_page(self): if self.module_link == None: return "" + if self.module_link.get_website() == "": + return "" ret = self.module_link.get_website() if ret[-1] != '/': ret += '/' diff --git a/monk/monkParse.py b/monk/monkParse.py index 38750a6..04db8ba 100644 --- a/monk/monkParse.py +++ b/monk/monkParse.py @@ -15,16 +15,16 @@ import lex import inspect from realog import debug -import monkClass as Class -import monkNamespace as Namespace -import monkStruct as Struct -import monkUnion as Union -import monkMethode as Methode -import monkEnum as Enum -import monkVariable as Variable -import monkNode as Node -import monkUsing as Using -import monkTypedef as Typedef +from . import monkClass as Class +from . import monkNamespace as Namespace +from . import monkStruct as Struct +from . import monkUnion as Union +from . import monkMethode as Methode +from . import monkEnum as Enum +from . import monkVariable as Variable +from . import monkNode as Node +from . import monkUsing as Using +from . import monkTypedef as Typedef tokens = [ 'NUMBER', diff --git a/monk/monkStruct.py b/monk/monkStruct.py index d620da0..90d18c8 100644 --- a/monk/monkStruct.py +++ b/monk/monkStruct.py @@ -1,6 +1,6 @@ #!/usr/bin/python from realog import debug -import monkNode as Node +from . import monkNode as Node class Struct(Node.Node): def __init__(self, stack=[], file="", lineNumber=0, documentation=[]): diff --git a/monk/monkType.py b/monk/monkType.py index 0677b32..4fc8b43 100644 --- a/monk/monkType.py +++ b/monk/monkType.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug -import monkType as Type -import monkNode as node +from . import monkType as Type +from . import monkNode as node from . import module import re diff --git a/monk/monkTypedef.py b/monk/monkTypedef.py index 09c4d80..f7dcb54 100644 --- a/monk/monkTypedef.py +++ b/monk/monkTypedef.py @@ -1,6 +1,6 @@ #!/usr/bin/python from realog import debug -import monkNode as Node +from . import monkNode as Node class Typedef(Node.Node): def __init__(self, stack=[], file="", lineNumber=0, documentation=[]): diff --git a/monk/monkUnion.py b/monk/monkUnion.py index ff103e6..73f5de5 100644 --- a/monk/monkUnion.py +++ b/monk/monkUnion.py @@ -1,6 +1,6 @@ #!/usr/bin/python from realog import debug -import monkNode as Node +from . import monkNode as Node class Union(Node.Node): def __init__(self, stack=[], file="", lineNumber=0, documentation=[]): diff --git a/monk/monkUsing.py b/monk/monkUsing.py index 4d3473d..fcdf4ec 100644 --- a/monk/monkUsing.py +++ b/monk/monkUsing.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug -import monkNode as Node -import monkType as Type +from . import monkNode as Node +from . import monkType as Type class Using(Node.Node): def __init__(self, stack=[], file="", lineNumber=0, documentation=[]): diff --git a/monk/monkVariable.py b/monk/monkVariable.py index 769c34e..d377dbb 100644 --- a/monk/monkVariable.py +++ b/monk/monkVariable.py @@ -1,7 +1,7 @@ #!/usr/bin/python from realog import debug -import monkType as Type -import monkNode as Node +from . import monkType as Type +from . import monkNode as Node class Variable(Node.Node): def __init__(self, stack=[], file="", lineNumber=0, documentation=[]): diff --git a/theme/base.css b/monk/theme/base.css similarity index 75% rename from theme/base.css rename to monk/theme/base.css index d350ffe..622020f 100644 --- a/theme/base.css +++ b/monk/theme/base.css @@ -29,6 +29,10 @@ body { overflow: visible; color: #ffffff; display: block; + background-image: url('entreprise.png'); + background-repeat: no-repeat; + background-attachment: fixed; + background-position: center; } .navbar div { @@ -47,12 +51,12 @@ body { right: 0; left: 0; margin-bottom: 0; - background-color: #d44413; - border: 1px solid #c64012; + background-color: #7fac1e; + border: 1px solid #7fac1e; font-size: 15px; font-weight: 200; color: #ffffff; - text-shadow: 0 1px 0 #ce4213; + text-shadow: 0 1px 0 #3b510c; padding: 10px 20px 10px; margin-left: -20px; overflow:scroll; @@ -79,6 +83,28 @@ p { display: block; } +code { + background-color: rgb(251, 229, 225); + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; + border-top-left-radius: 4px; + border-top-right-radius: 4px; + box-sizing: border-box; + color: rgb(192, 52, 29); + font-size: 13px; + font-weight: 400; + line-height: 18.9px; + margin-top: 0px; + overflow-wrap: normal; + padding-bottom: 2px; + padding-left: 4px; + padding-right: 4px; + padding-top: 2px; + text-align: start; + white-space: pre-wrap; + word-break: keep-all; +} + pre { #margin-left: 20px; display: block; @@ -201,3 +227,23 @@ pre { text-decoration:none; color:#006cb4; } + +table { + border-collapse:collapse; +} +td { + padding:4px; + border:1px solid #000; + vertical-align:top; +} + +#my-table { + width:30%; + border-collapse:collapse; +} +#my-table td{ + width:2000px; + padding:4px; + border:1px solid #000; + vertical-align:top; +} \ No newline at end of file diff --git a/theme/menu.css b/monk/theme/menu.css similarity index 67% rename from theme/menu.css rename to monk/theme/menu.css index 5b3f470..6659693 100644 --- a/theme/menu.css +++ b/monk/theme/menu.css @@ -2,8 +2,8 @@ /*----------------MENU-----------------*/ div#menu { - border-left: 4px solid #8d2d0d; - border-bottom: 4px solid #8d2d0d; + border-left: 4px solid #3b510c; + border-bottom: 4px solid #3b510c; padding-left: 4px; padding-bottom: 4px; } @@ -14,24 +14,24 @@ div#menu h2{ margin: 0; padding: 3px; padding-left: 6px; - background: #d44413; + background: #70981a; } div#menu h3{ margin: 0; padding: 6px; - background: #d44413; + background: #70981a; } div#menu a{ color: #000000; - bgcolor=#d44413; + bgcolor=#70981a; FONT-FAMILY: Arial; FONT-SIZE: 9pt; } div#menu li { list-style:none; width:160px; - border-top: 1px solid #d44413; + border-top: 1px solid #70981a; } div#menu ul { @@ -44,19 +44,19 @@ div#menu li a { padding: 2px 0px 2px 4px; text-decoration: none; width:160px; - border-left: 4px solid #8d2d0d; + border-left: 4px solid #70981a; } div#menu ul.niveau1 ul { - border-left: 20px solid #d44413; - background: #1a62db; + border-left: 20px solid #70981a; + background: #739d19; } div#menu ul.niveau1 li { - background: #b43a10; + background: #638716; } div#menu li a:hover { - border-left-color: #ff3800; + border-left-color: #b3f329; font-weight:bold; } diff --git a/theme/menu_dynamic.css b/monk/theme/menu_dynamic.css similarity index 100% rename from theme/menu_dynamic.css rename to monk/theme/menu_dynamic.css diff --git a/setup.py b/setup.py index ab52ca1..8f05370 100755 --- a/setup.py +++ b/setup.py @@ -37,7 +37,8 @@ setup(name='monk', packages=['monk', 'monk/codeBB', 'monk/codeHL', - 'monk/codeMarkDown'], + 'monk/codeMarkDown', + 'monk/theme'], classifiers=[ 'Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)', diff --git a/test/monk_testMonk.py b/test/monk_testMonk.py index d259a3a..3adc404 100644 --- a/test/monk_testMonk.py +++ b/test/monk_testMonk.py @@ -1,13 +1,13 @@ #!/usr/bin/python -import monkModule -import monkTools as tools +from monk import module +from monk import tools as tools def get_desc(): return "monk test all element that is capable" def create(): # module name is 'ewol' and type binary. - myModule = monkModule.Module(__file__, 'testMonk', 'LIBRARY') + myModule = module.Module(__file__, 'testMonk', 'LIBRARY') # enable doculentation : myModule.set_website("http://heeroyui.github.io/monk/") myModule.set_website_sources("http://github.com/heeroyui/monk/test/")