Skip to content

Commit 26a84e5

Browse files
committed
Update commit hashes and add function replacement patterns for optional parameters
1 parent a72d0bb commit 26a84e5

4 files changed

Lines changed: 77 additions & 3 deletions

File tree

WoW-API/COMMIT_HASHES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ This API documentation was generated using the following commit hashes:
55
- **vscode-wow-api**: `master` @ `a2e82582ac3f38c096ecc192fe701c3ba901d95d`
66
- **WoWUI**: `vanilla` @ `b6262ddd722e41b0757e7c6ae2e2a83563044152`
77

8-
Generated on: 2025-12-10 15:12:04
8+
Generated on: 2025-12-10 16:04:56

WoW-API/_UI/Blizzard_DeprecatedSpellBook/Deprecated_SpellBook.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ do
2424
---@deprecated
2525
---Deprecated by [C_SpellBook.IsSpellInSpellBook](https://warcraft.wiki.gg/wiki/API_C_SpellBook.IsSpellInSpellBook)
2626
---@param spellID number
27-
---@param isPet boolean
27+
---@param isPet boolean?
2828
---@return boolean isInSpellBook
2929
function IsSpellKnown(spellID, isPet)
3030
local spellBank = isPet and Enum.SpellBookSpellBank.Pet or Enum.SpellBookSpellBank.Player;
@@ -35,7 +35,7 @@ do
3535
---@deprecated
3636
---Deprecated by [C_SpellBook.IsSpellInSpellBook](https://warcraft.wiki.gg/wiki/API_C_SpellBook.IsSpellInSpellBook)
3737
---@param spellID number
38-
---@param isPet boolean
38+
---@param isPet boolean?
3939
---@return boolean isInSpellBook
4040
function IsSpellKnownOrOverridesKnown(spellID, isPet)
4141
local spellBank = isPet and Enum.SpellBookSpellBank.Pet or Enum.SpellBookSpellBank.Player;

generator/inject_annotations.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import re
44
import argparse
55
from inject_mixin_skip import MIXIN_SKIP_PATTERNS, FUNCTION_SKIP_PATTERNS
6+
from inject_replace import MIXIN_REPLACEMENT_PATTERNS, FUNCTION_REPLACEMENT_PATTERNS
67

78

89
def parse_annotations(source_dir):
@@ -176,6 +177,31 @@ def inject_mixins(target_dir, mixins_map, dry_run=False):
176177
already_present = True
177178

178179
if not already_present and anno_lines:
180+
# --- Apply Regex Replacements (Mixins) ---
181+
replacement_rules = MIXIN_REPLACEMENT_PATTERNS.get(
182+
mixin_name, []
183+
)
184+
if replacement_rules:
185+
temp_lines = []
186+
for al_line in anno_lines:
187+
replaced = False
188+
for pattern, replacement in replacement_rules:
189+
if re.match(pattern, al_line):
190+
new_line = re.sub(
191+
pattern, replacement, al_line
192+
)
193+
if al_line.endswith(
194+
"\n"
195+
) and not new_line.endswith("\n"):
196+
new_line += "\n"
197+
temp_lines.append(new_line)
198+
replaced = True
199+
break
200+
if not replaced:
201+
temp_lines.append(al_line)
202+
anno_lines = temp_lines
203+
# -----------------------------------------
204+
179205
if dry_run:
180206
print(
181207
f"[Dry Run] Injecting mixin docs for: {mixin_name} in {path} (from {source_file})"
@@ -427,6 +453,32 @@ def inject_annotations(target_dir, annotations_map, dry_run=False):
427453
# Inject annotations
428454
# We prepend the indentation found on the function line
429455

456+
# --- Apply Regex Replacements (Functions) ---
457+
replacement_rules = FUNCTION_REPLACEMENT_PATTERNS.get(
458+
func_name, []
459+
)
460+
if replacement_rules:
461+
temp_lines = []
462+
for al_line in anno_lines:
463+
replaced = False
464+
for pattern, replacement in replacement_rules:
465+
if re.match(pattern, al_line):
466+
new_line = re.sub(
467+
pattern, replacement, al_line
468+
)
469+
# Ensure newline if lost
470+
if al_line.endswith(
471+
"\n"
472+
) and not new_line.endswith("\n"):
473+
new_line += "\n"
474+
temp_lines.append(new_line)
475+
replaced = True
476+
break
477+
if not replaced:
478+
temp_lines.append(al_line)
479+
anno_lines = temp_lines
480+
# --------------------------------------------
481+
430482
# Get skip patterns for this function
431483
skip_patterns = [
432484
re.compile(p)

generator/inject_replace.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Configuration for replacing matched annotation lines when injecting
2+
# Key: Function Name or Mixin Name
3+
# Value: List of (regex_pattern, replacement_string) tuples
4+
FUNCTION_REPLACEMENT_PATTERNS = {
5+
# Spellbook functions with isPet parameter should have it as optional
6+
"IsSpellKnownOrOverridesKnown": [
7+
(r".*param\s*isPet\s*boolean", "---@param isPet boolean?"),
8+
],
9+
"IsSpellKnown": [
10+
(r".*param\s*isPet\s*boolean", "---@param isPet boolean?"),
11+
],
12+
}
13+
14+
15+
# Configuration for replacing matched annotation lines when injecting
16+
# Key: Mixin Name or Mixin Name
17+
# Value: List of (regex_pattern, replacement_string) tuples
18+
MIXIN_REPLACEMENT_PATTERNS = {
19+
# "PlayerLocationMixin": [
20+
# (r".*field\s*IsGUID", "---@field IsGUID boolean?"),
21+
# ],
22+
}

0 commit comments

Comments
 (0)