forked from superbobry/io-docs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDocExtractor.io
41 lines (35 loc) · 1.36 KB
/
DocExtractor.io
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
Common
DocExtractor := Object clone prependProto(ProgressMixIn) do(
path ::= "." # Root path for the extractor to start with.
with := method(path, self clone setPath(path))
extract := method(
# Note: what are *.m files for?
Directory with(path) recursiveFilesOfTypes(
list(".io", ".c", ".m")
) foreach(file,
# Skipping IoVMInit file!
if(file name beginsWithSeq("IoVMInit"), continue)
# Creating / updating Meta objects ...
file meta foreach(data, Meta with(data))
# ... and processing slot docstring objects.
file docs foreach(data, Meta slot(data))
done # Just a `success` hook.
)
)
printHeader := method(
("Extracting docs starting from `" .. path asMutable rstrip("/") .. "`:") println
)
printSummary := method(
objectCount := MetaCache keys size
slotCount := MetaCache values reduce(count, object,
count + object slots size, 0
)
# Printing summary.
("\n" .. "-" repeated(width)) println
("Processed " .. \
fileCount .. " file" pluralize(fileCount) .. ", " ..
objectCount .. " object" pluralize(objectCount) .. ", " ..
slotCount .. " slot" pluralize(slotCount) ..
" in " .. runtime .. "s") println
)
) setMain("extract")