File tree Expand file tree Collapse file tree 3 files changed +20
-9
lines changed
src/Elastic.Markdown/Myst/FrontMatter
tests/authoring/Applicability Expand file tree Collapse file tree 3 files changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -47,22 +47,22 @@ discontinued 9.2.0
4747all
4848```
4949
50- ` all ` and empty string mean generally available for all active versions
50+ ` all ` means generally available for all active versions
5151
5252``` yaml
5353applies_to :
5454 serverless : all
5555` ` `
5656
57- ` all` and empty string can also be specified at a version level
57+ ` all` can also be specified at a version level
5858
5959` ` ` yaml
6060applies_to:
6161 stack: beta all
6262 serverless: beta
6363` ` `
6464
65- Both are equivalent, note `all` just means we won't be rendering the version portion in the html .
65+ Note `all` just means we won't be rendering the version portion in the HTML .
6666
6767
6868# # Structured model
Original file line number Diff line number Diff line change @@ -122,10 +122,17 @@ public class ApplicableToConverter : IYamlTypeConverter
122122
123123 public object ? ReadYaml ( IParser parser , Type type , ObjectDeserializer rootDeserializer )
124124 {
125+ var warnings = new List < string > ( ) ;
126+ var applicableTo = new ApplicableTo ( ) ;
127+
125128 if ( parser . TryConsume < Scalar > ( out var value ) )
126129 {
127130 if ( string . IsNullOrWhiteSpace ( value . Value ) )
128- return ApplicableTo . All ;
131+ {
132+ warnings . Add ( "The 'applies_to' field is present but empty. No applicability will be assumed." ) ;
133+ return null ;
134+ }
135+
129136 if ( string . Equals ( value . Value , "all" , StringComparison . InvariantCultureIgnoreCase ) )
130137 return ApplicableTo . All ;
131138 }
@@ -134,10 +141,6 @@ public class ApplicableToConverter : IYamlTypeConverter
134141 if ( deserialized is not Dictionary < object , object ? > { Count : > 0 } dictionary )
135142 return null ;
136143
137-
138- var applicableTo = new ApplicableTo ( ) ;
139- var warnings = new List < string > ( ) ;
140-
141144 var keys = dictionary . Keys . OfType < string > ( ) . ToArray ( ) ;
142145 var oldStyleKeys = keys . Where ( k => k . StartsWith ( ':' ) ) . ToList ( ) ;
143146 if ( oldStyleKeys . Count > 0 )
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ applies_to:
2323"""
2424 [<Fact>]
2525 let ``apply matches expected`` () =
26- markdown |> appliesTo ApplicableTo.All
26+ markdown |> appliesTo ( Unchecked.defaultof < ApplicableTo >)
2727
2828type ``apply default to top level arguments`` () =
2929 static let markdown = frontMatter """
@@ -186,3 +186,11 @@ applies_to:
186186 Stack= AppliesCollection.op_ Explicit " ga 9.1.0" ,
187187 Product= AppliesCollection.op_ Explicit " coming 9.5, discontinued 9.7"
188188 ))
189+
190+ type ``parses empty applies_to as null`` () =
191+ static let markdown = frontMatter """
192+ applies_to:
193+ """
194+ [<Fact>]
195+ let ``does not render label`` () =
196+ markdown |> appliesTo ( Unchecked.defaultof< ApplicableTo>)
You can’t perform that action at this time.
0 commit comments