Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit d04d52c

Browse files
committed
[[ Docs ]] Put all docs of a particular type together in API
Put all lcs syntax into an lcs folder for inclusion in an LCS API, and similarly for LCB and IDE docs.
1 parent 7ee8116 commit d04d52c

File tree

3 files changed

+54
-26
lines changed

3 files changed

+54
-26
lines changed

builder/builder_utilities.livecodescript

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,9 @@ function builderIDEDocsFolder
291291
return builderIDEFolder() & slash & "Documentation"
292292
end builderIDEDocsFolder
293293

294-
# Location for api js file in > LC8
295-
function builderAPIFolder pEdition
296-
return builderIDEDocsFolder() & slash & "html_viewer/resources/data/api"
294+
# Location for api js files in > LC8
295+
function builderAPIFolder pEdition, pWhich
296+
return builderIDEDocsFolder() & slash & "html_viewer/resources/data/api-" & pWhich
297297
end builderAPIFolder
298298

299299
# Location for guide js file in > LC8

builder/docs_builder.livecodescript

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,7 +1918,7 @@ command docsBuilderGenerateDocsNew pEdition, pVersion
19181918
builderLog "report", "Building guide into" && builderGuideFolder(pEdition) & slash & "distributed_guide.js"
19191919
pathEnsure (builderGuideFolder(pEdition))
19201920
docsBuilderGenerateDistributedGuide pEdition
1921-
builderLog "report", "Building api into" && builderAPIFolder(pEdition) & slash & "distributed_api.js"
1921+
builderLog "report", "Building api into" && builderAPIFolder(pEdition)
19221922
pathEnsure (builderAPIFolder(pEdition))
19231923
docsBuilderGenerateDistributedAPI pEdition
19241924

@@ -2123,6 +2123,8 @@ command docsBuilderGenerateDistributedAPI pEdition
21232123
exit docsBuilderGenerateDistributedAPI
21242124
end if
21252125

2126+
put "script" into tLCSDictionaryA["filename"]
2127+
put "lcs" into tLCSDictionaryA["api"]
21262128
addToList tLCSDictionaryA, tLibrariesA
21272129

21282130
local tModuleList, tModularA, tModularCount, tBlocksA, tParsedA
@@ -2152,29 +2154,33 @@ command docsBuilderGenerateDistributedAPI pEdition
21522154
end repeat
21532155
put empty into tParsedA
21542156
end repeat
2155-
put "LiveCode Builder" into tLCBDictionaryA["display name"]
2156-
put revDocsModifyForUrl("LiveCode Builder") into tLCBDictionaryA["name"]
2157-
put "LiveCode" into tLCBDictionaryA["author"]
2158-
put "dictionary" into tLCBDictionaryA["type"]
21592157

21602158
if tLCBDictionaryA is empty then
21612159
logError "Couldn't parse builder dictionary data for" && pEdition
21622160
exit docsBuilderGenerateDistributedAPI
21632161
end if
21642162

2163+
put "LiveCode Builder" into tLCBDictionaryA["display name"]
2164+
put revDocsModifyForUrl("LiveCode Builder") into tLCBDictionaryA["name"]
2165+
put "LiveCode" into tLCBDictionaryA["author"]
2166+
put "dictionary" into tLCBDictionaryA["type"]
2167+
put "builder" into tLCSDictionaryA["filename"]
2168+
put "lcb" into tLCBDictionaryA["api"]
21652169
addToList tLCBDictionaryA, tLibrariesA
21662170

21672171
local tDatagridA, tDGDocs
21682172
put builderIDEDocsFolder() & "/dictionary/datagrid.lcdoc" into tDGDocs
21692173
put revDocsParseDocFileToLibraryArray(tDGDocs, "Data Grid", "LiveCode") \
2170-
into tDataGridA
2171-
2174+
into tDataGridA
2175+
21722176
if tDataGridA is empty then
21732177
builderLog "error", "Couldn't parse datagrid dictionary data for" && pEdition
21742178
exit docsBuilderGenerateDistributedAPI
21752179
end if
21762180

21772181
put "dictionary" into tDataGridA["type"]
2182+
put "dg" into tLCSDictionaryA["filename"]
2183+
put "lcs" into tLCBDictionaryA["api"]
21782184

21792185
addToList tDataGridA, tLibrariesA
21802186

@@ -2195,16 +2201,20 @@ command docsBuilderGenerateDistributedAPI pEdition
21952201
builderLog "error", "Couldn't parse" && item -2 of tFile && "dictionary data for" && pEdition
21962202
exit docsBuilderGenerateDistributedAPI
21972203
end if
2204+
put tLibA["name"] into tLibA["filename"]
2205+
put "lcs" into tLibA["api"]
21982206

21992207
addToList tLibA, tLibrariesA
22002208
end repeat
22012209

2202-
local tJSON
2203-
put revDocsFormatLibrariesArrayAsJSON(tLibrariesA) into tJSON
2204-
22052210
docsBuilderPopulateDatabase pEdition, tLibrariesA
2206-
2207-
put textEncode(tJSON, "utf-8") into url ("binfile:" & builderAPIFolder(pEdition) & slash & "distributed_api.js")
2211+
repeat for each element tLibA in tLibrariesA
2212+
local tJSON, tFolder
2213+
put revDocsFormatLibraryDocArrayAsJSON(tLibA["name"], tLibA["doc"]) into tJSON
2214+
put builderAPIFolder(pEdition, tLibA["api"]) into tFolder
2215+
put textEncode(tJSON, "utf-8") into url ("binfile:" & tFolder \
2216+
& slash & tLibA["filename"] & ".js")
2217+
end repeat
22082218
end docsBuilderGenerateDistributedAPI
22092219

22102220
on docsBuilderPopulateDatabase pEdition, pLibrariesA

ide-support/revdocsparser.livecodescript

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,26 +1895,44 @@ private function __tabs pNum
18951895
return tOutput
18961896
end __tabs
18971897

1898-
function revDocsFormatLibraryArrayAsJSON pLibraryA
1899-
local tJSON
1900-
put "{" after tJSON
1901-
put return & __tabs(2) & keyValue("display name",pLibraryA["display name"]) & comma after tJSON
1902-
put return & __tabs(2) & keyValue("name",pLibraryA["name"]) & comma after tJSON
1903-
put return & __tabs(2) & keyValue("author",pLibraryA["author"]) & comma after tJSON
1904-
put return & __tabs(2) & escape("doc") & ":[" after tJSON
1905-
1898+
function revDocsFormatLibraryDocArrayAsJSON pLibraryName, pDocA
19061899
local tCount
1907-
put the number of elements in pLibraryA["doc"] into tCount
1900+
put the number of elements in pDocA into tCount
19081901

1902+
local tJSON
19091903
if tCount is not 0 then
1910-
repeat with tID = 1 to tCount
1911-
put revDocsFormatLibraryDataAsJSON(tID, pLibraryA["doc"][tID]) & comma after tJSON
1904+
repeat with tIndex = 1 to tCount
1905+
local tDoc, tId
1906+
put pDocA[tIndex] into tDoc
1907+
put pLibraryName & "-" & tIndex into tId
1908+
put revDocsFormatLibraryDataAsJSON(tId, tDoc) & comma after tJSON
19121909
end repeat
19131910
delete the last char of tJSON
19141911
end if
1912+
return tJSON
1913+
end revDocsFormatLibraryDocArrayAsJSON
1914+
1915+
function revDocsCreateAPIJSON pLibraryTitle, pLibraryName, pAuthor, pDocContentJSON
1916+
local tJSON
1917+
put "{" after tJSON
1918+
put return & __tabs(2) & keyValue("display name",pLibraryTitle) & comma after tJSON
1919+
put return & __tabs(2) & keyValue("name",pLibraryName) & comma after tJSON
1920+
if pAuthor is not empty then
1921+
put return & __tabs(2) & keyValue("author",pAuthor) & comma after tJSON
1922+
end if
1923+
put return & __tabs(2) & escape("doc") & ":[" after tJSON
1924+
put pDocContentJSON after tJSON
19151925
put "]" after tJSON
19161926
put return & tab & "}" after tJSON
19171927
return tJSON
1928+
end revDocsCreateAPIJSON
1929+
1930+
function revDocsFormatLibraryArrayAsJSON pLibraryA
1931+
local tDocContent
1932+
put revDocsFormatLibraryDocArrayAsJSON(pLibraryA["name"], pLibraryA["doc"]) \
1933+
into tDocContent
1934+
return revDocsCreateAPIJSON(pLibraryA["display name"], pLibraryA["name"], \
1935+
pLibraryA["author"], tDocContent)
19181936
end revDocsFormatLibraryArrayAsJSON
19191937

19201938
private function __revDocsParamIsDefinedType pType

0 commit comments

Comments
 (0)