Skip to content

Commit c449100

Browse files
Fix unnecessary bullet points for single extensions in HTML docs (#936)
## Summary Fixes issue #927 where single extension definitions were showing unnecessary bullet points in the HTML documentation's "Defining Extension" section. ## Problem - Single extensions like `definedBy: Sm` were displaying as `• Sm, version >= 1.11.0` with unwanted bullet points - This made the documentation look cluttered for simple cases where only one extension is involved - Multiple extensions correctly needed bullets, but single ones should appear clean ## Solution - Modified `to_asciidoc` method in `req_expression.rb` to detect simple single extensions at root level - Added `is_simple_single_extension?()` helper to identify when bullets aren't needed - Added `to_asciidoc_no_bullet()` method for clean formatting of single extensions - Preserved existing bullet behavior for complex multi-extension conditions (allOf, anyOf, etc.) ## Testing - Single extensions now display cleanly: `Sm, version >= 1.11.0` - Multiple extensions maintain proper structure with bullets - No regression in complex extension requirement formatting ## Impact - Improves readability of HTML documentation for CSRs with single defining extensions - Maintains backward compatibility for all existing complex extension definitions Ready for Review @ThinkOpenly @dhower-qc Fixes #927 --------- Signed-off-by: Sukuna0007Abhi <[email protected]> Signed-off-by: GitHub <[email protected]>
1 parent 345c07e commit c449100

File tree

2 files changed

+75
-49
lines changed

2 files changed

+75
-49
lines changed

backends/instructions_appendix/all_instructions.golden.adoc

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3812,11 +3812,11 @@ Decode Variables::
38123812
|===
38133813

38143814
Included in::
3815-
* anyOf:
3816-
*** allOf:
3817-
***** C, version >= [email protected]
3818-
***** D, version >= [email protected]
3819-
*** Zcd, version >= [email protected]
3815+
anyOf:
3816+
* allOf:
3817+
** C, version >= [email protected]
3818+
** D, version >= [email protected]
3819+
* Zcd, version >= [email protected]
38203820

38213821

38223822
[#udb:doc:inst:c_fldsp]
@@ -3850,11 +3850,11 @@ Decode Variables::
38503850
|===
38513851

38523852
Included in::
3853-
* anyOf:
3854-
*** allOf:
3855-
***** C, version >= [email protected]
3856-
***** D, version >= [email protected]
3857-
*** Zcd, version >= [email protected]
3853+
anyOf:
3854+
* allOf:
3855+
** C, version >= [email protected]
3856+
** D, version >= [email protected]
3857+
* Zcd, version >= [email protected]
38583858

38593859

38603860
[#udb:doc:inst:c_flw]
@@ -3889,11 +3889,11 @@ Decode Variables::
38893889
|===
38903890

38913891
Included in::
3892-
* anyOf:
3893-
*** allOf:
3894-
***** C, version >= [email protected]
3895-
***** F, version >= [email protected]
3896-
*** Zcf, version >= [email protected]
3892+
anyOf:
3893+
* allOf:
3894+
** C, version >= [email protected]
3895+
** F, version >= [email protected]
3896+
* Zcf, version >= [email protected]
38973897

38983898

38993899
[#udb:doc:inst:c_flwsp]
@@ -3927,11 +3927,11 @@ Decode Variables::
39273927
|===
39283928

39293929
Included in::
3930-
* anyOf:
3931-
*** allOf:
3932-
***** C, version >= [email protected]
3933-
***** F, version >= [email protected]
3934-
*** Zcf, version >= [email protected]
3930+
anyOf:
3931+
* allOf:
3932+
** C, version >= [email protected]
3933+
** F, version >= [email protected]
3934+
* Zcf, version >= [email protected]
39353935

39363936

39373937
[#udb:doc:inst:c_fsd]
@@ -3966,11 +3966,11 @@ Decode Variables::
39663966
|===
39673967

39683968
Included in::
3969-
* anyOf:
3970-
*** allOf:
3971-
***** C, version >= [email protected]
3972-
***** D, version >= [email protected]
3973-
*** Zcd, version >= [email protected]
3969+
anyOf:
3970+
* allOf:
3971+
** C, version >= [email protected]
3972+
** D, version >= [email protected]
3973+
* Zcd, version >= [email protected]
39743974

39753975

39763976
[#udb:doc:inst:c_fsdsp]
@@ -4004,11 +4004,11 @@ Decode Variables::
40044004
|===
40054005

40064006
Included in::
4007-
* anyOf:
4008-
*** allOf:
4009-
***** C, version >= [email protected]
4010-
***** D, version >= [email protected]
4011-
*** Zcd, version >= [email protected]
4007+
anyOf:
4008+
* allOf:
4009+
** C, version >= [email protected]
4010+
** D, version >= [email protected]
4011+
* Zcd, version >= [email protected]
40124012

40134013

40144014
[#udb:doc:inst:c_fsw]
@@ -4043,11 +4043,11 @@ Decode Variables::
40434043
|===
40444044

40454045
Included in::
4046-
* anyOf:
4047-
*** allOf:
4048-
***** C, version >= [email protected]
4049-
***** F, version >= [email protected]
4050-
*** Zcf, version >= [email protected]
4046+
anyOf:
4047+
* allOf:
4048+
** C, version >= [email protected]
4049+
** F, version >= [email protected]
4050+
* Zcf, version >= [email protected]
40514051

40524052

40534053
[#udb:doc:inst:c_fswsp]
@@ -4081,11 +4081,11 @@ Decode Variables::
40814081
|===
40824082

40834083
Included in::
4084-
* anyOf:
4085-
*** allOf:
4086-
***** C, version >= [email protected]
4087-
***** F, version >= [email protected]
4088-
*** Zcf, version >= [email protected]
4084+
anyOf:
4085+
* allOf:
4086+
** C, version >= [email protected]
4087+
** F, version >= [email protected]
4088+
* Zcf, version >= [email protected]
40894089

40904090

40914091
[#udb:doc:inst:c_j]
@@ -46326,10 +46326,10 @@ Decode Variables::
4632646326
|===
4632746327

4632846328
Included in::
46329-
* allOf:
46330-
*** Zbb, version >= [email protected]
46331-
*** not:
46332-
***** Zbkb, version >= [email protected]
46329+
allOf:
46330+
* Zbb, version >= [email protected]
46331+
* not:
46332+
** Zbkb, version >= [email protected]
4633346333

4633446334

4633546335
[#udb:doc:inst:zip]

tools/ruby-gems/udb/lib/udb/req_expression.rb

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,23 +151,49 @@ def flat_versions
151151
end
152152
end
153153

154+
sig { params(cond: T.any(String, T::Hash[String, T.untyped], T::Array[T.untyped])).returns(T::Boolean) }
155+
def is_simple_single_extension?(cond)
156+
case cond
157+
when String
158+
true
159+
when Hash
160+
# Single extension with name and optional version
161+
cond.key?("name") && cond.size <= 2 && (cond.size == 1 || cond.key?("version"))
162+
else
163+
false
164+
end
165+
end
166+
167+
sig { params(cond: T.any(String, T::Hash[String, T.untyped], T::Array[T.untyped])).returns(T::Boolean) }
168+
def is_complex_condition_header?(cond)
169+
# Check if this is a complex condition header (allOf, anyOf, oneOf, etc.)
170+
cond.is_a?(Hash) && !cond.key?("name")
171+
end
172+
154173
sig { params(cond: T.any(String, T::Hash[String, T.untyped], T::Array[T.untyped]), indent: Integer, join: String).returns(String) }
155174
def to_asciidoc(cond = @hsh, indent = 0, join: "\n")
175+
# For simple single extension OR complex condition headers at root level (indent = 0), don't show bullets
176+
use_bullets = !(indent == 0 && (is_simple_single_extension?(cond) || is_complex_condition_header?(cond)))
177+
bullet_prefix = use_bullets ? "#{'*' * indent} " : ""
178+
156179
case cond
157180
when String
158-
"#{'*' * indent}* #{cond}, version >= #{T.must(@arch.extension(cond)).min_version}"
181+
"#{bullet_prefix}#{cond}, version >= #{T.must(@arch.extension(cond)).min_version}"
159182
when Hash
160183
if cond.key?("name")
161184
if cond.key?("version")
162-
"#{'*' * indent}* #{cond['name']}, version #{cond['version']}#{join}"
185+
"#{bullet_prefix}#{cond['name']}, version #{cond['version']}#{join}"
163186
else
164-
"#{'*' * indent}* #{cond['name']}, version >= #{T.must(@arch.extension(cond['name'])).min_version}#{join}"
187+
"#{bullet_prefix}#{cond['name']}, version >= #{T.must(@arch.extension(cond['name'])).min_version}#{join}"
165188
end
166189
else
167-
"#{'*' * indent}* #{cond.keys[0]}:#{join}" + to_asciidoc(cond[T.must(cond.keys[0])], indent + 2)
190+
"#{bullet_prefix}#{cond.keys[0]}:#{join}" + to_asciidoc(cond[T.must(cond.keys[0])], indent + 1)
168191
end
169192
when Array
170-
cond.map { |e| to_asciidoc(e, indent) }.join(join)
193+
# Arrays represent multiple items, so they need bullets for clarity
194+
# Use indent=1 at root level to ensure bullets are shown
195+
array_indent = indent == 0 ? 1 : indent
196+
cond.map { |e| to_asciidoc(e, array_indent) }.join(join)
171197
else
172198
T.absurd(cond)
173199
end

0 commit comments

Comments
 (0)