From 76511a7a71660b564040bfadb466251fbfa0167b Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Wed, 20 Jan 2021 15:58:03 -0500 Subject: [PATCH 1/3] Make 'docs' optional --- src/librustdoc/json/conversions.rs | 2 +- src/librustdoc/json/types.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 7d05cb016b67c..d8f1f51579624 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -27,7 +27,7 @@ impl JsonRenderer<'_> { name: name.map(|sym| sym.to_string()), source: self.convert_span(source), visibility: self.convert_visibility(visibility), - docs: attrs.collapsed_doc_value().unwrap_or_default(), + docs: attrs.collapsed_doc_value(), links: attrs .links .into_iter() diff --git a/src/librustdoc/json/types.rs b/src/librustdoc/json/types.rs index 9335fe9be1a4b..2f6db0231ab49 100644 --- a/src/librustdoc/json/types.rs +++ b/src/librustdoc/json/types.rs @@ -69,7 +69,7 @@ pub struct Item { /// so this field is needed to differentiate. pub visibility: Visibility, /// The full markdown docstring of this item. - pub docs: String, + pub docs: Option, /// This mapping resolves [intra-doc links](https://github.com/rust-lang/rfcs/blob/master/text/1946-intra-rustdoc-links.md) from the docstring to their IDs pub links: FxHashMap, /// Stringified versions of the attributes on this item (e.g. `"#[inline]"`) From 811fa59db0210c8c5eeb86e47d858c88e3460d07 Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Wed, 20 Jan 2021 17:52:52 -0500 Subject: [PATCH 2/3] Add explanation of None vs Some("") --- src/librustdoc/json/types.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/json/types.rs b/src/librustdoc/json/types.rs index 2f6db0231ab49..c148602009f9a 100644 --- a/src/librustdoc/json/types.rs +++ b/src/librustdoc/json/types.rs @@ -68,7 +68,8 @@ pub struct Item { /// By default all documented items are public, but you can tell rustdoc to output private items /// so this field is needed to differentiate. pub visibility: Visibility, - /// The full markdown docstring of this item. + /// The full markdown docstring of this item. Absent if there is no documentation at all, + /// Some("") if there is some documentation but it is empty (EG `#[doc = ""]`). pub docs: Option, /// This mapping resolves [intra-doc links](https://github.com/rust-lang/rfcs/blob/master/text/1946-intra-rustdoc-links.md) from the docstring to their IDs pub links: FxHashMap, From 26565f05c045c15d4304e73639efcaf5b3100842 Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Thu, 21 Jan 2021 21:18:31 -0500 Subject: [PATCH 3/3] Bump format version --- src/librustdoc/json/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index df7ab9b7361a0..e96ceb32f2e96 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -236,7 +236,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { ) }) .collect(), - format_version: 1, + format_version: 2, }; let mut p = self.out_path.clone(); p.push(output.index.get(&output.root).unwrap().name.clone().unwrap());