forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextract-docs.livecodescript
More file actions
76 lines (60 loc) · 2.15 KB
/
Copy pathextract-docs.livecodescript
File metadata and controls
76 lines (60 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!
send "extractDocs" to me
on extractDocs
local tDocsParser
local tOutputDir
local tArgs
put the commandArguments into tArgs
put tArgs[2] into tDocsParser
put tArgs[3] into tOutputDir
try
start using stack tDocsParser
catch tError
write "Error: could not load docs parser:" && tDocsParser & return & tError & return to stderr
quit 1
end try
if there is not a folder tOutputDir then
create folder tOutputDir
end if
if there is not a folder tOutputDir then
write "Error: could not create output directory: " & tOutputDir & return to stderr
quit 2
end if
local tArg
repeat with tArg = 4 to the number of elements of tArgs
local tName, tSource, tContent
local tDocs
if tArgs[tArg] ends with "lcb" then
write tArgs[tArg] to stdout
put "api" into tName
put revDocsGenerateDocsFileFromModularFile(tArgs[tArg]) into tDocs
else
if there is a stack tArgs[tArg] then
put "api" into tName
put the script of stack tArgs[tArg] into tContent
put the long id of stack tArgs[tArg] into tSource
else if tArgs[tArg] ends with ".lcidl" then
if the platform is "Win32" then
set the itemDelimiter to backslash
else
set the itemDelimiter to slash
end if
put "com.livecode.external." & tolower(char 1 to -7 of the last item of tArgs[tArg]) into tName
put textDecode(url ("binfile:" & tArgs[tArg]), "UTF8") into tContent
put tArgs[tArg] into tSource
else
write "Error: stack not found: " & tArgs[tArg] & return to stderr
quit 3
end if
put revDocsGenerateDocsFileFromText(tContent, tSource) into tDocs
end if
put textEncode(tDocs, "UTF-8") into tDocs
replace numToByte(13) with numToByte(10) in tDocs
put tDocs into url ("binfile:" & tOutputDir & "/" & tName & ".lcdoc")
end repeat
quit 0
end extractDocs
on errorDialog tError
write "Error:" && tError to stderr
quit 10
end errorDialog