[DEV] add documantation capabilities

This commit is contained in:
Edouard DUPIN 2013-12-05 21:10:42 +01:00
parent 8659f3f133
commit 70423434d8
2 changed files with 69 additions and 16 deletions

View File

@ -8,6 +8,8 @@ sys.path.append(lutinTools.GetCurrentPath(__file__) + "/cppParser/CppHeaderParse
import CppHeaderParser import CppHeaderParser
import lutinDocHtml import lutinDocHtml
import lutinDocMd import lutinDocMd
import os
import fnmatch
## ##
## @brief Main Documantion class ## @brief Main Documantion class
@ -22,6 +24,60 @@ class doc:
self.listFunction = dict() self.listFunction = dict()
self.listNamepsaces = dict() self.listNamepsaces = dict()
self.target = None self.target = None
self.webSite = ""
self.pathParsing = ""
self.externalLink = []
self.title = moduleName + " Library"
self.styleHtml = ""
##
## @brief Set the module website (activate only when compile in release mode, else "../moduleName/)
## @param[in] url New Website url
##
def set_website(self, url):
self.webSite = url
##
## @brief set the parsing folder
## @param[in] path New path to parse
##
def set_path(self, path):
self.pathParsing = path
##
## @brief List of validate external library link (disable otherwise)
## @param[in] availlable List of all module link availlable
##
def set_external_link(self, availlable):
self.externalLink = availlable
##
## @brief Set the library title
## @param[in] title New title to set.
##
def set_title(self, title):
self.title = title
##
## @brief new html basic css file
## @param[in] file File of the css style sheet
##
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)
## ##
## @brief Add a File at the parsing system ## @brief Add a File at the parsing system
@ -52,10 +108,12 @@ class doc:
# add all enums: # add all enums:
for localEnum in metaData.enums: for localEnum in metaData.enums:
if localEnum['namespace'] == '': if "name" not in localEnum.keys():
enumName = localEnum['name'] continue
if localEnum["namespace"] == "":
enumName = localEnum["name"]
else: else:
enumName = localEnum['namespace'] + "::" + localEnum['name'] enumName = localEnum["namespace"] + "::" + localEnum['name']
enumName = enumName.replace("::::", "::") enumName = enumName.replace("::::", "::")
if enumName in self.listEnum.keys(): if enumName in self.listEnum.keys():
debug.warning("Might merge enum : '" + enumName + "' file : " + filename) debug.warning("Might merge enum : '" + enumName + "' file : " + filename)

View File

@ -34,8 +34,7 @@ class module:
self.name=moduleName self.name=moduleName
# Dependency list: # Dependency list:
self.depends=[] self.depends=[]
# Dependency list: # Documentation list:
self.docPath = ""
self.documentation = None self.documentation = None
# export PATH # export PATH
self.export_path=[] self.export_path=[]
@ -380,34 +379,30 @@ class module:
## @brief Set the documentation availlable for this module ## @brief Set the documentation availlable for this module
## ##
def doc_enable(self): def doc_enable(self):
self.docPath = lutinTools.GetCurrentPath(self.originFile)
self.documentation = lutinDoc.doc(self.name) self.documentation = lutinDoc.doc(self.name)
self.documentation.set_path(lutinTools.GetCurrentPath(self.originFile))
## ##
## @brief Create the module documentation: ## @brief Create the module documentation:
## @param[in,out] target target that request generation of the documentation ## @param[in,out] target target that request generation of the documentation
## ##
def doc_parse_code(self, target): def doc_parse_code(self, target):
if self.docPath == "": if self.documentation == None:
return False return False
for root, dirnames, filenames in os.walk(self.docPath): self.documentation.doc_parse_code()
tmpList = fnmatch.filter(filenames, "*.h") return True
# Import the module :
for filename in tmpList:
fileCompleteName = os.path.join(root, filename)
debug.debug(" Find a file : '" + fileCompleteName + "'")
self.documentation.add_file(fileCompleteName)
## ##
## @brief Generate real documentation files ## @brief Generate real documentation files
## @param[in,out] target target that request generation of the documentation ## @param[in,out] target target that request generation of the documentation
## ##
def doc_generate(self, target): def doc_generate(self, target):
if self.docPath == "": if self.documentation == None:
return False return False
# Real creation of the documentation : # Real creation of the documentation :
lutinTools.RemoveFolderAndSubFolder(target.GetDocFolder(self.name)); lutinTools.RemoveFolderAndSubFolder(target.GetDocFolder(self.name));
self.documentation.generate_documantation(target, target.GetDocFolder(self.name)) self.documentation.generate_documantation(target, target.GetDocFolder(self.name))
return True
## ##
@ -416,7 +411,7 @@ class module:
## @return [real element name, link on it] ## @return [real element name, link on it]
## ##
def doc_get_link(self, target, elementName): def doc_get_link(self, target, elementName):
if self.docPath == "": if self.documentation == None:
return [elementName, ""] return [elementName, ""]
return self.documentation.get_class_link_from_target(elementName); return self.documentation.get_class_link_from_target(elementName);