Skip to content

Commit 1cc13b4

Browse files
authored
Rollup merge of #81225 - CraftSpider:json-opt-docs, r=jyn514
Make 'docs' nullable in rustdoc-json output Matches the backing better, and makes it so there's a difference between 'empty docs' and 'no docs'.
2 parents 950ed27 + 26565f0 commit 1cc13b4

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/librustdoc/json/conversions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl JsonRenderer<'_> {
2727
name: name.map(|sym| sym.to_string()),
2828
source: self.convert_span(source),
2929
visibility: self.convert_visibility(visibility),
30-
docs: attrs.collapsed_doc_value().unwrap_or_default(),
30+
docs: attrs.collapsed_doc_value(),
3131
links: attrs
3232
.links
3333
.into_iter()

src/librustdoc/json/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
241241
)
242242
})
243243
.collect(),
244-
format_version: 1,
244+
format_version: 2,
245245
};
246246
let mut p = self.out_path.clone();
247247
p.push(output.index.get(&output.root).unwrap().name.clone().unwrap());

src/librustdoc/json/types.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ pub struct Item {
6868
/// By default all documented items are public, but you can tell rustdoc to output private items
6969
/// so this field is needed to differentiate.
7070
pub visibility: Visibility,
71-
/// The full markdown docstring of this item.
72-
pub docs: String,
71+
/// The full markdown docstring of this item. Absent if there is no documentation at all,
72+
/// Some("") if there is some documentation but it is empty (EG `#[doc = ""]`).
73+
pub docs: Option<String>,
7374
/// 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
7475
pub links: FxHashMap<String, Id>,
7576
/// Stringified versions of the attributes on this item (e.g. `"#[inline]"`)

0 commit comments

Comments
 (0)