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
56 lines (40 loc) · 1.38 KB
/
Copy pathextract-docs.livecodescript
File metadata and controls
56 lines (40 loc) · 1.38 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
#!
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
if there is not a stack tArgs[tArg] then
write "Error: stack not found: " & tArgs[tArg] & return to stderr
quit 3
end if
local tDocs
put revDocsGenerateDocsFileFromText(the script of stack tArgs[tArg],the long id of stack tArgs[tArg]) into tDocs
put textEncode(tDocs, "UTF-8") into tDocs
replace numToByte(13) with numToByte(10) in tDocs
put tDocs into url ("binfile:" & tOutputDir & "/" & tolower(the short name of stack tArgs[tArg]) & ".lcdoc")
end repeat
quit 0
end extractDocs
on errorDialog tError
write "Error:" && tError to stderr
quit 10
end errorDialog