Skip to content

Commit 73e6a32

Browse files
committed
[[ Docs ]] Split database docs per-api
This patch rejigs the api database to split things up into lcs, lcb and ide APIs.
1 parent b6d1dcd commit 73e6a32

File tree

2 files changed

+39
-57
lines changed

2 files changed

+39
-57
lines changed

builder/docs_builder.livecodescript

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,7 +2140,7 @@ command docsBuilderGenerateDistributedAPI pEdition
21402140
end if
21412141

21422142
put "script" into tLCSDictionaryA["filename"]
2143-
put "lcs" into tLCSDictionaryA["api"]
2143+
put "livecode_script" into tLCSDictionaryA["api"]
21442144
addToList tLCSDictionaryA, tLibrariesA
21452145

21462146
local tModuleList, tModularA, tModularCount, tBlocksA, tParsedA
@@ -2181,7 +2181,7 @@ command docsBuilderGenerateDistributedAPI pEdition
21812181
put "LiveCode" into tLCBDictionaryA["author"]
21822182
put "dictionary" into tLCBDictionaryA["type"]
21832183
put "builder" into tLCSDictionaryA["filename"]
2184-
put "lcb" into tLCBDictionaryA["api"]
2184+
put "livecode_builder" into tLCBDictionaryA["api"]
21852185
addToList tLCBDictionaryA, tLibrariesA
21862186

21872187
local tDatagridA, tDGDocs
@@ -2196,7 +2196,7 @@ command docsBuilderGenerateDistributedAPI pEdition
21962196

21972197
put "dictionary" into tDataGridA["type"]
21982198
put "dg" into tLCSDictionaryA["filename"]
2199-
put "lcs" into tLCBDictionaryA["api"]
2199+
put "livecode_script" into tLCBDictionaryA["api"]
22002200

22012201
addToList tDataGridA, tLibrariesA
22022202

@@ -2218,7 +2218,7 @@ command docsBuilderGenerateDistributedAPI pEdition
22182218
exit docsBuilderGenerateDistributedAPI
22192219
end if
22202220
put tLibA["name"] into tLibA["filename"]
2221-
put "lcs" into tLibA["api"]
2221+
put "livecode_script" into tLibA["api"]
22222222

22232223
addToList tLibA, tLibrariesA
22242224
end repeat
@@ -2252,9 +2252,9 @@ on docsBuilderPopulateDatabase pEdition, pLibrariesA
22522252

22532253
revExecuteSQL tConnection,"BEGIN TRANSACTION"
22542254

2255-
repeat for each key tKey in pLibrariesA
2256-
builderLog "message", "adding library" && pLibrariesA[tKey]["display name"] && "to docs database"
2257-
revDocsUpdateDatabase tConnection, pLibrariesA[tKey]
2255+
repeat for each element tLib in pLibrariesA
2256+
builderLog "message", "adding library" && tLib["display name"] && "to docs database"
2257+
revDocsUpdateDatabase tConnection, tLib["api"], tLib
22582258
if the result is not empty then
22592259
logError the result
22602260
exit docsBuilderPopulateDatabase

ide-support/revdocsparser.livecodescript

Lines changed: 32 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,84 +2350,73 @@ on revDocsOpenAPIDatabase pFolder
23502350
return tConnection
23512351
end revDocsOpenAPIDatabase
23522352

2353-
on revDocsUpdateDatabase pConnection, pLibraryA
2353+
on revDocsUpdateDatabase pConnection, pAPI, pLibraryA
23542354
if pConnection is empty then
23552355
return "no database connection"
23562356
end if
23572357

23582358
local tSQL, tResult
23592359

23602360
# Create the libraries table. This might already exist, so do it unchecked.
2361-
put "CREATE TABLE libraries(library_id integer primary key, library_name text, author text, type text)" into tSQL
2361+
put "CREATE TABLE apis(api_id integer primary key, api_name text)" into tSQL
23622362
revExecuteSQL pConnection, tSQL
23632363

2364-
local tName
2365-
put pLibraryA["name"] into tName
2366-
if tName is empty then
2367-
put revDocsModifyForURL(pLibraryA["display name"]) into tName
2368-
end if
2369-
2370-
local tAuthor
2371-
put pLibraryA["author"] into tAuthor
2372-
2373-
local tType
2374-
put pLibraryA["type"] into tType
2375-
23762364
# Try an UPDATE first. If this fails, the entry might not exist already, so try an INSERT.
2377-
put "UPDATE libraries SET author = :1, type = :2 WHERE library_name = :3" into tSQL
2378-
revExecuteSQL pConnection, tSQL, "tAuthor", "tType", "tName"
2365+
put "UPDATE apis SET api_name = :1 WHERE api_name = :1" into tSQL
2366+
revExecuteSQL pConnection, tSQL, "pAPI"
23792367
put the result into tResult
23802368
if tResult is not a number or tResult is 0 then
2381-
put "INSERT into libraries VALUES(NULL, :1, :2, :3)" into tSQL
2382-
revExecuteSQL pConnection, tSQL, "tName", "tAuthor", "tType"
2369+
put "INSERT into apis VALUES(NULL, :1)" into tSQL
2370+
revExecuteSQL pConnection, tSQL, "pAPI"
23832371
put the result into tResult
23842372
end if
23852373

23862374
if tResult is not a number then
2387-
return "unable to open table 'libraries'" & return & tResult
2375+
return "unable to open table 'apis'" & return & tResult
23882376
end if
23892377

23902378
# Create the library data table. This might already exist, so do it unchecked.
2391-
put "CREATE TABLE dictionary_data(library_id integer, entry_name text, entry_type text, entry_data blob)" into tSQL
2379+
put "CREATE TABLE dictionary_data(api_id integer, library_name text, entry_name text, entry_type text, entry_data blob)" into tSQL
23922380
revExecuteSQL pConnection, tSQL
23932381

2394-
revDocsUpdateLibrary pConnection, tName, pLibraryA["doc"]
2382+
local tName
2383+
put pLibraryA["display name"] into tName
2384+
2385+
revDocsUpdateLibrary pConnection, pAPI, tName, pLibraryA["doc"]
23952386
if the result is not empty then
23962387
return "unable to update data for library" && tName & return & the result
23972388
end if
23982389

23992390
return empty
24002391
end revDocsUpdateDatabase
24012392

2402-
on revDocsUpdateLibrary pConnection, pName, pDocDataA
2403-
# Find the library id
2404-
local tSQL, tLibraryID
2405-
put "SELECT library_id FROM libraries WHERE library_name = :1" into tSQL
2406-
put revDataFromQuery(comma, return, pConnection, tSQL, "pName") into tLibraryID
2393+
on revDocsUpdateLibrary pConnection, pAPI, pName, pDocDataA
2394+
# Find the API id
2395+
local tSQL, tAPIID
2396+
put "SELECT api_id FROM apis WHERE api_name = :1" into tSQL
2397+
put revDataFromQuery(comma, return, pConnection, tSQL, "pAPI") into tAPIID
24072398

24082399
if the result is not a number then
2409-
return "error finding library id for" && pName & return & the result
2400+
return "error finding api id for" && pAPI & return & the result
24102401
end if
24112402

24122403
local tDocA, tDocName
24132404
repeat for each element tDocA in pDocDataA
2414-
put tDocA["name"] into tDocName
2415-
if tDocName is empty then
2416-
put revDocsModifyForURL(tDocA["display name"]) into tDocName
2417-
end if
2418-
2405+
put tDocA["display name"] into tDocName
2406+
24192407
local tType
24202408
put tDocA["type"] into tType
24212409

24222410
local tEncodedData, tResult
24232411
put arrayEncode(tDocA) into tEncodedData
24242412
# Try an UPDATE first. If this fails, the entry might not exist already, so try an INSERT.
2425-
put "UPDATE dictionary_data SET entry_data = :1 WHERE entry_name = :2 AND entry_type = :3 AND library_id = :4" into tSQL
2426-
revExecuteSQL pConnection, tSQL, "*btEncodedData", "tDocName", "tType", "tLibraryID"
2413+
put "UPDATE dictionary_data SET entry_data = :1 WHERE library_name = :2" && \
2414+
"AND entry_name = :3 AND entry_type = :4 AND api_id = :5" into tSQL
2415+
revExecuteSQL pConnection, tSQL, "*btEncodedData", "pName", "tDocName", "tType", "tAPIID"
24272416
put the result into tResult
24282417
if tResult is not a number or tResult is 0 then
2429-
put "INSERT into dictionary_data VALUES(:1, :2, :3, :4)" into tSQL
2430-
revExecuteSQL pConnection, tSQL, "tLibraryID", "tDocName", "tType", "*btEncodedData"
2418+
put "INSERT into dictionary_data VALUES(:1, :2, :3, :4, :5)" into tSQL
2419+
revExecuteSQL pConnection, tSQL, "tAPIID", "pName", "tDocName", "tType", "*btEncodedData"
24312420
put the result into tResult
24322421
end if
24332422

@@ -2438,30 +2427,23 @@ on revDocsUpdateLibrary pConnection, pName, pDocDataA
24382427
return empty
24392428
end revDocsUpdateLibrary
24402429

2441-
on revDocsRemoveLibrary pConnection, pName
2430+
on revDocsRemoveLibrary pConnection, pAPI, pName
24422431
# Find the library id
2443-
local tSQL, tLibraryID
2444-
put "SELECT library_id FROM libraries WHERE library_name = :1" into tSQL
2445-
put revDataFromQuery(comma, return, pConnection, tSQL, pName) into tLibraryID
2432+
local tSQL, tAPIID
2433+
put "SELECT api_id FROM apis WHERE api_name = :1" into tSQL
2434+
put revDataFromQuery(comma, return, pConnection, tSQL, pAPI) into tAPIID
24462435

24472436
if the result is not a number then
2448-
return "error finding library id for" && pName & return & the result
2437+
return "error finding api id for" && pAPI & return & the result
24492438
end if
24502439

24512440
# Delete all entries associated with this library
2452-
put "DELETE * FROM dictionary_data WHERE library_id = :1" into tSQL
2453-
revExecuteSQL pConnection, tSQL, "tLibraryID"
2441+
put "DELETE * FROM dictionary_data WHERE api_id = :1 AND library_name = :2" into tSQL
2442+
revExecuteSQL pConnection, tSQL, "tAPIID", "pName"
24542443
if the result is not a number then
24552444
return "unable to delete data for" && pName & return & the result
24562445
end if
24572446

2458-
# Delete the library entry from the libraries table
2459-
put "DELETE * FROM libraries WHERE library_name = :1" into tSQL
2460-
revExecuteSQL pConnection, tSQL, pName
2461-
if the result is not a number then
2462-
return "unable to remove library" && pName && "from libraries table" & return & the result
2463-
end if
2464-
24652447
return empty
24662448
end revDocsRemoveLibrary
24672449

0 commit comments

Comments
 (0)