### Usage Example Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/api-documentation-framework.md Example of retrieving and displaying function documentation. ```lua -- Retrieve documentation for a function local funcInfo = APIDocumentationDB:GetFunctionByName("GetPlayerName") if funcInfo then print(funcInfo:GetFullName()) -- Output: GetPlayerName() print(funcInfo:GetType()) -- Output: function print(funcInfo:GenerateAPILink()) -- Output: |cff55ddff|Hapi:function:...|h...|h|r -- Get detailed information local detailedLines = funcInfo:GetDetailedOutputLines() for i, line in ipairs(detailedLines) do print(line) end end ``` -------------------------------- ### Event-Driven Architecture Example Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/README.md Illustrates how UI updates are triggered by game events, showing event registration and handler setup. ```lua frame:RegisterEvent("PLAYER_LOGIN") frame:SetScript("OnEvent", handler) ``` -------------------------------- ### HelpTip Example Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/chat-frame-system.md Example of creating a help tip with specified properties. ```lua HelpTip { text = "Your tutorial text here", buttonStyle = HelpTip.ButtonStyle.Close, cvarBitfield = "closedInfoFrames", bitfieldFlag = Enum.FrameTutorial.ChatExample, } ``` -------------------------------- ### ApplyGridLayout Example Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/grid-layout-utilities.md Example of applying a standard grid layout to a list of buttons with a specified starting anchor. ```lua local buttons = { button1, button2, button3, ... } local layout = GridLayoutUtil.CreateStandardGridLayout(4, 2, 2, 1, 1) local startAnchor = AnchorUtil.CreateAnchor("TOPLEFT", parentFrame, "TOPLEFT", 0, 0) GridLayoutUtil.ApplyGridLayout(buttons, startAnchor, layout) ``` -------------------------------- ### Conditional Loading Example Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/project-overview.md Example TOC statements demonstrating conditional loading of AddOns. ```toc ## LoadWith: Blizzard_APIDocumentationGenerated ## LoadOnDemand: 1 ``` -------------------------------- ### CreateStandardGridLayout Example Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/grid-layout-utilities.md Example of creating a standard grid layout. ```lua local layout = GridLayoutUtil.CreateStandardGridLayout( 8, -- stride: 8 items per row 2, -- xPadding: 2 pixels horizontal spacing 2, -- yPadding: 2 pixels vertical spacing 1, -- xMultiplier: 1 = grow right, -1 = grow left 1 -- yMultiplier: 1 = grow down, -1 = grow up ) ``` -------------------------------- ### Usage Example Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/api-documentation-framework.md Example of how to retrieve and display information about a function, including its arguments, return values, and a Lua snippet for the clipboard. ```lua -- Get function documentation with arguments and returns local funcInfo = APIDocumentationDB:GetFunctionByName("GetDamageInfo") if funcInfo then -- Get formatted argument list local args = funcInfo:GetArgumentString() print("Arguments: " .. args) -- Get formatted return list local rets = funcInfo:GetReturnString() print("Returns: " .. rets) -- Get code snippet for clipboard local snippet = funcInfo:GetClipboardString() print("Lua snippet: " .. snippet) end ``` -------------------------------- ### ActionButtonUtil Example Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/core-patterns-and-architecture.md Example of the ActionButtonUtil module, showing enumerations and static functions. ```lua ActionButtonUtil = {} -- Enumerations ActionButtonUtil.ActionBarActionStatus = { NotMissing = 1, MissingFromAllBars = 2, -- ... } -- Static functions function ActionButtonUtil.GetPageForSlot(slot) return math.floor((slot - 1) / NUM_ACTIONBAR_BUTTONS) + 1 end ``` -------------------------------- ### CreateVerticalGridLayout Example Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/grid-layout-utilities.md Example of creating a vertical grid layout. ```lua local layout = GridLayoutUtil.CreateVerticalGridLayout( 3, -- stride: 3 items per column 2, -- xPadding: horizontal spacing 2, -- yPadding: vertical spacing 1, -- xMultiplier: 1 = grow right 1 -- yMultiplier: 1 = grow up ) ``` -------------------------------- ### CVar Integration Example Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/project-overview.md Examples of game configuration variables (CVars) that persist across sessions. ```lua buffDurations -- Show buff durations consolidateBuffs -- Merge similar buffs collapseExpandBuffs -- Allow buff collapse countdownForCooldowns -- Show cooldown numbers ``` -------------------------------- ### Example Flow for Cooldown Update Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/project-overview.md Illustrates the sequence of events from a player casting a spell to the cooldown animation starting. ```mermaid graph TD A[Player casts spell] B[Game raises SPELL_UPDATE_COOLDOWN event] C[ActionButton:OnEvent() handler called] D[Button:UpdateCooldown() executed] E[Cooldown animation starts] A --> B --> C --> D --> E ``` -------------------------------- ### File Organization Example Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/project-overview.md Illustrates the directory structure for AddOns, including shared utilities and base templates. ```treeview Interface/ ├── AddOns/ (316 AddOns) │ ├── Blizzard_ActionBar/ │ ├── Blizzard_BuffFrame/ │ ├── Blizzard_ChatFrame/ │ ├── Blizzard_APIDocumentation/ │ ├── Blizzard_SharedXML/ (Shared utilities) │ ├── Blizzard_FrameXML/ (Base templates) │ └── [200+ more AddOns] ├── ui-code-list.txt (All Lua files) ├── ui-toc-list.txt (All TOC files) └── ui-gen-addon-list.txt (Generated addon list) ``` -------------------------------- ### Get Warning Alpha for Aura Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/buff-frame-system.md Example of calculating the appropriate alpha for an aura icon based on its remaining duration for warning animations. ```Lua -- In aura icon update function local remainingDuration = aura.expirationTime - GetTime() local displayAlpha = auraContainer:GetAuraWarningAlphaForDuration(remainingDuration) auraIcon:SetAlpha(displayAlpha) ``` -------------------------------- ### Grid Layout System Example Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/README.md Shows how to use the flexible layout engine for UI elements, including creating a standard grid layout and applying it to buttons. ```lua local layout = GridLayoutUtil.CreateStandardGridLayout(12, 2, 2, 1, 1) GridLayoutUtil.ApplyGridLayout(buttons, anchor, layout) ``` -------------------------------- ### CreateVerticalGridLayout Usage Example Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/grid-layout-utilities.md Usage example for CreateVerticalGridLayout. ```lua -- Create 4-column layout for buff icons local layout = GridLayoutUtil.CreateVerticalGridLayout(4, 2, 2, 1, -1) ``` -------------------------------- ### CreateStandardGridLayout Usage Examples Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/grid-layout-utilities.md Usage examples for CreateStandardGridLayout. ```lua -- Create 12-wide horizontal layout, growing right and down, with 2px spacing local layout = GridLayoutUtil.CreateStandardGridLayout(12, 2, 2, 1, 1, false) -- Create 6-wide vertical layout, growing left and up local layout = GridLayoutUtil.CreateStandardGridLayout(6, 2, 2, -1, -1, true) ``` -------------------------------- ### Callback Registry Pattern Example Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/project-overview.md Demonstrates the registration and triggering of events using a callback registry. ```lua registry:Register("Event", callback) registry:TriggerEvent("Event", ...) ``` -------------------------------- ### CreateNaturalGridLayout Example Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/grid-layout-utilities.md Example of creating a natural grid layout. ```lua local layout = GridLayoutUtil.CreateNaturalGridLayout( 12, -- stride: 12 items per row 4, -- xPadding: extra horizontal spacing 4, -- yPadding: extra vertical spacing 1, -- xMultiplier: grow right 1 -- yMultiplier: grow down ) ``` -------------------------------- ### API Documentation Framework Example Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/README.md Demonstrates how to use the introspectable system for API queries, retrieving function information by name. ```lua local funcInfo = APIDocumentationDB:GetFunctionByName("GetPlayerName") print(funcInfo:GetFullName()) ``` -------------------------------- ### Accessing System Information Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/api-documentation-framework.md Example of how to retrieve system information by name and access its properties, including listing all functions within that system. ```lua local systemInfo = APIDocumentationDB:GetSystemByName("Player") if systemInfo then print(systemInfo:GetName()) -- "Player" print(systemInfo:GetFullName()) -- "Player" -- List all functions in this system if systemInfo.Functions then for i, func in ipairs(systemInfo.Functions) do print(func:GetFullName()) end end end ``` -------------------------------- ### Source Code Reference Example Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/README.md An example of how source file paths and line numbers are provided for direct code lookup. ```text Source: Interface/AddOns/Blizzard_ActionBar/Shared/ActionBar.lua:93 ``` -------------------------------- ### Cached State Example Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/core-patterns-and-architecture.md Example of caching grid settings to detect changes and optimize updates. ```lua -- Cache grid settings to detect changes function ActionBarMixin:CacheGridSettings() self.oldGridSettings = { numRows = self.numRows, isHorizontal = self.isHorizontal, -- ... more properties } end -- Check if update needed function ActionBarMixin:ShouldUpdateGrid() if not self.oldGridSettings then return true end return self.oldGridSettings.numRows ~= self.numRows end ``` -------------------------------- ### Integration with AnchorUtil Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/grid-layout-utilities.md Demonstrates how to create an anchor point using AnchorUtil and then apply a grid layout from that point. ```lua -- Create anchor at specific point local anchor = AnchorUtil.CreateAnchor("TOPLEFT", parentFrame, "TOPLEFT", xOffset, yOffset) -- Apply layout from that anchor point GridLayoutUtil.ApplyGridLayout(frames, anchor, layout) ``` -------------------------------- ### ToggleChatMessageGroup API Example Source: https://github.com/gethe/wow-ui-source/blob/live/_autodocs/chat-frame-system.md Example showing how to disable whisper messages. ```lua ToggleChatMessageGroup(false, "WHISPER") -- Disable whisper messages ```