[DEV] add basic tutorial system documentation
This commit is contained in:
parent
6c5d034e77
commit
4caa15d422
26
codeBB/BB_Code.py
Normal file
26
codeBB/BB_Code.py
Normal file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/python
|
||||
import lutinDebug as debug
|
||||
import sys
|
||||
import lutinTools
|
||||
import re
|
||||
|
||||
|
||||
##
|
||||
## @brief Transcode balise :
|
||||
## [code language=cpp]
|
||||
## int main(void) {
|
||||
## return 0;
|
||||
## }
|
||||
## [/code]
|
||||
## @param[in] value String to transform.
|
||||
## @return Transformed string.
|
||||
##
|
||||
def transcode(value):
|
||||
|
||||
value = re.sub(r'\[code=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]',
|
||||
r'<span style="color: \1;">\2</span>',
|
||||
value)
|
||||
|
||||
return value
|
||||
|
||||
|
19
codeBB/BB_Image.py
Normal file
19
codeBB/BB_Image.py
Normal file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/python
|
||||
import lutinDebug as debug
|
||||
import sys
|
||||
import lutinTools
|
||||
import re
|
||||
|
||||
|
||||
##
|
||||
## @brief Transcode balise:
|
||||
## [img w=125 h=45]dossier/image.jpg[/img]
|
||||
## [img w=125 h=45]http://plop.com/dossier/image.png[/img]
|
||||
## @param[in] value String to transform.
|
||||
## @return Transformed string.
|
||||
##
|
||||
def transcode(value):
|
||||
|
||||
return value
|
||||
|
||||
|
70
codeBB/BB_IndentAndDot.py
Normal file
70
codeBB/BB_IndentAndDot.py
Normal file
@ -0,0 +1,70 @@
|
||||
#!/usr/bin/python
|
||||
import lutinDebug as debug
|
||||
import sys
|
||||
import lutinTools
|
||||
import re
|
||||
|
||||
|
||||
##
|
||||
## @brief Transcode
|
||||
## commencez les ligne par ":" comme:
|
||||
## : 1
|
||||
## : 2
|
||||
## ::2.1
|
||||
## ::2.2
|
||||
## :::2.2.1
|
||||
## ::::2.2.1.1
|
||||
## :::::2.2.1.1.1
|
||||
## ::2.3
|
||||
## :3
|
||||
## resultat:
|
||||
##
|
||||
## 1
|
||||
## 2
|
||||
## 2.1
|
||||
## 2.2
|
||||
## 2.2.1
|
||||
## 2.2.1.1
|
||||
## 2.3
|
||||
## 3
|
||||
##
|
||||
## note: lorsque vous sautez une ligne, la liste sarraite et en recommence une autre...
|
||||
##
|
||||
## Il est possible de mettre des ":" sans ligne appres ce qui genere une ligne vide..
|
||||
##
|
||||
## AND DOT
|
||||
## **Ma ligne2 star consecutives engendrent des points quelque soit la position dans la ligne...
|
||||
##
|
||||
## Resultat:
|
||||
##
|
||||
## * premiere ligne
|
||||
## * deusieme ligne
|
||||
## @param[in] value String to transform.
|
||||
## @return Transformed string.
|
||||
##
|
||||
def transcode(value):
|
||||
|
||||
value = re.sub(r'\n:',
|
||||
r'\n:INDENT:',
|
||||
value)
|
||||
p = re.compile('((\:INDENT\:(.*?)\n)*)')
|
||||
value = p.sub(replace_wiki_identation,
|
||||
value)
|
||||
|
||||
value = re.sub(r'\*\*(.*?)\n',
|
||||
r'<li>\1</li>',
|
||||
value)
|
||||
|
||||
return value
|
||||
|
||||
|
||||
def replace_wiki_identation(match):
|
||||
if match.group() == "":
|
||||
return ""
|
||||
debug.info("plop: " + str(match.group()))
|
||||
value = "<ul>"
|
||||
value += re.sub(r':INDENT:',
|
||||
r'',
|
||||
match.group())
|
||||
value += "</ul>"
|
||||
return transcode(value)
|
21
codeBB/BB_Link.py
Normal file
21
codeBB/BB_Link.py
Normal file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/python
|
||||
import lutinDebug as debug
|
||||
import sys
|
||||
import lutinTools
|
||||
import re
|
||||
|
||||
|
||||
##
|
||||
## @brief Transcode:
|
||||
## [http://votre_site.con] => http://votre_site.con
|
||||
## [http://votre_site.con | texte affiché] => texte affiché
|
||||
## [http://votre_site.con texte affiché] => texte affiché.
|
||||
##
|
||||
## @param[in] value String to transform.
|
||||
## @return Transformed string.
|
||||
##
|
||||
def transcode(value):
|
||||
|
||||
return value
|
||||
|
||||
|
17
codeBB/BB_Specification.py
Normal file
17
codeBB/BB_Specification.py
Normal file
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/python
|
||||
import lutinDebug as debug
|
||||
import sys
|
||||
import lutinTools
|
||||
import re
|
||||
|
||||
|
||||
##
|
||||
## @brief Transcode thales specification ...
|
||||
## @param[in] value String to transform.
|
||||
## @return Transformed string.
|
||||
##
|
||||
def transcode(value):
|
||||
|
||||
return value
|
||||
|
||||
|
42
codeBB/BB_Table.py
Normal file
42
codeBB/BB_Table.py
Normal file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/python
|
||||
import lutinDebug as debug
|
||||
import sys
|
||||
import lutinTools
|
||||
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
|
||||
## |}
|
||||
## 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...
|
||||
##
|
||||
## result:
|
||||
## +-------------------------------------+
|
||||
## | colone 1 |
|
||||
## +------------------+------------------+
|
||||
## | ligne 1 | colone 2 ligne 1 |
|
||||
## +------------------+------------------+
|
||||
## | 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):
|
||||
|
||||
return value
|
||||
|
||||
|
78
codeBB/BB_Text.py
Normal file
78
codeBB/BB_Text.py
Normal file
@ -0,0 +1,78 @@
|
||||
#!/usr/bin/python
|
||||
import lutinDebug as debug
|
||||
import sys
|
||||
import lutinTools
|
||||
import re
|
||||
|
||||
|
||||
##
|
||||
## @brief Transcode .
|
||||
## [b]texte ici[/b]
|
||||
## [i]texte ici[/i]
|
||||
## [u]texte ici[/u]
|
||||
## [strike]texte ici[/strike]
|
||||
## [color=olive]texte ici[/color]
|
||||
## [color=#456FF33F]texte ici[/color]
|
||||
## Left : [left]texte ici[/left]
|
||||
## Center : [center]texte ici[/center]
|
||||
## Right : [right]texte ici[/right]
|
||||
## [size=22]sdfgsdfgsdgsfd[/size]
|
||||
## [cadre]mettre les code ici[/cadre]
|
||||
## @param[in] string String to transform.
|
||||
## @return Transformed string.
|
||||
##
|
||||
def transcode(value):
|
||||
value = re.sub(r'\[b\](.*?)\[/b\]',
|
||||
r'<span style="font-weight: bold;">\1</span>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\[i\](.*?)\[/i\]',
|
||||
r'<span style="font-style: italic;">\1</span>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\[u\](.*?)\[/u\]',
|
||||
r'<span style="text-decoration: underline;">\1</span>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\[sup\](.*?)\[/sup\]',
|
||||
r'<sup>\1</sup>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\[sub\](.*?)\[/sub\]',
|
||||
r'<sub>\1</sub>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\[color=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]',
|
||||
r'<span style="color: \1;">\2</span>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\[center\](.*?)\[/center\]',
|
||||
r'<div align="center">\1</div>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\[right\](.*?)\[/right\]',
|
||||
r'<div align="right">\1</div>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\[left\](.*?)\[/left\]',
|
||||
r'<div align="left">\1</div>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\[strike\](.*?)\[/strike\]',
|
||||
r'<span><strike>\1</strike></span>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\[size=(.*?)\](.*?)\[/size\]',
|
||||
r'<span style="font-size: \1px; line-height: normal;">\2</span>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\[cadre\](.*?)\[/cadre\]',
|
||||
r'<table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"><tbody><tr><td class="quote">\1</td></tr></tbody></table>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'____(.*?)\n',
|
||||
r'<hr>',
|
||||
value)
|
||||
|
||||
|
||||
return value
|
43
codeBB/BB_Title.py
Normal file
43
codeBB/BB_Title.py
Normal file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/python
|
||||
import lutinDebug as debug
|
||||
import sys
|
||||
import lutinTools
|
||||
import re
|
||||
|
||||
|
||||
##
|
||||
## @brief Transcode .
|
||||
## ==Title 1==
|
||||
## ===Title 2===
|
||||
## ====Title 3====
|
||||
## =====Title 4=====
|
||||
## ======Title 5======
|
||||
## @param[in] value String to transform.
|
||||
## @return Transformed string.
|
||||
##
|
||||
def transcode(value):
|
||||
|
||||
value = re.sub(r'\n======(.*?)======',
|
||||
r'<h5>\1</h5>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\n=====(.*?)=====',
|
||||
r'<h4>\1</h4>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\n====(.*?)====',
|
||||
r'<h3>\1</h3>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\n===(.*?)===',
|
||||
r'<h2>\1</h2>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\n==(.*?)==',
|
||||
r'<h1>\1</h1>',
|
||||
'\n' + value)
|
||||
# todo : remove \n at the start of the file ...
|
||||
|
||||
return value
|
||||
|
||||
|
26
codeBB/BB_comment.py
Normal file
26
codeBB/BB_comment.py
Normal file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/python
|
||||
import lutinDebug as debug
|
||||
import sys
|
||||
import lutinTools
|
||||
import re
|
||||
|
||||
|
||||
##
|
||||
## @brief Transcode balise:
|
||||
## /* ... */
|
||||
## @param[in] value String to transform.
|
||||
## @return Transformed string.
|
||||
##
|
||||
def transcode(value):
|
||||
|
||||
value = re.sub(r'\/\*(.*?)\*\/',
|
||||
r'',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\/\/(.*?)\n',
|
||||
r'',
|
||||
value)
|
||||
|
||||
return value
|
||||
|
||||
|
34
codeBB/BB_lineReturn.py
Normal file
34
codeBB/BB_lineReturn.py
Normal file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/python
|
||||
import lutinDebug as debug
|
||||
import sys
|
||||
import lutinTools
|
||||
import re
|
||||
|
||||
|
||||
##
|
||||
## @brief Transcode balise:
|
||||
## \n\n ==> <br/>
|
||||
## @param[in] value String to transform.
|
||||
## @return Transformed string.
|
||||
##
|
||||
def transcode(value):
|
||||
|
||||
value = re.sub(r'\r\n',
|
||||
r'\n',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\n\n\n',
|
||||
r'<br/><br/>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\n\n',
|
||||
r'<br/>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'<br/>',
|
||||
r'<br/>\n',
|
||||
value)
|
||||
|
||||
return value
|
||||
|
||||
|
48
codeBB/codeBB.py
Normal file
48
codeBB/codeBB.py
Normal file
@ -0,0 +1,48 @@
|
||||
#!/usr/bin/python
|
||||
import lutinDebug as debug
|
||||
import sys
|
||||
import lutinTools
|
||||
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):
|
||||
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 = lutinTools.FileReadData(inputFileName)
|
||||
if inData == "":
|
||||
return False
|
||||
outData = transcode(inData)
|
||||
debug.warning(" out: " + outputFileName)
|
||||
lutinTools.FileWriteData(outputFileName, outData)
|
||||
return True
|
||||
|
||||
|
4
codeHL/codeHL.py
Normal file
4
codeHL/codeHL.py
Normal file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
import lutinDebug as debug
|
||||
import sys
|
||||
import lutinTools
|
4
codeHL/codeHLBBcode.py
Normal file
4
codeHL/codeHLBBcode.py
Normal file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
import lutinDebug as debug
|
||||
import sys
|
||||
import lutinTools
|
4
codeHL/codeHLJava.py
Normal file
4
codeHL/codeHLJava.py
Normal file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
import lutinDebug as debug
|
||||
import sys
|
||||
import lutinTools
|
4
codeHL/codeHLPython.py
Normal file
4
codeHL/codeHLPython.py
Normal file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
import lutinDebug as debug
|
||||
import sys
|
||||
import lutinTools
|
4
codeHL/codeHLXML.py
Normal file
4
codeHL/codeHLXML.py
Normal file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
import lutinDebug as debug
|
||||
import sys
|
||||
import lutinTools
|
4
codeHL/codeHLcpp.py
Normal file
4
codeHL/codeHLcpp.py
Normal file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
import lutinDebug as debug
|
||||
import sys
|
||||
import lutinTools
|
4
codeHL/codeHLjson.py
Normal file
4
codeHL/codeHLjson.py
Normal file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
import lutinDebug as debug
|
||||
import sys
|
||||
import lutinTools
|
45
lutinDoc.py
45
lutinDoc.py
@ -5,6 +5,7 @@ import lutinTools
|
||||
# TODO : Add try of generic input ...
|
||||
sys.path.append(lutinTools.GetCurrentPath(__file__) + "/ply/ply/")
|
||||
sys.path.append(lutinTools.GetCurrentPath(__file__) + "/cppParser/CppHeaderParser/")
|
||||
sys.path.append(lutinTools.GetCurrentPath(__file__) + "/codeBB/")
|
||||
import CppHeaderParser
|
||||
import lutinDocHtml
|
||||
import lutinDocMd
|
||||
@ -18,6 +19,7 @@ import fnmatch
|
||||
class doc:
|
||||
def __init__(self, moduleName):
|
||||
self.moduleName = moduleName
|
||||
self.listDocFile = []
|
||||
self.listClass = dict()
|
||||
self.listEnum = dict()
|
||||
self.listVariable = dict()
|
||||
@ -26,6 +28,7 @@ class doc:
|
||||
self.target = None
|
||||
self.webSite = ""
|
||||
self.pathParsing = ""
|
||||
self.pathGlobalDoc = ""
|
||||
self.externalLink = []
|
||||
self.title = moduleName + " Library"
|
||||
self.styleHtml = ""
|
||||
@ -44,6 +47,13 @@ class doc:
|
||||
def set_path(self, path):
|
||||
self.pathParsing = path
|
||||
|
||||
##
|
||||
## @brief set the glabal documentation parsing folder
|
||||
## @param[in] path New path to parse
|
||||
##
|
||||
def set_path_general_doc(self, path):
|
||||
self.pathGlobalDoc = path
|
||||
|
||||
##
|
||||
## @brief List of validate external library link (disable otherwise)
|
||||
## @param[in] availlable List of all module link availlable
|
||||
@ -65,22 +75,39 @@ class doc:
|
||||
def set_html_css(self, cssFile):
|
||||
self.styleHtml = cssFile
|
||||
|
||||
|
||||
##
|
||||
## @brief Create the module documentation:
|
||||
## @param[in,out] target target that request generation of the documentation
|
||||
##
|
||||
def doc_parse_code(self):
|
||||
for root, dirnames, filenames in os.walk(self.pathParsing):
|
||||
tmpList = fnmatch.filter(filenames, "*.h")
|
||||
# Import the module :
|
||||
for filename in tmpList:
|
||||
fileCompleteName = os.path.join(root, filename)
|
||||
debug.debug(" Find a file : '" + fileCompleteName + "'")
|
||||
self.add_file(fileCompleteName)
|
||||
if self.pathParsing != "":
|
||||
for root, dirnames, filenames in os.walk(self.pathParsing):
|
||||
tmpList = fnmatch.filter(filenames, "*.h")
|
||||
# Import the module :
|
||||
for filename in tmpList:
|
||||
fileCompleteName = os.path.join(root, filename)
|
||||
debug.debug(" Find a file : '" + fileCompleteName + "'")
|
||||
self.add_file(fileCompleteName)
|
||||
if self.pathGlobalDoc != "":
|
||||
for root, dirnames, filenames in os.walk(self.pathGlobalDoc):
|
||||
tmpList = fnmatch.filter(filenames, "*.bb")
|
||||
# Import the module :
|
||||
for filename in tmpList:
|
||||
fileCompleteName = os.path.join(root, filename)
|
||||
debug.debug(" Find a doc file : '" + fileCompleteName + "'")
|
||||
self.add_file_doc(fileCompleteName)
|
||||
|
||||
##
|
||||
## @brief Add a File at the parsing system
|
||||
## @brief Add a documentation file at the parsing system
|
||||
## @param[in] filename File To add at the parsing element system.
|
||||
## @return True if no error occured, False otherwise
|
||||
##
|
||||
def add_file_doc(self, filename):
|
||||
debug.debug("adding file in documantation : '" + filename + "'");
|
||||
self.listDocFile.append(filename)
|
||||
|
||||
##
|
||||
## @brief Add a file at the parsing system
|
||||
## @param[in] filename File To add at the parsing element system.
|
||||
## @return True if no error occured, False otherwise
|
||||
##
|
||||
|
@ -4,6 +4,7 @@ import sys
|
||||
import lutinTools
|
||||
import CppHeaderParser
|
||||
import re
|
||||
import codeBB
|
||||
|
||||
global_class_link = {
|
||||
"std::string" : "http://www.cplusplus.com/reference/string/string/",
|
||||
@ -251,13 +252,13 @@ def generate(myDoc, outFolder) :
|
||||
genericHeader += "<html>\n"
|
||||
genericHeader += "<head>\n"
|
||||
genericHeader += " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0\">\n"
|
||||
genericHeader += " <title>" + myDoc.moduleName+ " Library</title>\n"
|
||||
genericHeader += " <title>" + myDoc.moduleName + " Library</title>\n"
|
||||
genericHeader += " <link rel=\"stylesheet\" href=\"base.css\">\n"
|
||||
genericHeader += "</head>\n"
|
||||
genericHeader += "<body>\n"
|
||||
genericHeader += " <div class=\"navbar navbar-fixed-top\">\n"
|
||||
genericHeader += " <div class=\"container\">\n"
|
||||
genericHeader += " <h1>" + myDoc.moduleName+ " Library</h1>\n"
|
||||
genericHeader += " <h1>" + myDoc.moduleName + " Library</h1>\n"
|
||||
#genericHeader += " <ul>\n"
|
||||
baseNamespace = ""
|
||||
for className in sorted(myDoc.listClass.iterkeys()) :
|
||||
@ -309,6 +310,16 @@ def generate(myDoc, outFolder) :
|
||||
genericFooter += "</body>\n"
|
||||
genericFooter += "</html>\n"
|
||||
|
||||
# create index.hml :
|
||||
file = open(outFolder + "/index.html", "w")
|
||||
file.write(genericHeader)
|
||||
file.write("<h1>" + myDoc.moduleName + "</h1>");
|
||||
file.write("<br/>");
|
||||
file.write("TODO : Main page ...");
|
||||
file.write("<br/>");
|
||||
file.write("<br/>");
|
||||
file.write(genericFooter)
|
||||
file.close();
|
||||
|
||||
for className in sorted(myDoc.listClass.iterkeys()) :
|
||||
localClass = myDoc.listClass[className]
|
||||
@ -432,6 +443,8 @@ def generate(myDoc, outFolder) :
|
||||
|
||||
file.close()
|
||||
|
||||
for docInputName in myDoc.listDocFile :
|
||||
codeBB.transcode_file(docInputName, docInputName+".html")
|
||||
|
||||
|
||||
|
||||
|
@ -49,6 +49,11 @@ def FileReadData(path):
|
||||
file.close()
|
||||
return data_file
|
||||
|
||||
def FileWriteData(path, data):
|
||||
file = open(path, "w")
|
||||
file.write(data)
|
||||
file.close()
|
||||
|
||||
def ListToStr(list):
|
||||
if type(list) == type(str()):
|
||||
return list + " "
|
||||
|
Loading…
Reference in New Issue
Block a user