script "DocsBuilder" # The max number allowed constant kFilesPerClump = 50 # Probably not a good idea to change this... constant kClumpNamePrefix = "revDocClump_" private function docsBuilderGetSourceDirectory return builderDocsFolder() end docsBuilderGetSourceDirectory private function docsBuilderGetOutputDirectory return builderBuiltDocsFolder() end docsBuilderGetOutputDirectory command docsBuilderProgressUpdate pProgress, pMessage builderLog "message", pMessage end docsBuilderProgressUpdate command errorShow pError builderLog "error", pError throw pError end errorShow command docsBuilderRun pEdition, pVersion set the itemdelimiter to "." if item 1 of pVersion > 7 then docsBuilderGenerateDocsNew exit docsBuilderRun end if local tSourceDir, tOutputDir put docsBuilderGetSourceDirectory() into tSourceDir put docsBuilderGetOutputDirectory() & "/packaged_xml" into tOutputDir start using stack (builderIdeRepoFolder() & slash & "Toolset/palettes/revdocumentationlibrary.rev") builderLog "report", "Building docs into" && tOutputDir buildDocumentation tSourceDir & "/dictionary", tSourceDir & "/glossary", tOutputDir & "/dictionary", tOutputDir & "/glossary", tOutputDir, "docsBuilderProgressUpdate", the long id of me builderLog "report", "Building docs into" && tOutputDir && "complete" end docsBuilderRun command buildDocumentation pDictionaryInputDirectory, pGlossaryInputDirectory, pDictionaryOutputDirectory, pGlossaryOutputDirectory, pManifestOutputDirectory, pCallback, pCallbackTarget initializeProgress pCallback, pCallbackTarget reportProgress "Cleaning Directory", 0, "Cleaning Existing Structure" # Create the subdirectories we need. pathEnsure (pDictionaryOutputDirectory) pathEnsure (pGlossaryOutputDirectory) # Ensure the subDirectories we need were created. if there is no folder pDictionaryOutputDirectory then errorShow "libDocumentClumpGenerateAll", "Invalid output directory: " & pDictionaryOutputDirectory exit buildDocumentation end if if there is no folder pGlossaryOutputDirectory then errorShow "libDocumentClumpGenerateAll", "Invalid output directory: " & pGlossaryOutputDirectory exit buildDocumentation end if # Clean any existing clumps out of memory to prevent interference. deleteExistingClumpsFromMemory local tFileToDirectory, tLinkLookup # Get the the file reference information libDocumentationListXMLFiles pGlossaryInputDirectory, tFileToDirectory reportProgress "Glossary", 0, "Listed XML files" libDocumentationListXMLFiles pDictionaryInputDirectory, tFileToDirectory reportProgress "Dictionary", 0, "Listed XML files" #Get the cross reference information for the internal links libDocumentationCreateDocRefs tFileToDirectory put libCreateLookupTable (tFileToDirectory) into tLinkLookup # Build XRef symmetry - create symmetry entries in the lookup array libDocumentationCreateXRefSymmertry tFileToDirectory, tLinkLookup # Compile the dictionary and glossary into a collection of stacks with # compressed custom properties. compileDictionaryIntoStacks pDictionaryInputDirectory, pDictionaryOutputDirectory, tFileToDirectory, tLinkLookup compileGlossaryIntoStacks pGlossaryInputDirectory, pGlossaryOutputDirectory, tFileToDirectory, tLinkLookup # Create a manifest in the packaged_xml directory as the files are dynamic. createManifest pManifestOutputDirectory reportProgress empty, 100, "Done" end buildDocumentation local sProgress local sProgressCallback local sProgressCallbackTarget local sProgressStepStatus // HSC - tested - complies with current dictionary format private command initializeProgress pCallback, pCallbackTarget put empty into sProgress put empty into sProgressStepStatus # The callback is optional. if pCallback is not empty and pCallbackTarget is not empty then put pCallback into sProgressCallback put pCallbackTarget into sProgressCallbackTarget end if end initializeProgress local sLastTime private command reportProgress pStep, pPercentage, pMessage # This lets us configure the approximate proportions each step is of the whole process, # so that the progress is fairly smooth. (These are quite rough...) local tProportion switch pStep case "Dictionary" put 20 into tProportion break case "Glossary" put 1 into tProportion break case "Creating glossary index" put 4 into tProportion break case "Manifest" put "4" into tProportion break case "Cleaning Directory" put 11 into tProportion break case "Creating dictionary index" put 33 into tProportion break case "Verifying dictionary" put 37 into tProportion break end switch # When a step is complete, add its proportion to the current progress. # The current progess is the overall progress plus the step percentage. local tStepPercentage if pPercentage = 100 then if sProgressStepStatus[pStep] is not "Complete" then put "Complete" into sProgressStepStatus[pStep] add tProportion to sProgress end if put 0 into tStepPercentage else put ((pPercentage / 100) * tProportion) into tStepPercentage end if local tCurrentProgress put sProgress + tStepPercentage into tCurrentProgress # Here we can send a message back to the caller to indicate progress # of the docs building, but for now we just display progress on the card. if sProgressCallback is not empty and sProgressCallbackTarget is not empty then send sProgressCallback && "tCurrentProgress, pMessage" to sProgressCallbackTarget end if if the mode of me is not 0 and the visible of me then if the millisecs - sLastTime > 500 then statusSet pMessage set the thumbPosition of scrollbar 1 of me to tCurrentProgress put the millisecs into sLastTime end if end if end reportProgress private command statusSet pMessage put pMessage into field "Status" of me end statusSet // HSC - tested - complies with current dictionary format private command deleteExistingClumpsFromMemory repeat for each line tStack in the mainstacks if tStack begins with "revDocClump_" then lock messages delete stack tStack unlock messages end if end repeat end deleteExistingClumpsFromMemory private command compileGlossaryIntoStacks pInputDirectory, pOutputDirectory, @pFileToDirectory, @pLinkLookup local tArrIndex, tFilePath, tRelFilePath, tKeyNumber local tOldPath put the directory into tOldPath local tPath put pInputDirectory into tPath set the directory to tPath reportProgress "Glossary", 0, "Listed XML files" -- Now loop through the list of files and add the file data to the relevant clump local tFileNumber, tClumpNumber, tClumpName, tCount = 1 repeat with tArrIndex = 1 to the number of elements of pFileToDirectory -- Work out which clump to add the file to from its name (number) if pFileToDirectory[tArrIndex]["type"] is "glossary" then put ((tArrIndex - 1) div kFilesPerClump) + 1 into tClumpNumber put kClumpNamePrefix & tClumpNumber into tClumpName if there is no stack tClumpName then libDocumentationClumpCreate tClumpNumber, pOutputDirectory end if -- Get the relative file path of the entry put pFileToDirectory[tArrIndex]["path"] into tFilepath set the itemDelimiter to slash put item -3 to -1 of tFilepath into tRelFilepath put libDocumentationClumpAddTo(tClumpName, tArrIndex, pFileToDirectory, pOutputDirectory, pLinkLookup) into tKeyNumber reportProgress "Glossary", ((tArrIndex / the number of elements of pFileToDirectory) * 100), "Added glossary entry: " & item -1 of tFilePath //reportProgress "Glossary", ((tArrIndex / the number of lines of pFileToDirectory) * 100), "Added glossary entry: " & item -1 of tFilePath set the itemDelimiter to comma end if end repeat -- Clean up repeat for each line tStack in the mainStacks if char 1 to (the length of kClumpNamePrefix) of tStack is kClumpNamePrefix then delete stack tStack end if end repeat reportProgress "Glossary", 100, "Glossary Built" # Build the index for the xml files libDocumentationBuildGlossaryIndex pFileToDirectory, pOutputDirectory end compileGlossaryIntoStacks // HSC - tested - complies with current dictionary format private command libDocumentationListXMLFiles pDirectory, @rFileToPath local tOldDirectory put the directory into tOldDirectory set the directory to pDirectory local tDirectories put the folders into tDirectories filter tDirectories without ".." local tFiles, tItems put the number of elements of rFileToPath into tItems repeat for each line tDirectory in tDirectories set the directory to pDirectory & slash & tDirectory put the files into tFiles filter tFiles with "*.xml" repeat for each line tFile in tFiles if tFile is not "" then add 1 to tItems put pDirectory & slash & tDirectory & slash & tFile into rFileToPath[tItems]["path"] put tFile into rFileToPath[tItems]["name"] if the length of tDirectory is 1 then put "glossary" into rFileToPath[tItems]["type"] else put tDirectory into rFileToPath[tItems]["type"] end if end if end repeat end repeat set the directory to tOldDirectory end libDocumentationListXMLFiles private command libDocumentationCreateDocRefs @rFileToDirectory local tTree, tName, tArrIndex repeat with tArrIndex = 1 to the number of elements of rFileToDirectory open file rFileToDirectory[tArrIndex]["path"] for read read from file rFileToDirectory[tArrIndex]["path"] until EOF // extract the or from the files and update the rFileToDirectory information put revCreateXMLTree(it, false, true, false) into tTree if tTree is not an integer then errorShow "Failed to process preferences file with error: " & tTree return empty end if put revXMLNodeContents(tTree, "doc/name") into tName if matchText(tName,"xmlerr") then put revXMLNodeContents(tTree, "doc/term") into tName end if if matchText(tName,"xmlerr") then //breakpoint end if // Build XRef symmetry - add see also links to the array structure local tXrefs, tXref, tXrefToReplace, tTextStart, tTextEnd, tOffsetFound put libGetTextLocation (it, "", "", tTextStart, tTextEnd) into tXrefs if tTextStart is not 0 and tTextEnd is not 0 then replace "" with "" in tXrefs put true into tOffsetFound set the itemDelimiter to space repeat while tOffsetFound // need to include the tStartTags in another repeat loop this will be for the new files. put libGetTextLocation (tXrefs, "<", ">", tTextStart, tTextEnd) into tXrefToReplace if tTextStart is 0 and tTextEnd is 0 then put false into tOffsetFound else put tXrefToReplace into tXref replace "<" with "" in tXref replace ">" with "" in tXref replace "tag=" with "" in tXref replace quote with "" in tXref replace tXrefToReplace with tXref in tXrefs if character 1 of tXref is not "/" then put tXref & return after rFileToDirectory[tArrIndex]["xrefs"] end if end if end repeat end if // need the following line as revXMLNodeContents decides to turn "&" into "&" put escapeEntities (tName) into tName put tName into rFileToDirectory[tArrIndex]["ref"] close file rFileToDirectory[tArrIndex]["path"] end repeat end libDocumentationCreateDocRefs command libDocumentationCreateXRefSymmertry @rFileToDirectory, @rLinkLookup local tArrIndex, tReferenceTo repeat with tArrIndex = 1 to the number of elements of rFileToDirectory if "xrefs" is among the keys of rFileToDirectory[tArrIndex] then repeat for each line tReferenceTo in rFileToDirectory[tArrIndex]["xrefs"] if rFileToDirectory[tArrIndex]["type"] && rFileToDirectory[tArrIndex]["ref"] is not among the lines of rFileToDirectory[rLinkLookup[tReferenceTo]]["xrefs"] then put rFileToDirectory[tArrIndex]["type"] && rFileToDirectory[tArrIndex]["ref"] & return after rFileToDirectory[rLinkLookup[tReferenceTo]]["xrefs"] end if end repeat end if end repeat end libDocumentationCreateXRefSymmertry private command createManifest pDirectory reportProgress "Manifest", 0, "Listing files for manifest" local tFiles put utilityEnumerateDirectory(pDirectory) into tFiles reportProgress "Manifest", 70, "Finished listing manifest files" local tManifest repeat for each line tFile in tFiles if the last char of tFile is slash then # Don't include directories next repeat end if if tFile ends with "/Manifest" then next repeat end if put "file," & slash & tFile & return after tManifest end repeat delete the last char of tManifest local tResult put tManifest into url ("file:" & pDirectory & "/Manifest") put the result into tResult if tResult is not empty then errorShow "Failed to write manifest at location: " & pDirectory & "/Manifest" & return & "With error: " & tResult exit createManifest end if reportProgress "Manifest", 100, "Finished creating manifest" end createManifest # Stolen from standalone builder. private function utilityEnumerateDirectory pDirectory, pPrefix local tOldDirectory, tResult put the folder into tOldDirectory set the folder to pDirectory # OK-2008-09-10 : Bug 7147 - Prevent the possibility of an infinite loop by # returning empty if the directory cannot be set to pDirectory if the folder is not pDirectory then return empty end if repeat for each line tSubDirectory in the folders if tSubDirectory is among the items of ".,.." then next repeat end if # For our purposes we need the directory first, so it can be created ahead of file creation.. put pPrefix & tSubDirectory & "/" & return after tResult get utilityEnumerateDirectory(pDirectory & "/" & tSubDirectory, pPrefix & tSubDirectory & "/") if it is not empty then put it & return after tResult end if end repeat local tFileSize repeat for each line tFile in the files put pPrefix & tFile & return after tResult end repeat set the folder to tOldDirectory delete the last char of tResult return tResult end utilityEnumerateDirectory private function extractFileNumberFromPath pPath set the itemDelimiter to slash get item -1 of pPath set the itemDelimiter to "." return item 1 of it end extractFileNumberFromPath private command compileDictionaryIntoStacks pInputDirectory, pOutputDirectory, @pFileToDirectory, @pLinkLookup local tDocDirectory, tDirectory, tDirectories, tFile, tFiles, tFilepath local tCurrentClumpNumber, tIndexData, tKeyNumber, tRelFilepath, tOutputDirectory local tXMLFiles, tFileToPath local tOldPath put the directory into tOldPath local tPath put pInputDirectory into tPath set the directory to tPath reportProgress "Dictionary", 0, "Listed XML files" -- Now loop through the list of files and add the file data to the relevant clump local tFileNumber, tClumpNumber, tClumpName, tCount = 1 repeat with tArrIndex = 1 to the number of elements of pFileToDirectory -- Work out which clump to add the file to from its name (number) if pFileToDirectory[tArrIndex]["type"] is not "glossary" then put ((tArrIndex - 1) div kFilesPerClump) + 1 into tClumpNumber put kClumpNamePrefix & tClumpNumber into tClumpName if there is no stack tClumpName then libDocumentationClumpCreate tClumpNumber, pOutputDirectory end if -- Get the relative file path of the entry put pFileToDirectory[tArrIndex]["path"] into tFilepath set the itemDelimiter to slash put item -3 to -1 of tFilepath into tRelFilepath put libDocumentationClumpAddTo(tClumpName, tArrIndex, pFileToDirectory, pOutputDirectory, pLinkLookup) into tKeyNumber if tArrIndex mod 10 is 0 then reportProgress "Dictionary", ((tArrIndex / the number of elements of pFileToDirectory) * 100), "Added dictionary entry: " & item -1 of tFilePath end if set the itemDelimiter to comma end if end repeat -- Clean up repeat for each line tStack in the mainStacks if char 1 to (the length of kClumpNamePrefix) of tStack is kClumpNamePrefix then delete stack tStack end if end repeat reportProgress "Dictionary", 100, "Dictionary built" # Build the index for the xml files libDocumentationBuildDictionaryIndex pFileToDirectory, pOutputDirectory # Verify that the documentation is complete, we only bother doing this with the dictionary, # as broken glossary entries don't matter as much. local tResult libDocumentationVerifyAll "dictionary/", pOutputDirectory put the result into tResult if the result is not empty then throw "generation_failed - " & "libDocumentationClumpGenerateAll", "The following docs failed to build: " & return & tResult exit to top end if end compileDictionaryIntoStacks private function getIndexFileName pDirectory if pDirectory is "dictionary/" then return "dict.index" else return "glos.index" end if end getIndexFileName private command libDocumentationVerifyAll pDocDirectory, pOutputDirectory reportProgress "Verifying dictionary", 0, "Verifying dictionary" local tIndexPath local tIndexFileName put getIndexFileName(pDocDirectory) into tIndexFileName set the itemDelimiter to slash put item 1 to -3 of pOutputDirectory & slash & tIndexFileName into tIndexPath set the itemDelimiter to comma local tIndex put url ("binfile:" & tIndexPath) into tIndex put arrayDecode(tIndex) into tIndex local tDocsDirectory set the itemDelimiter to slash put item 1 to -3 of pOutputDirectory into tDocsDirectory set the itemDelimiter to comma local tResult local tType, tTag set the itemDelimiter to tab local tTotal put the number of lines of the keys of tIndex into tTotal local tLineNumber put 1 into tLineNumber repeat for each key tLine in tIndex put "dictionary/" into tType put tIndex[tLine]["ID"] into tTag local tData try put revDocumentationRetrieve(tType, tTag, tDocsDirectory) into tData if tData is empty then put "Failed to load dictionary entry: " & tTag && tType & return after tResult end if catch tError put "Failed to load dictionary entry: " & tTag && tType & return after tResult end try if tLineNumber mod 10 = 0 then reportProgress "Verifying dictionary", ((tLineNumber / tTotal) * 100), "Verified dictionary entry: " & tLine end if add 1 to tLineNumber end repeat reportProgress "Verifying dictionary", 100, "Dictionary verified" return tResult end libDocumentationVerifyAll private command libDocumentationBuildGlossaryIndex pFileToDirectory, pOutputDirectory local tStep put "Creating glossary index" into tStep reportProgress tStep, 0, tStep local tIndexFileName put getIndexFileName("glossary/") into tIndexFileName local tIndexFile set the itemDelimiter to slash put item 1 to -3 of pOutputDirectory & slash & tIndexFileName into tIndexFile local tIndex, tPath, tLine local tArrIndex repeat with tArrIndex = 1 to the number of elements of pFileToDirectory if pFileToDirectory[tArrIndex]["type"] is "glossary" then put pFileToDirectory[tArrIndex]["path"] into tPath put indexGlossaryLine(tPath, tArrIndex) into tLine put tLine & return after tIndex end if reportProgress tStep, ((tArrIndex / the number of elements of pFileToDirectory) * 100), "Indexed glossary file: " & item -1 of tPath end repeat set the itemDelimiter to comma delete the last char of tIndex local tResult put tIndex into url ("file:" & tIndexFile) put the result into tResult if tResult is not empty then errorShow "Failed to write to file: " & tIndexFile & " with error : " & tResult exit libDocumentationBuildGlossaryIndex end if reportProgress tStep, 100, "Index creation finished" end libDocumentationBuildGlossaryIndex // HSC - tested - complies with current dictionary format private command libDocumentationBuildDictionaryIndex pFileToDirectory, pOutputDirectory local tStep put "Creating dictionary index" into tStep reportProgress tStep, 0, tStep local tIndexFileName put getIndexFileName("dictionary/") into tIndexFileName local tIndexFile set the itemDelimiter to slash put item 1 to -3 of pOutputDirectory & slash & tIndexFileName into tIndexFile local tIndex, tLine, tArrIndex, tPath local tLineNumber put 0 into tLineNumber repeat with tArrIndex = 1 to the number of elements of pFileToDirectory if pFileToDirectory[tArrIndex]["type"] is not "glossary" then add 1 to tLineNumber put pFileToDirectory[tArrIndex]["path"] into tPath put indexLine(tPath, tArrIndex) into tLine put tLine into tIndex[tLineNumber] local tSynonyms put expandSynonyms(tPath, tArrIndex) into tSynonyms if tSynonyms is an array then repeat for each key tKey in tSynonyms add 1 to tLineNumber put tSynonyms[tKey] into tIndex[tLineNumber] end repeat end if end if reportProgress tStep, ((tArrIndex / the number of elements of pFileToDirectory) * 100), "Indexed dictionary file: " & item -1 of tPath end repeat set the itemDelimiter to comma local tResult put arrayEncode(tIndex) into url ("binfile:" & tIndexFile) put the result into tResult if tResult is not empty then errorShow "Failed to write to file: " & tIndexFile & " with error: " & tResult exit libDocumentationBuildDictionaryIndex end if reportProgress tStep, 100, "Index creation finished" end libDocumentationBuildDictionaryIndex # This function does the following: # 1. Opens the file pDocument and creates an xml tree of the contents. # 2. Extract the "synonyms" node and processes it to obtain a list of the synonyms. # 3. For each synonym, creates an index line linking to pDocument # 4. Returns the list of index lines private function expandSynonyms pDocument, pFilename local tData put url ("binfile:" & pDocument) into tData if tData is empty then errorShow "No data for file: " & pDocument exit expandSynonyms end if local tTree put revCreateXMLTree(tData, false, true, false) into tTree local tRoot put revXMLRootNode(tTree) into tRoot if tTree is not a number then errorShow "The document " & pDocument & " cannot be parsed by revXML" exit expandSynonyms end if if tRoot is not "doc" then errorShow "The document " & pDocument & " is not a valid dictionary entry because its root node is not " exit expandSynonyms end if # Synonyms are stored as: # # wd # window # revXMLChildNames gives us a return-delimited list of each node containing a synonym. local tNodes put revXMLChildNames(tTree, "/doc/synonyms", return, "synonym", true) into tNodes if tNodes is empty or item 1 of tNodes is "xmlerr" then # No synonyms found, exit now... return empty end if local tIndexLine put indexLine(pDocument, pFilename) into tIndexLine local tName -- set the itemDelimiter to tab -- put item 2 of tIndexLine into tName -- set the itemDelimiter to comma put tIndexLine["Keyword"] into tName local tSynonym, tSynonyms, tContent local tCount put 0 into tCount repeat for each line tNode in tNodes add 1 to tCount put revXMLNodeContents(tTree, "/doc/synonyms/" & tNode) into tContent # For each one, copy the index line from the main doc, but replace the doc's name with the synonym. put tIndexLine into tSynonym --set the itemDelimiter to tab # Replace the main name # put tContent into item 2 of tSynonym put tContent into tSynonym["Keyword"] # Replace any references to the name in the syntax (hopefully this won't cause irregular syntax problems...) --get item 4 of tSynonym get tSynonym["Syntax"] replace tName with tContent in it --put it into item 4 of tSynonym put it into tSynonym["Syntax"] --set the itemDelimiter to comma --put tSynonym & return after tSynonyms put tSynonym into tSynonyms[tCount] end repeat --delete the last char of tSynonyms revDeleteXMLTree tTree return tSynonyms end expandSynonyms -- Given the path to an xml documentation entry (dictionary only), -- returns the line of text in the dictionary index that corresponds -- to the document. // HSC - tested - complies with current dictionary format private function indexLine pDoc, pIndex local tFilename set the itemDelimiter to slash put item -1 of pDoc into tFilename local tData put url ("file:" & pDoc) into tData local tArray put pIndex into tArray["ID"] local tTree put revCreateXMLTree(tData, false, true, false) into tTree if tTree is not a number then breakpoint end if local tName, tCategory put escapeEntities(revXMLNodeContents(tTree, "doc/name")) into tArray["Keyword"] put revXMLNodeContents(tTree, "doc/type") into tArray["Type"] if item 1 of tArray["Keyword"] is "xmlerr" then errorShow "Could not extract name from the dictionary file : " & pDoc & " with error: " & tName exit indexLine end if if item 1 of tArray["Type"] is "xmlerr" then errorShow "Could not extract type from the glossary file : " & pDoc & " with error: " & tCategory exit indexLine end if local tSyntax set the itemDelimiter to comma put extractNodeXML(tTree, "doc/syntax/example") into tSyntax if item 1 of tSyntax is "xmlerr" then put empty into tArray["Syntax"] else put auxFormatSyntax(tSyntax) into tArray["Syntax"] end if local tSynonymInfo, tSynonyms put revXMLChildContents(tTree, "doc/synonyms", slash, comma, true, 1) into tSynonymInfo repeat for each item tChild in tSynonymInfo set the itemDelimiter to slash put item 2 to -1 of tChild & comma after tSynonyms set the itemDelimiter to comma end repeat if tSynonyms is not empty then delete the last char of tSynonyms end if put tSynonyms into tArray["Synonyms"] local tVersion set the itemDelimiter to comma put revXMLAttribute(tTree, "doc/history/introduced", "version") into tVersion if item 1 of tVersion is "xmlerr" then put empty into tArray["Version"] else put tVersion into tArray["Version"] end if put revDocumentationVersionDate(tArray["Version"]) into tArray["Date"] put empty into tArray["Notes"] local tLibrary put revXMLNodeContents(tTree, "doc/library") into tLibrary if item 1 of tLibrary is "xmlerr" then put empty into tArray["Library"] else put tLibrary into tArray["Library"] end if local tObjects put revXMLChildNames(tTree,"doc/objects",return,,false) into tObjects repeat for each word tObject in "Button Field Graphic Scrollbar Image Player Card Stack Group" if lower (tObject) is among the lines of tObjects or tObjects is "any object" then put merge("") into tArray[tObject] else put empty into tArray[tObject] end if end repeat local tClass, tLine put revXMLChildNames(tTree,"doc/classes",return,,false) into tClass put empty into tArray["Platforms"] if "desktop" is among the lines of tClass then put "Desktop, " after tArray["Platforms"] end if if "server" is among the lines of tClass then put "Server, " after tArray["Platforms"] end if if "web" is among the lines of tClass then put "Web, " after tArray["Platforms"] end if if "mobile" is among the lines of tClass then put "Mobile, " after tArray["Platforms"] end if if tArray["Platforms"] is not empty then put item 1 to -2 of tArray["Platforms"] into tArray["Platforms"] else //put "" into tArray["Platforms"] put "Desktop, Server, Web, Mobile" into tArray["Platforms"] end if local tSecurity put revXMLChildNames(tTree,"doc/security",return,,false) into tSecurity put empty into tArray["Security"] local tCapitalEntry repeat for each line tLine in tSecurity put tLine into tCapitalEntry put toUpper (character 1 of tCapitalEntry) into character 1 of tCapitalEntry put tArray["Security"] & tCapitalEntry & comma & space into tArray["Security"] end repeat if tArray["Security"] is not empty then put item 1 to -2 of tArray["Security"] into tArray["Security"] else put "None required" into tArray["Security"] end if // We are not supporting Products anymore put "" into tArray["Products"] local tPlatforms put extractPlatformInformation(tTree) into tPlatforms //HSC-ND put tPlatforms into tArray["Platforms"] put tPlatforms into tArray["Operating Systems"] revDeleteXMLTree tTree return tArray end indexLine function indexGlossaryLine pDoc, pIndex local tFilename set the itemDelimiter to slash put item -1 of pDoc into tFilename local tData put url ("file:" & pDoc) into tData local tTree put revCreateXMLTree(tData, false, true, false) into tTree if tTree is not a number then errorShow "Could not parse the glossary file: " & pDoc & " with error: " & tTree exit indexGlossaryLine end if local tName, tCategory put revXMLNodeContents(tTree, "doc/term") into tName put revXMLNodeContents(tTree, "doc/categories/category") into tCategory if item 1 of tName is "xmlerr" then errorShow "Could not extract name from the glossary file : " & pDoc & " with error: " & tName exit indexGlossaryLine end if if item 1 of tCategory is "xmlerr" then errorShow "Could not extract category from the glossary file : " & pDoc & " with error: " & tCategory exit indexGlossaryLine end if local tLine put pIndex & tab & tName & tab & tCategory into tLine return tLine end indexGlossaryLine private function extractPlatformInformation pTree, pMetadata local tPlatforms # Information about the 4 desktop platforms is already contained in each document, # first extract this. //if revXMLAttribute(pTree, "doc/platforms", "mac/") then //put "MacOS," after tPlatforms //end if local tChildNames put revXMLChildNames(pTree,"doc/platforms",return,,false) into tChildNames if "mac" is among the lines of tChildNames then put "Mac OS X," after tPlatforms end if if "windows" is among the lines of tChildNames then put "Windows," after tPlatforms end if if "linux" is among the lines of tChildNames then put "Linux," after tPlatforms end if if "ios" is among the lines of tChildNames then put "iOS," after tPlatforms end if if "android" is among the lines of tChildNames then put "Android," after tPlatforms end if delete the last char of tPlatforms --delete the last char of tPlatforms return tPlatforms end extractPlatformInformation private function extractNodeXML pTree, pName local tXML put revXMLText(pTree, pName, false) into tXML if item 1 of tXML is "xmlerr" then return tXML end if # Chop off the "" at the start as we don't want this and also the "" at the end local tName set the itemDelimiter to slash put item -1 of pName into tName set the itemDelimiter to comma delete char 1 to (the length of tName + 2) of tXML delete char -(the length of tName + 3) to -1 of tXML return tXML end extractNodeXML private function auxFormatSyntax pSyntax local tSyntax, tOffset local tReduced = "false" put pSyntax into tSyntax if the number of lines of tSyntax > 1 then put true into tReduced put line 1 of tSyntax into tSyntax end if if the last char of tSyntax is return then delete the last char of tSyntax put offset("

",tSyntax) into tOffset if tOffset <> 0 then add 4 to tOffset if (tOffset <> 0) and (tOffset < the length of tSyntax) then put char 1 to tOffset - 5 of tSyntax & "

" into tSyntax put true into tReduced end if replace "

" with empty in tSyntax replace "

" with empty in tSyntax replace tab with space in tSyntax if tReduced then put " ..." after tSyntax -- Remove all style tags. This is a workaround for the tabstops bug -- remove this line to allow the original style information for syntax -- to reappear in the dictionary. put replaceText(tSyntax, "(<[/a-zA-Z0-9]+>)", "") into tSyntax return tSyntax end auxFormatSyntax private function escapeEntities pText replace "&" with "&" in pText replace quote with """ in pText replace "<" with "<" in pText replace ">" with ">" in pText return pText end escapeEntities // HSC - tested - complies with current dictionary format private command libDocumentationClumpCreate pNumber, pDir local tClumpName --------- put kClumpNamePrefix & pNumber into tClumpName local tResult create invisible stack tClumpName save it as pDir & slash & tClumpName & ".rev" put the result into tResult if tResult is not empty then errorShow "Failed to save file to disk at location: " & pDir & slash & tClumpName & ".rev" & " with result: " & tResult exit libDocumentationClumpCreate end if return tClumpName end libDocumentationClumpCreate // HSC - tested - complies with current dictionary format private function libDocumentationClumpAddTo pClumpName, pFileIndex, pFileToDirectory, @pOutputDirectory, @pLinkLookup -- adds mapping pFilepath -> pClumpName.N to clump local tKeyNumber, tPropName, tDir, tData local tFilename, tRemainder put pFileIndex mod kFilesPerClump into tRemainder if tRemainder is 0 then put kFilesPerClump into tRemainder end if put tRemainder into tKeyNumber put "c" & tKeyNumber into tPropName put url ("binfile:" & pFileToDirectory[pFileIndex]["path"]) into tData if tData is empty then errorShow "No data for file: " & pFileToDirectory[pFileIndex]["path"] exit libDocumentationClumpAddTo end if // convert the new XML format back to the old type libDocumentationOldFormat tData, pFileToDirectory, pLinkLookup put the compress of tData into tData set the tPropName of stack pClumpName to tData # OK-2007-09-03 : Work around an engine bug to ensure that we don't have any problems # saving to mounted network drives on OS X # save stack pClumpName local tResult if there is a file (the filename of stack pClumpName) then delete file (the filename of stack pClumpName) put the result into tResult if tResult is not empty then errorShow "Failed to delete old stack file: " & tResult exit libDocumentationClumpAddTo end if end if save stack pClumpName put the result into tResult if tResult is not empty then errorShow "Failed to save clump: " & pClumpName & " (" & tResult & ")" exit libDocumentationClumpAddTo end if set the directory to tDir return tKeyNumber end libDocumentationClumpAddTo private function libGetRelatedEntries tData local tResult, tTextStart, tTextEnd, tTextToProcess, tTextLine put libGetTextLocation (tData, "", "", tTextStart, tTextEnd) into tTextToProcess repeat for each line tTextLine in tTextToProcess set the itemdelimiter to slash put item 3 of tTextLine into tTextLine if tTextLine is empty then next repeat end if set the itemdelimiter to ">" put item 0 to 1 of tTextLine into tTextLine put char 0 to -6 of tTextLine into tTextLine if tTextLine is a number then put tTextLine & comma after tResult end if end repeat if tResult is not empty then delete the last char of tResult end if return tResult end libGetRelatedEntries private function libGetSynonyms pTree local tResult put revXMLChildContents(pTree,"doc/synonyms",comma, return,"false", -1) into tResult if char 1 to 6 of tResult is "xmlerr" then put empty into tResult end if return tResult end libGetSynonyms private function libGetTextLocation, pData, pStartToken, pEndToken, @rStart, @rEnd local tTextFound put empty into tTextFound put offset (pStartToken, pData) into rStart put offset (pEndToken, pData) into rEnd if rStart > rEnd then breakpoint end if if rStart is not 0 and rEnd is not 0 then put rEnd + the length of pEndToken - 1 into rEnd put char rStart to rEnd of pData into tTextFound end if return tTextFound end libGetTextLocation function libGetTextText pText local tTextText, tTextStart, tTextEnd put offset (">", pText) into tTextStart if tTextStart is 0 or tTextStart is the length of pText then breakpoint end if put offset(" 0 then // we are using the extened notation set the itemdelimiter to quote put item 2 of pText into tLinkText else // the link is implicit in the name put libGetTextText (pText) into tLinkText end if // test that we can access the element we are looking for if pLinkLookup[pType && tLinkText] is not a number then breakpoint end if // look up and substitute natural name with file name set the itemdelimiter to slash // repeat with tArrayIndex = 1 to the number of elements of pFileToDirectory // if pFileToDirectory[tArrayIndex]["type"] is pType and pFileToDirectory[tArrayIndex]["ref"] is tLinkText then // put item -3 to -1 of pFileToDirectroy[tArrayIndex]["path"] & slash & tArrayIndex & ".xml" into tLinkText // put item -3 to -2 of pFileToDirectory[tArrayIndex]["path"] & slash & tArrayIndex & ".xml" into tLinkText put item -3 to -2 of pFileToDirectory[pLinkLookup[pType && tLinkText]]["path"] & slash & pLinkLookup[pType && tLinkText] & ".xml" into tLinkText //put false into tNotFound // exit repeat // end if //end repeat //if tNotFound is true then // breakpoint // end if return tLinkText end libGetLinkText private command libReplaceLinks @rData, @rFileToDirectory, @rLinkLookup local tOffsetFound, tOffsetSkip, tStartTags, tStartTagsLink, tEndTags, tTag, tTextStart, tTextEnd, tTextToReplace, tReplaceWith, tLinkText, tTextText put ",,,,,,,,," into tStartTags put ",,,,,,,,," into tEndTags put true into tOffsetFound put 0 into tOffsetSkip set the itemdelimiter to comma set the caseSensitive to true repeat with tTag = 1 to the number of items in tStartTags put true into tOffsetFound repeat while tOffsetFound // need to include the tStartTags in another repeat loop this will be for the new files. put libGetTextLocation (rData, item tTag of tStartTagsLink, item tTag of tEndTags, tTextStart, tTextEnd) into tTextToReplace if tTextStart is 0 and tTextEnd is 0 then put false into tOffsetFound else // generate the text that is to be inserted put "--text--" into tReplaceWith put libGetLinkText (tTextToReplace, char 2 to -2 of item tTag of tStartTags, rFileToDirectory, rLinkLookup) into tLinkText put libGetTextText (tTextToReplace) into tTextText // replace the text here replace "--link--" with tLinkText in tReplaceWith replace "--text--" with tTextText in tReplaceWith replace tTextToReplace with tReplaceWith in rData end if end repeat end repeat end libReplaceLinks private command libUpdateSyntaxExamples @rData // updates the notation local tTextToReplace, tReplaceWith, tTextStart, tTextEnd put libGetTextLocation (rData, "", "", tTextStart, tTextEnd) into tTextToReplace if tTextToReplace is empty then breakpoint else put tTextToReplace into tReplaceWith replace "" with "

" in tReplaceWith replace "" with "

" in tReplaceWith replace "

" with "

" in tReplaceWith replace "

" with "

" in tReplaceWith replace tTextToReplace with tReplaceWith in rData end if end libUpdateSyntaxExamples private command libUpdateObjects @rData // updates the ... notation local tTextToReplace, tReplaceWith, tTextStart, tTextEnd put libGetTextLocation (rData, "", "", tTextStart, tTextEnd) into tTextToReplace if tTextToReplace is empty then breakpoint else put "--text--" into tReplaceWith if offset ("", tTextToReplace) > 0 then replace "--text--" with "card,--text--" in tReplaceWith end if if offset ("", tTextToReplace) > 0 then replace "--text--" with "stack,--text--" in tReplaceWith end if if offset ("", tTextToReplace) > 0 then replace "--text--" with "group,--text--" in tReplaceWith end if if offset ("", tTextToReplace) > 0 then replace "--text--" with "field,--text--" in tReplaceWith end if if offset ("