Skip to content

Commit

Permalink
Rollup merge of #81225 - CraftSpider:json-opt-docs, r=jyn514
Browse files Browse the repository at this point in the history
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'.
  • Loading branch information
m-ou-se authored Jan 22, 2021
2 parents 950ed27 + 26565f0 commit 1cc13b4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/librustdoc/json/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,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());
Expand Down
5 changes: 3 additions & 2 deletions src/librustdoc/json/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ 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.
pub docs: String,
/// 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<String>,
/// 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<String, Id>,
/// Stringified versions of the attributes on this item (e.g. `"#[inline]"`)
Expand Down

0 comments on commit 1cc13b4

Please sign in to comment.