OSDN Git Service

こっそり、気持ち程度の日本語化しました (UTF-8 / Windows 環境用)。
[ring-lang-081/annotated-ring-with-OmegaT.git] / source / extensions / codegen / gendoc.ring
1 # Generate Documentation from Configuration File
2 # Author : Mahmoud Fayed <msfclipper@yahoo.com>
3 # Date : 2016.09.22
4
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 #===============================================
12
13 load "stdlibcore.ring"
14
15 aList = str2list(cFile)
16
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()
22
23 process_file(aList)
24
25 write(C_OUTPUTFILE,cOutput)
26 system(C_OUTPUTFILE)
27
28
29 func process_file(aList)
30
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))
39                         chdir(cCurrentDir)
40                         loop
41                 ok
42                 if left(lower(cLine),7)="<class>"                
43                         lStart = True
44                         x++
45                         do 
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()
53         
54                                         cOutput += windowsnl() + cClassName + windowsnl()
55                                         cOutput += Copy("=",len(cClassName)) + windowsnl() + windowsnl()
56                                         if funcAfterClass != NULL
57                                                 cOutput += call funcAfterClass(cClassNameAlone)
58                                         ok
59                                 ok
60                                 if left(cLine,7) = "parent:"
61                                         cClassName = trim(substr(cLine,8)) 
62                                         cOutput += windowsnl() + "Parent Class : " + cClassName + WindowsNl() + WindowsNl()
63                                 ok
64                                 if left(cLine,5) = "para:"
65                                         cClassName = trim(substr(cLine,6)) 
66                                         cOutput += windowsnl() + "Parameters : " + cClassName + WindowsNl() + WindowsNl()
67                                 ok
68         
69                                 x++
70                         again left(lower(cLine),8) !="</class>"
71                         loop
72                 ok
73                 aAvoidBlocks = ["comment","code","funcstart","runcode","struct"]
74                 for cAvoid in aAvoidBlocks
75                         if left(lower(cLine),len(cAvoid)+2)="<"+cAvoid+">"               
76                                 x++
77                                 do 
78                                         cLine = trim(aList[x])
79                                         x++
80                                 again left(lower(cLine),len(cAvoid)+3) !="</"+cAvoid+">"
81                                 loop
82                         ok
83                 next
84                 avoidline("constant",cLine)
85                 avoidline("ignorecpointertype",cLine)
86                 avoidline("register",cLine)
87                 avoidline("filter",cLine)
88                 
89                 avoidline("/comment",cLine)
90                 avoidline("/code",cLine)
91                 avoidline("/runcode",cLine)
92                 avoidline("/struct",cLine)
93
94                 if lStart
95                         if (cLine != NULL ) and len(cLine) > 1
96                                 cLine = substr(cLine,"@","_")
97                                 cOutput += "* " + cLine + windowsnl()
98                         ok
99                 ok
100         next
101         
102 func avoidline cStr,cLine
103         if ( left(lower(cLine),len(cStr)+2)="<"+cStr + ">" ) or ( left(lower(cLine),len(cStr)+3)="</"+cStr + ">"  )
104                 loop
105         ok