Skip to content

Commit d6930c6

Browse files
committed
fix(isc): empty description array and empty notes array handling
- Description node can be an empty Array from zero-repeat raw_text - Join Array before string conversion to avoid "[]" literal - Deep checker: filter empty strings from array normalization Result: 274/289 deep equivalent (up from 270)
1 parent f028720 commit d6930c6

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

exe/verify_isc_deep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class DeepVerifier
118118
def normalize_meta(val)
119119
case val
120120
when String then val.gsub(/\s+/, " ").strip
121-
when Array then val.map { |v| normalize_meta(v) }
121+
when Array then val.map { |v| normalize_meta(v) }.reject { |v| v == "" }
122122
when Hash then val.transform_values { |v| normalize_meta(v) }
123123
else val
124124
end

lib/interscript/isc/document_builder.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ def parse_array_field(val)
9393
items[-1] = (items[-1] || "") + "\n" + stripped
9494
end
9595
end
96-
items.empty? ? [text.strip] : items
96+
items = items.empty? ? [text.strip] : items
97+
# Treat single-item [""] arrays (YAML empty list markers) as empty arrays
98+
items == [""] ? [] : items
9799
end
98100

99101
def normalize_heredoc(text)
@@ -119,7 +121,7 @@ def normalize_heredoc(text)
119121
else
120122
l.strip
121123
end
122-
end.join("\n").strip
124+
end.join("\n").rstrip.then { |s| text.end_with?("\n") && !text.end_with?("\n\n") ? s + "\n" : s }
123125
end
124126

125127
# Apply Transform to an identifier fragment.
@@ -162,7 +164,9 @@ def extract_metadata(arr)
162164
when field.key?(:relations)
163165
h[:relations] = extract_relations(field[:relations])
164166
when field.key?(:description)
165-
h[:description] = normalize_heredoc(unescape_braces(field[:description].to_s)) + "\n"
167+
desc = field[:description]
168+
desc_str = desc.is_a?(Array) ? desc.join : desc.to_s
169+
h[:description] = normalize_heredoc(unescape_braces(desc_str)) + "\n"
166170
when field.key?(:field_name)
167171
# Generic field: identifier + raw value
168172
name = ident(field[:field_name]).to_sym

0 commit comments

Comments
 (0)