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
60 lines (45 loc) · 1.52 KB
/
Copy pathextract-docs.livecodescript
File metadata and controls
60 lines (45 loc) · 1.52 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
#!
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 tDocs
if tArgs[tArg] ends with "lcb" then
write tArgs[tArg] to stdout
put revDocsGenerateDocsFileFromModularFile(tArgs[tArg]) into tDocs
else
if there is not a stack tArgs[tArg] then
write "Error: stack not found: " & tArgs[tArg] & return to stderr
quit 3
end if
put revDocsGenerateDocsFileFromText(the script of stack tArgs[tArg],the long id of stack tArgs[tArg]) 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 & "/" & "api.lcdoc")
end repeat
quit 0
end extractDocs
on errorDialog tError
write "Error:" && tError to stderr
quit 10
end errorDialog