3A tool to preprocess root documentation in order to provide missing
4functionality in the documentation tools like doxygen or pandoc.
5At the moment filters are just functions. A proper implementation would
6go through the creation of a filter class which is very genereic and can be
7composed with a trigger and an action.
14usage=
"Usage: %s fileToBeTreated.md\n" %__file__
22 Check if the invocation is correct. If not print help
28 if not os.path.exists(argv[1]):
35 Create a name for the preprocessed version of filename
37 fileName, fileExtension = os.path.splitext(filename)
38 return "%s_preprocessed%s" %(fileName, fileExtension)
43 @ROOT_INCLUDE_FILE filename
44 is encountered, it is replaced with the content of filename
48 for line
in text.split(
"\n"):
49 if line.startswith(
"@ROOT_INCLUDE_FILE"):
50 inclFileName = line.split()[1]
51 if not os.path.exists(inclFileName):
52 print(
"[includeFilter] Error: file", inclFileName,
"does not exist.")
55 for inclFileLine
in open(inclFileName).readlines():
59 return retcode, newText
62textFilters=[includeFilter]
66 Apply a series of filters to the file modifiying its content.
67 A new file is created with the suffix _preprocessed before the extension.
69 myChapter.md --> myChapter_preprocessed.md
71 filecontent = open(filename).
read()
73 for textFilter
in textFilters:
74 tmpretcode,filecontent=textFilter(filecontent)
77 ofile = open(preprocessedName,
"w")
78 ofile.write(filecontent)
84 Apply a series of "filters" to the input file.
94 print(
"Errors during the preprocessing.")
97if __name__ ==
"__main__":
preprocessFile()
Apply a series of "filters" to the input file.
createPreprocessedName(filename)
Create a name for the preprocessed version of filename.
applyFilters(filename)
Apply a series of filters to the file modifiying its content.
includeFilter(text)
If a line of the form @ROOT_INCLUDE_FILE filename is encountered, it is replaced with the content of ...
checkInvocation(argv)
Check if the invocation is correct.