Skip to content

Commit cf864c3

Browse files
committed
[[ Docs ]] Support Edition element in lcdoc
This patch implements support for the `Edition` element in lcdoc files. The `Edition` element: - should have a value that corresponds to a LiveCode edition - is inherited and overridable when declared in a library document This patch also implements support for documentation to be read from component folders that declare their edition in a YAML metadata file.
1 parent ea61a64 commit cf864c3

File tree

5 files changed

+88
-109
lines changed

5 files changed

+88
-109
lines changed

builder/builder_utilities.livecodescript

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,9 @@ function builderMergExtVersion
323323
return kMergExtVersion
324324
end builderMergExtVersion
325325

326-
function builderUnpackFolder
327-
return sWorkDir & "/ext/unpacked"
326+
function builderUnpackFolder pEdition
327+
replace space with "_" in pEdition
328+
return sWorkDir & "/ext/unpacked/" & toLower(pEdition)
328329
end builderUnpackFolder
329330

330331
function builderTSNetVersion
@@ -595,7 +596,7 @@ end builderMergExtDownloadedFilePath
595596

596597
private command builderMergExtUnpack pMergExtVersion, pEdition
597598
local tFolder
598-
put builderUnpackFolder() & slash & "Ext" into tFolder
599+
put builderUnpackFolder(pEdition) & slash & "Ext" into tFolder
599600

600601
local tZipFile
601602
put builderMergExtDownloadedFilePath(pMergExtVersion, pEdition) into tZipFile
@@ -620,7 +621,7 @@ end builderTSNetDownloadedFilePath
620621

621622
private command builderTSNetUnpack pTSNetVersion, pEdition
622623
local tFolder
623-
put builderUnpackFolder() & slash & "Ext" into tFolder
624+
put builderUnpackFolder(pEdition) & slash & "Ext" into tFolder
624625

625626
local tZipFile
626627
put builderTSNetDownloadedFilePath(pTSNetVersion, pEdition) into tZipFile
@@ -637,7 +638,7 @@ end builderTSNetUnpack
637638

638639
command builderExtUnpack pEdition
639640
local tFolder
640-
put builderUnpackFolder() & slash & "Ext" into tFolder
641+
put builderUnpackFolder(pEdition) & slash & "Ext" into tFolder
641642

642643
if there is a folder tFolder then
643644
builderLog "message", "Cleaning unpack folder" && tFolder
@@ -678,7 +679,7 @@ An commma delimited list
678679
679680
**/
680681
function builderEditionNames
681-
return "Business,Indy,Community Extra,Community"
682+
return "Business,Indy,Community+,Community"
682683
end builderEditionNames
683684

684685
/**

builder/docs_builder.livecodescript

Lines changed: 45 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,7 @@ end escape
19131913
command docsBuilderGenerateDocsNew pEdition, pVersion
19141914
start using stack (builderRepoFolder() & slash & "ide-support" & slash & "revdocsparser.livecodescript")
19151915

1916-
builderExtUnpack pEdition
1916+
builderExtUnpack "Business"
19171917

19181918
builderLog "report", "Building guide into" && builderGuideFolder(pEdition) & slash & "distributed_guide.js"
19191919
pathEnsure (builderGuideFolder(pEdition))
@@ -1946,14 +1946,6 @@ private command addFolderToListIfExists pFolder, pThrowIfNot, @xArray
19461946
end if
19471947
end addFolderToListIfExists
19481948

1949-
private function RepoEditionDocsFolder pEdition
1950-
if editionIsInPrivateRepo(pEdition) then
1951-
return builderPrivateRepoFolder() & slash & "docs" & slash & toLower(pEdition)
1952-
else
1953-
return builderRepoFolder() & slash & "docs" & slash & toLower(pEdition)
1954-
end if
1955-
end RepoEditionDocsFolder
1956-
19571949
private command docsBuilderGetGuideFolders pEdition, @xFolders
19581950
local tRepoGuides
19591951
put builderRepoFolder() & slash & "docs" & slash & "guides" into tRepoGuides
@@ -1963,49 +1955,31 @@ private command docsBuilderGetGuideFolders pEdition, @xFolders
19631955
put builderIDEDocsFolder() & slash & "guides" into tIDEGuides
19641956
addFolderToListIfExists tIDEGuides, true, xFolders
19651957

1966-
repeat for each item tEdition in "indy,business"
1967-
if editionCompare(pEdition, tEdition) >= 0 then
1968-
local tGuides
1969-
put RepoEditionDocsFolder(tEdition) & slash & "guides" into tGuides
1970-
addFolderToListIfExists tGuides, false, xFolders
1958+
local tComponents
1959+
put builderComponentFolders() into tComponents
1960+
1961+
repeat for each element tComponent in tComponents
1962+
if editionCompare(pEdition, tComponent["metadata"]["edition"]) >= 0 then
1963+
addFolderToListIfExists tComponent["folder"] & slash & "guides", false, xFolders
19711964
end if
19721965
end repeat
1973-
1966+
19741967
addFolderToListIfExists builderBuiltGuidesFolder(), false, xFolders
19751968
end docsBuilderGetGuideFolders
19761969

19771970
private command docsBuilderAddExtFolders pEdition, @xFolders
1978-
local tDefaultFolder
1979-
put the defaultFolder into tDefaultFolder
1980-
19811971
local tTargetFolder
1982-
put builderUnpackFolder() & slash & "Ext" into tTargetFolder
1983-
set the defaultFolder to tTargetFolder
1984-
1985-
repeat for each line tFolder in the folders
1972+
put builderUnpackFolder("Business") & slash & "Ext" into tTargetFolder
1973+
repeat for each line tFolder in folders(tTargetFolder)
19861974
if tFolder is ".." then next repeat
19871975
addFolderToListIfExists tTargetFolder & slash & tFolder, true, xFolders
19881976
end repeat
1989-
1990-
set the defaultFolder to tDefaultFolder
19911977
end docsBuilderAddExtFolders
19921978

19931979
private command docsBuilderGetAdditionalFolders pEdition, @xFolders
19941980
docsBuilderAddExtFolders pEdition, xFolders
19951981
end docsBuilderGetAdditionalFolders
19961982

1997-
private command docsBuilderGetDictionaryFolders pEdition, @xFolders
1998-
local tCommunityDocs
1999-
put builderRepoFolder() & slash & "docs" into tCommunityDocs
2000-
addFolderToListIfExists tCommunityDocs, true, xFolders
2001-
2002-
repeat for each item tEdition in "indy,business"
2003-
if editionCompare(pEdition, tEdition) >= 0 then
2004-
addFolderToListIfExists RepoEditionDocsFolder(), true, xFolders
2005-
end if
2006-
end repeat
2007-
end docsBuilderGetDictionaryFolders
2008-
20091983
command docsBuilderGenerateDistributedGuide pEdition
20101984
local tGuideFoldersA
20111985
docsBuilderGetGuideFolders pEdition, tGuideFoldersA
@@ -2048,26 +2022,22 @@ end docsFileGetUTF8Contents
20482022

20492023
-- Find all lcdoc files in pFolder and add them to the list of docs
20502024
-- data in xLibraryA
2051-
private command addToDictionaryFromFolder pFolder, @xLibraryA
2052-
local tDefaultFolder
2053-
put the defaultFolder into tDefaultFolder
2054-
2025+
private command addToDictionaryFromFolder pFolder, pDefaults, @xLibraryA
20552026
docsBuilderProgressUpdate "", "Building dictionary from folder" && pFolder
2056-
set the defaultfolder to pFolder
2057-
get the files
2027+
2028+
get files(pFolder)
20582029
filter it with "*.lcdoc"
20592030
repeat for each line tFile in it
20602031
local tText, tParsedA
20612032
wait 0 with messages
20622033
put docsFileGetUTF8Contents(pFolder & slash & tFile, true) into tText
2063-
put revDocsParseDocText(tText) into tParsedA
2034+
put revDocsParseDocText(tText, pFolder & slash & tFile, pDefaults) into tParsedA
20642035
repeat for each element tDoc in tParsedA["doc"]
20652036
-- TODO: Work out why something empty is returned
20662037
if tDoc["display name"] is empty then next repeat
20672038
addToList tDoc, xLibraryA
20682039
end repeat
20692040
end repeat
2070-
set the defaultFolder to tDefaultFolder
20712041
end addToDictionaryFromFolder
20722042

20732043
/*
@@ -2077,40 +2047,39 @@ pRootDirs (array): An array of paths to the relevant root folders of the
20772047
dictionary.
20782048
*/
20792049

2080-
command docsBuilderParseDictionaryToLibraryArray pRootDirs, @xDocsA
2081-
local tDefaultFolder
2082-
put the defaultFolder into tDefaultFolder
2083-
2084-
# Get the list of canonical glossary entries
2085-
local tGlossaryA
2086-
repeat for each element tRootDir in pRootDirs
2087-
union tGlossaryA with revDocsCollectGlossarySynonyms(tRootDir)
2088-
end repeat
2089-
2090-
repeat for each element tRootDir in pRootDirs
2050+
command docsBuilderParseDictionaryToLibraryArray pComponents, @xDocsA
2051+
repeat for each element tComponent in pComponents
20912052
local tDictionaryRoot, tGlossaryRoot
2092-
put tRootDir & slash & "dictionary" into tDictionaryRoot
2093-
put tRootDir & slash & "glossary" into tGlossaryRoot
2053+
put tComponent["folder"] & slash & "dictionary" into tDictionaryRoot
2054+
put tComponent["folder"] & slash & "glossary" into tGlossaryRoot
2055+
2056+
local tDefaults
2057+
delete variable tDefaults
2058+
if tComponent["metadata"]["edition"] is not empty then
2059+
put editionDisplayName(tComponent["metadata"]["edition"]) into tDefaults["edition"]
2060+
end if
20942061

20952062
repeat for each item tRoot in (tDictionaryRoot & "," & tGlossaryRoot)
2096-
set the defaultfolder to tRoot
2097-
repeat for each line tLine in the folders
2063+
if there is not a folder tRoot then
2064+
next repeat
2065+
end if
2066+
2067+
repeat for each line tLine in folders(tRoot)
20982068
if tLine is ".." then next repeat
2099-
addToDictionaryFromFolder tRoot & slash & tLine, xDocsA
2069+
addToDictionaryFromFolder tRoot & slash & tLine, tDefaults, xDocsA
21002070
end repeat
21012071
end repeat
21022072
end repeat
2103-
set the defaultFolder to tDefaultFolder
21042073
end docsBuilderParseDictionaryToLibraryArray
21052074

21062075
command docsBuilderParseAdditionalFoldersToLibraryArray pDirs, @xDocsA
21072076
local tFolder
21082077
repeat for each element tFolder in pDirs
2109-
addToDictionaryFromFolder tFolder, xDocsA
2078+
addToDictionaryFromFolder tFolder, empty, xDocsA
21102079
end repeat
21112080
end docsBuilderParseAdditionalFoldersToLibraryArray
21122081

2113-
function docsBuilderParseDictionary pLibraryName, pAuthor, pRootDirsA, pAdditionalDirsA, pRecursive
2082+
function docsBuilderParseDictionary pLibraryName, pAuthor, pComponents, pAdditionalDirsA, pRecursive
21142083
local tLibraryA
21152084

21162085
put revDocsModifyForUrl(pLibraryName) into tLibraryA["name"]
@@ -2119,7 +2088,7 @@ function docsBuilderParseDictionary pLibraryName, pAuthor, pRootDirsA, pAddition
21192088
put "dictionary" into tLibraryA["type"]
21202089

21212090
-- Special case for the dictionary / glossary data extraction
2122-
docsBuilderParseDictionaryToLibraryArray pRootDirsA, tLibraryA["doc"]
2091+
docsBuilderParseDictionaryToLibraryArray pComponents, tLibraryA["doc"]
21232092

21242093
-- Add any additional docs to the dictionary
21252094
docsBuilderParseAdditionalFoldersToLibraryArray pAdditionalDirsA, tLibraryA["doc"]
@@ -2132,14 +2101,23 @@ function docsBuilderParseDictionary pLibraryName, pAuthor, pRootDirsA, pAddition
21322101
end docsBuilderParseDictionary
21332102

21342103
command docsBuilderGenerateDistributedAPI pEdition
2135-
local tDictionaryFolders, tAdditionalFolders
2136-
docsBuilderGetDictionaryFolders pEdition, tDictionaryFolders
2104+
local tAdditionalFolders
21372105
docsBuilderGetAdditionalFolders pEdition, tAdditionalFolders
21382106

21392107
local tLibrariesA
21402108

2109+
local tComponents
2110+
put builderComponentFolders() into tComponents
2111+
2112+
-- special case the main docs folder
2113+
local tIndex
2114+
put the number of elements of tComponents + 1 into tIndex
2115+
put builderRepoFolder() & "/docs" into tComponents[tIndex]["folder"]
2116+
put "engine" into tComponents[tIndex]["metadata"]["category"]
2117+
put "community" into tComponents[tIndex]["metadata"]["edition"]
2118+
21412119
local tLCSDictionaryA
2142-
put docsBuilderParseDictionary("LiveCode Script", "LiveCode", tDictionaryFolders, tAdditionalFolders, false) into tLCSDictionaryA
2120+
put docsBuilderParseDictionary("LiveCode Script", "LiveCode", tComponents, tAdditionalFolders, false) into tLCSDictionaryA
21432121

21442122
if tLCSDictionaryA is empty then
21452123
logError "Couldn't parse script dictionary data for" && pEdition

builder/release_notes_builder.livecodescript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ command releaseNotesBuilderRun pEdition, pVersion, pReleaseType, pOutputDir
7070
put "extension" into tComponents[tIndex]["metadata"]["category"]
7171

7272
if tPath is builderPrivateRepoFolder() then
73-
put "community extra" into tComponents[tIndex]["metadata"]["edition"]
73+
put "community+" into tComponents[tIndex]["metadata"]["edition"]
7474
else
7575
put "community" into tComponents[tIndex]["metadata"]["edition"]
7676
end if

builder/tools_builder.livecodescript

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private command toolsBuilderPrepareExt pEdition, pPlatform
130130
-- Remove un-needed files from the unpacked Ext collection
131131
local tOldFolder
132132
local tCollectionFolder
133-
put builderUnpackFolder() & slash & "Ext" into tCollectionFolder
133+
put builderUnpackFolder(pEdition) & slash & "Ext" into tCollectionFolder
134134
put the defaultFolder into tOldFolder
135135
set the defaultFolder to tCollectionFolder
136136
repeat for each line tExtension in the folders
@@ -198,7 +198,7 @@ private command toolsBuilderMakePackage pVersion, pEdition, pPlatform, pEngineFo
198198
packageCompilerConfigureSOurce tPackager, "emscripten", pEngineFolders["emscripten"]
199199
packageCompilerConfigureSource tPackager, "prebuilt", builderRepoFolder() & slash & "prebuilt"
200200
packageCompilerConfigureSource tPackager, "repo", builderRepoFolder()
201-
packageCompilerConfigureSource tPackager, "ext", builderUnpackFolder()
201+
packageCompilerConfigureSource tPackager, "ext", builderUnpackFolder(pEdition)
202202
if editionIsInPrivateRepo(tEditionType) then
203203
packageCompilerConfigureSource tPackager, "private", builderPrivateRepoFolder()
204204
end if

0 commit comments

Comments
 (0)