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
47
47
all
48
48
```
49
49
50
- ` all ` and empty string mean generally available for all active versions
50
+ ` all ` means generally available for all active versions
51
51
52
52
``` yaml
53
53
applies_to :
54
54
serverless : all
55
55
` ` `
56
56
57
- ` all` and empty string can also be specified at a version level
57
+ ` all` can also be specified at a version level
58
58
59
59
` ` ` yaml
60
60
applies_to:
61
61
stack: beta all
62
62
serverless: beta
63
63
` ` `
64
64
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 .
66
66
67
67
68
68
# # Structured model
Original file line number Diff line number Diff line change @@ -122,10 +122,17 @@ public class ApplicableToConverter : IYamlTypeConverter
122
122
123
123
public object ? ReadYaml ( IParser parser , Type type , ObjectDeserializer rootDeserializer )
124
124
{
125
+ var warnings = new List < string > ( ) ;
126
+ var applicableTo = new ApplicableTo ( ) ;
127
+
125
128
if ( parser . TryConsume < Scalar > ( out var value ) )
126
129
{
127
130
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
+
129
136
if ( string . Equals ( value . Value , "all" , StringComparison . InvariantCultureIgnoreCase ) )
130
137
return ApplicableTo . All ;
131
138
}
@@ -134,10 +141,6 @@ public class ApplicableToConverter : IYamlTypeConverter
134
141
if ( deserialized is not Dictionary < object , object ? > { Count : > 0 } dictionary )
135
142
return null ;
136
143
137
-
138
- var applicableTo = new ApplicableTo ( ) ;
139
- var warnings = new List < string > ( ) ;
140
-
141
144
var keys = dictionary . Keys . OfType < string > ( ) . ToArray ( ) ;
142
145
var oldStyleKeys = keys . Where ( k => k . StartsWith ( ':' ) ) . ToList ( ) ;
143
146
if ( oldStyleKeys . Count > 0 )
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ applies_to:
23
23
"""
24
24
[<Fact>]
25
25
let ``apply matches expected`` () =
26
- markdown |> appliesTo ApplicableTo.All
26
+ markdown |> appliesTo ( Unchecked.defaultof < ApplicableTo >)
27
27
28
28
type ``apply default to top level arguments`` () =
29
29
static let markdown = frontMatter """
@@ -186,3 +186,11 @@ applies_to:
186
186
Stack= AppliesCollection.op_ Explicit " ga 9.1.0" ,
187
187
Product= AppliesCollection.op_ Explicit " coming 9.5, discontinued 9.7"
188
188
))
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