You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/librustdoc/json/types.rs
+20-21
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
//! Rustdoc's JSON output interface
2
2
//!
3
-
//! These types are the public API exposed through the `--output-format json` flag. The [`Crate`][]
3
+
//! These types are the public API exposed through the `--output-format json` flag. The [`Crate`]
4
4
//! struct is the root of the JSON blob and all other items are contained within.
5
5
6
6
use std::path::PathBuf;
@@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize};
13
13
/// tools to find or link to them.
14
14
#[derive(Clone,Debug,Serialize,Deserialize)]
15
15
pubstructCrate{
16
-
/// The id of the root [`Module`][] item of the local crate.
16
+
/// The id of the root [`Module`] item of the local crate.
17
17
pubroot:Id,
18
18
/// The version string given to `--crate-version`, if any.
19
19
pubversion:Option<String>,
@@ -22,10 +22,9 @@ pub struct Crate {
22
22
/// A collection of all items in the local crate as well as some external traits and their
23
23
/// items that are referenced locally.
24
24
pubindex:FxHashMap<Id,Item>,
25
-
/// Maps ids to fully qualified paths (e.g. `["std", "io", "lazy", "Lazy"]` for
26
-
/// `std::io::lazy::Lazy`) as well as their `ItemKind`
25
+
/// Maps IDs to fully qualified paths and other info helpful for generating links.
27
26
pubpaths:FxHashMap<Id,ItemSummary>,
28
-
/// Maps `crate_num` of items to a crate name and html_root_url if it exists
27
+
/// Maps `crate_id` of items to a crate name and html_root_url if it exists.
29
28
pubexternal_crates:FxHashMap<u32,ExternalCrate>,
30
29
/// A single version number to be used in the future when making backwards incompatible changes
31
30
/// to the JSON output.
@@ -38,31 +37,36 @@ pub struct ExternalCrate {
38
37
pubhtml_root_url:Option<String>,
39
38
}
40
39
41
-
/// For external items (stuff not defined in the local crate), you don't get the same level of
40
+
/// For external (not defined in the local crate) items, you don't get the same level of
42
41
/// information. This struct should contain enough to generate a link/reference to the item in
43
42
/// question, or can be used by a tool that takes the json output of multiple crates to find
44
43
/// the actual item definition with all the relevant info.
45
44
#[derive(Clone,Debug,Serialize,Deserialize)]
46
45
pubstructItemSummary{
47
-
pubcrate_num:u32,
46
+
/// Can be used to look up the name and html_root_url of the crate this item came from in the
47
+
/// `external_crates` map.
48
+
pubcrate_id:u32,
49
+
/// The list of path components for the fully qualified path of this item (e.g.
50
+
/// `["std", "io", "lazy", "Lazy"]` for `std::io::lazy::Lazy`).
48
51
pubpath:Vec<String>,
52
+
/// Whether this item is a struct, trait, macro, etc.
49
53
pubkind:ItemKind,
50
54
}
51
55
52
56
#[derive(Clone,Debug,Serialize,Deserialize)]
53
57
pubstructItem{
54
-
/// This can be used as a key to the `external_crates` map of [`Crate`][] to see which crate
58
+
/// This can be used as a key to the `external_crates` map of [`Crate`] to see which crate
55
59
/// this item came from.
56
-
pubcrate_num:u32,
60
+
pubcrate_id:u32,
57
61
/// Some items such as impls don't have names.
58
62
pubname:Option<String>,
59
-
/// The source location of this item. May not be present if it came from a macro expansion,
60
-
/// inline assembly, other "virtual" files.
63
+
/// The source location of this item (absent if it came from a macro expansion or inline
64
+
/// assembly).
61
65
pubsource:Option<Span>,
62
-
/// Usually documented items are all public, but you can tell rustdoc to output private items
66
+
/// By default all documented items are public, but you can tell rustdoc to output private items
63
67
/// so this field is needed to differentiate.
64
68
pubvisibility:Visibility,
65
-
/// The full docstring of this item.
69
+
/// The full markdown docstring of this item.
66
70
pubdocs:String,
67
71
/// This mapping resolves [intradoc links](https://github.com/rust-lang/rfcs/blob/master/text/1946-intra-rustdoc-links.md) from the docstring to their IDs
68
72
publinks:FxHashMap<String,Id>,
@@ -71,10 +75,6 @@ pub struct Item {
71
75
pubdeprecation:Option<Deprecation>,
72
76
pubkind:ItemKind,
73
77
pubinner:ItemEnum,
74
-
// TODO: should we stringify the cfg attrs as well, or should we preserve their structure so
75
-
// the consumer doesn't have to parse an arbitrarily nested tree to figure out what platforms
76
-
// the item is available on?
77
-
// TODO: should we have a "stability" field if it's only used by the standard library?
78
78
}
79
79
80
80
#[derive(Clone,Debug,Serialize,Deserialize)]
@@ -97,6 +97,8 @@ pub struct Deprecation {
97
97
#[derive(Clone,Debug,Serialize,Deserialize)]
98
98
pubenumVisibility{
99
99
Public,
100
+
/// For the most part items are private by default. The exceptions are associated items of
101
+
/// public traits and variants of public enums.
100
102
Default,
101
103
Crate,
102
104
// TODO: Restricted(Id, String),
@@ -336,7 +338,7 @@ pub enum Type {
336
338
ResolvedPath{
337
339
name:String,
338
340
id:Id,
339
-
args:Box<Option<GenericArgs>>,
341
+
args:Option<Box<GenericArgs>>,
340
342
param_names:Vec<GenericBound>,
341
343
},
342
344
/// Parameterized types
@@ -429,9 +431,6 @@ pub struct Impl {
429
431
pubblanket_impl:Option<Type>,
430
432
}
431
433
432
-
// TODO: this is currently broken because imports have the same ID as the module that contains
433
-
// them. The only obvious fix is to modify the clean types to renumber imports so that IDs are
0 commit comments