File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,12 @@ pub struct Outline {
33
33
children : Vec < OutlineNode > ,
34
34
}
35
35
36
+ impl Outline {
37
+ pub ( crate ) fn is_empty ( & self ) -> bool {
38
+ self . children . is_empty ( )
39
+ }
40
+ }
41
+
36
42
impl Default for Outline {
37
43
fn default ( ) -> Self {
38
44
Self :: new ( )
Original file line number Diff line number Diff line change @@ -247,7 +247,16 @@ impl SerializeContext {
247
247
}
248
248
249
249
pub ( crate ) fn set_outline ( & mut self , outline : Outline ) {
250
- self . global_objects . outline = MaybeTaken :: new ( Some ( outline) ) ;
250
+ // Only set it if it's not empty or if the current validator requires an
251
+ // outline.
252
+ if !outline. is_empty ( )
253
+ || self
254
+ . serialize_settings
255
+ . validator
256
+ . prohibits ( & ValidationError :: MissingDocumentOutline )
257
+ {
258
+ self . global_objects . outline = MaybeTaken :: new ( Some ( outline) ) ;
259
+ }
251
260
}
252
261
253
262
pub ( crate ) fn set_metadata ( & mut self , metadata : Metadata ) {
You can’t perform that action at this time.
0 commit comments