1 # Generate Documentation from Configuration File
2 # Author : Mahmoud Fayed <msfclipper@yahoo.com>
5 #========== Expect the next input
6 # C_OUTPUTFILE = "qtclassesdoc.txt" # Output File Name
7 # C_CHAPTERNAME = "RingQt Classes Reference" # Chapter Name
8 # cFile = read("qt.cf") # Input File
9 # lStart = False # False = Classes Doc. True = Functions Doc.
10 # funcAfterClass = func cClassName { return string } # function to call
11 #===============================================
13 load "stdlibcore.ring"
15 aList = str2list(cFile)
17 cOutput = ".. index:: " + windowsnl()
18 cOutput += " single: "+C_CHAPTERNAME+"; Introduction" + windowsnl() + windowsnl()
19 cOutput += copy("=",len(C_CHAPTERNAME)) + windowsnl()
20 cOutput += C_CHAPTERNAME + windowsnl()
21 cOutput += copy("=",len(C_CHAPTERNAME)) + windowsnl() + windowsnl()
25 write(C_OUTPUTFILE,cOutput)
29 func process_file(aList)
31 for x = 1 to len(aList)
32 cLine = trim(aList[x])
33 if left(lower(cLine),10)="<loadfile>"
34 cSubFileName = trim(substr(cLine,11))
35 cSubFileText = read(cSubFileName)
36 cCurrentDir = currentdir()
37 chdir(justfilepath(cSubFileName))
38 process_file(str2list(cSubFileText))
42 if left(lower(cLine),7)="<class>"
46 cLine = trim(aList[x])
47 if left(cLine,5) = "name:"
48 cClassNameAlone = trim(substr(cLine,6))
49 cClassName = cClassNameAlone + " Class"
50 cOutput += Windowsnl() + ".. index::" + windowsnl()
51 cOutput +=" pair: "+C_CHAPTERNAME+"; "
52 cOutput += cClassName + WindowsNl()
54 cOutput += windowsnl() + cClassName + windowsnl()
55 cOutput += Copy("=",len(cClassName)) + windowsnl() + windowsnl()
56 if funcAfterClass != NULL
57 cOutput += call funcAfterClass(cClassNameAlone)
60 if left(cLine,7) = "parent:"
61 cClassName = trim(substr(cLine,8))
62 cOutput += windowsnl() + "Parent Class : " + cClassName + WindowsNl() + WindowsNl()
64 if left(cLine,5) = "para:"
65 cClassName = trim(substr(cLine,6))
66 cOutput += windowsnl() + "Parameters : " + cClassName + WindowsNl() + WindowsNl()
70 again left(lower(cLine),8) !="</class>"
73 aAvoidBlocks = ["comment","code","funcstart","runcode","struct"]
74 for cAvoid in aAvoidBlocks
75 if left(lower(cLine),len(cAvoid)+2)="<"+cAvoid+">"
78 cLine = trim(aList[x])
80 again left(lower(cLine),len(cAvoid)+3) !="</"+cAvoid+">"
84 avoidline("constant",cLine)
85 avoidline("ignorecpointertype",cLine)
86 avoidline("register",cLine)
87 avoidline("filter",cLine)
89 avoidline("/comment",cLine)
90 avoidline("/code",cLine)
91 avoidline("/runcode",cLine)
92 avoidline("/struct",cLine)
95 if (cLine != NULL ) and len(cLine) > 1
96 cLine = substr(cLine,"@","_")
97 cOutput += "* " + cLine + windowsnl()
102 func avoidline cStr,cLine
103 if ( left(lower(cLine),len(cStr)+2)="<"+cStr + ">" ) or ( left(lower(cLine),len(cStr)+3)="</"+cStr + ">" )