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

Commit 88c680d

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 5442a85 commit 88c680d

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
@@ -309,9 +309,9 @@ function builderIDEDocsFolder
309309
return builderIDEFolder() & slash & "Documentation"
310310
end builderIDEDocsFolder
311311

312-
# Location for api js file in > LC8
313-
function builderAPIFolder pEdition
314-
return builderIDEDocsFolder() & slash & "html_viewer/resources/data/api"
312+
# Location for api js files in > LC8
313+
function builderAPIFolder pEdition, pWhich
314+
return builderIDEDocsFolder() & slash & "html_viewer/resources/data/api-" & pWhich
315315
end builderAPIFolder
316316

317317
# 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

@@ -2139,6 +2139,8 @@ command docsBuilderGenerateDistributedAPI pEdition
21392139
exit docsBuilderGenerateDistributedAPI
21402140
end if
21412141

2142+
put "script" into tLCSDictionaryA["filename"]
2143+
put "lcs" into tLCSDictionaryA["api"]
21422144
addToList tLCSDictionaryA, tLibrariesA
21432145

21442146
local tModuleList, tModularA, tModularCount, tBlocksA, tParsedA
@@ -2168,29 +2170,33 @@ command docsBuilderGenerateDistributedAPI pEdition
21682170
end repeat
21692171
put empty into tParsedA
21702172
end repeat
2171-
put "LiveCode Builder" into tLCBDictionaryA["display name"]
2172-
put revDocsModifyForUrl("LiveCode Builder") into tLCBDictionaryA["name"]
2173-
put "LiveCode" into tLCBDictionaryA["author"]
2174-
put "dictionary" into tLCBDictionaryA["type"]
21752173

21762174
if tLCBDictionaryA is empty then
21772175
logError "Couldn't parse builder dictionary data for" && pEdition
21782176
exit docsBuilderGenerateDistributedAPI
21792177
end if
21802178

2179+
put "LiveCode Builder" into tLCBDictionaryA["display name"]
2180+
put revDocsModifyForUrl("LiveCode Builder") into tLCBDictionaryA["name"]
2181+
put "LiveCode" into tLCBDictionaryA["author"]
2182+
put "dictionary" into tLCBDictionaryA["type"]
2183+
put "builder" into tLCSDictionaryA["filename"]
2184+
put "lcb" into tLCBDictionaryA["api"]
21812185
addToList tLCBDictionaryA, tLibrariesA
21822186

21832187
local tDatagridA, tDGDocs
21842188
put builderIDEDocsFolder() & "/dictionary/datagrid.lcdoc" into tDGDocs
21852189
put revDocsParseDocFileToLibraryArray(tDGDocs, "Data Grid", "LiveCode") \
2186-
into tDataGridA
2187-
2190+
into tDataGridA
2191+
21882192
if tDataGridA is empty then
21892193
builderLog "error", "Couldn't parse datagrid dictionary data for" && pEdition
21902194
exit docsBuilderGenerateDistributedAPI
21912195
end if
21922196

21932197
put "dictionary" into tDataGridA["type"]
2198+
put "dg" into tLCSDictionaryA["filename"]
2199+
put "lcs" into tLCBDictionaryA["api"]
21942200

21952201
addToList tDataGridA, tLibrariesA
21962202

@@ -2211,16 +2217,20 @@ command docsBuilderGenerateDistributedAPI pEdition
22112217
builderLog "error", "Couldn't parse" && item -2 of tFile && "dictionary data for" && pEdition
22122218
exit docsBuilderGenerateDistributedAPI
22132219
end if
2220+
put tLibA["name"] into tLibA["filename"]
2221+
put "lcs" into tLibA["api"]
22142222

22152223
addToList tLibA, tLibrariesA
22162224
end repeat
22172225

2218-
local tJSON
2219-
put revDocsFormatLibrariesArrayAsJSON(tLibrariesA) into tJSON
2220-
22212226
docsBuilderPopulateDatabase pEdition, tLibrariesA
2222-
2223-
put textEncode(tJSON, "utf-8") into url ("binfile:" & builderAPIFolder(pEdition) & slash & "distributed_api.js")
2227+
repeat for each element tLibA in tLibrariesA
2228+
local tJSON, tFolder
2229+
put revDocsFormatLibraryDocArrayAsJSON(tLibA["name"], tLibA["doc"]) into tJSON
2230+
put builderAPIFolder(pEdition, tLibA["api"]) into tFolder
2231+
put textEncode(tJSON, "utf-8") into url ("binfile:" & tFolder \
2232+
& slash & tLibA["filename"] & ".js")
2233+
end repeat
22242234
end docsBuilderGenerateDistributedAPI
22252235

22262236
on docsBuilderPopulateDatabase pEdition, pLibrariesA

ide-support/revdocsparser.livecodescript

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,26 +1908,44 @@ private function __tabs pNum
19081908
return tOutput
19091909
end __tabs
19101910

1911-
function revDocsFormatLibraryArrayAsJSON pLibraryA
1912-
local tJSON
1913-
put "{" after tJSON
1914-
put return & __tabs(2) & keyValue("display name",pLibraryA["display name"]) & comma after tJSON
1915-
put return & __tabs(2) & keyValue("name",pLibraryA["name"]) & comma after tJSON
1916-
put return & __tabs(2) & keyValue("author",pLibraryA["author"]) & comma after tJSON
1917-
put return & __tabs(2) & escape("doc") & ":[" after tJSON
1918-
1911+
function revDocsFormatLibraryDocArrayAsJSON pLibraryName, pDocA
19191912
local tCount
1920-
put the number of elements in pLibraryA["doc"] into tCount
1913+
put the number of elements in pDocA into tCount
19211914

1915+
local tJSON
19221916
if tCount is not 0 then
1923-
repeat with tID = 1 to tCount
1924-
put revDocsFormatLibraryDataAsJSON(tID, pLibraryA["doc"][tID]) & comma after tJSON
1917+
repeat with tIndex = 1 to tCount
1918+
local tDoc, tId
1919+
put pDocA[tIndex] into tDoc
1920+
put pLibraryName & "-" & tIndex into tId
1921+
put revDocsFormatLibraryDataAsJSON(tId, tDoc) & comma after tJSON
19251922
end repeat
19261923
delete the last char of tJSON
19271924
end if
1925+
return tJSON
1926+
end revDocsFormatLibraryDocArrayAsJSON
1927+
1928+
function revDocsCreateAPIJSON pLibraryTitle, pLibraryName, pAuthor, pDocContentJSON
1929+
local tJSON
1930+
put "{" after tJSON
1931+
put return & __tabs(2) & keyValue("display name",pLibraryTitle) & comma after tJSON
1932+
put return & __tabs(2) & keyValue("name",pLibraryName) & comma after tJSON
1933+
if pAuthor is not empty then
1934+
put return & __tabs(2) & keyValue("author",pAuthor) & comma after tJSON
1935+
end if
1936+
put return & __tabs(2) & escape("doc") & ":[" after tJSON
1937+
put pDocContentJSON after tJSON
19281938
put "]" after tJSON
19291939
put return & tab & "}" after tJSON
19301940
return tJSON
1941+
end revDocsCreateAPIJSON
1942+
1943+
function revDocsFormatLibraryArrayAsJSON pLibraryA
1944+
local tDocContent
1945+
put revDocsFormatLibraryDocArrayAsJSON(pLibraryA["name"], pLibraryA["doc"]) \
1946+
into tDocContent
1947+
return revDocsCreateAPIJSON(pLibraryA["display name"], pLibraryA["name"], \
1948+
pLibraryA["author"], tDocContent)
19311949
end revDocsFormatLibraryArrayAsJSON
19321950

19331951
private function __revDocsParamIsDefinedType pType

0 commit comments

Comments
 (0)