-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rustdoc-json] absolute position of item is hard to get #93524
Comments
It is not quite that simple unfortunately, because an item can have many "parents". Consider this code in mod m {
pub const C: usize = 7;
}
pub mod a {
pub use super::m::C;
}
pub mod b {
pub use super::m::C;
} The rustdoc JSON will be (some details omitted): "0:4": {
"id": "0:4",
"crate_id": 0,
"name": "C",
"visibility": "public",
"kind": "constant",
"inner": {
"type": {
"kind": "primitive",
"inner": "usize"
},
}
},
"0:5": {
"id": "0:5",
"crate_id": 0,
"name": "a",
"visibility": "public",
"kind": "module",
"inner": {
"is_crate": false,
"items": [
"0:4" <--- Note: Contains C
]
}
},
"0:9": {
"id": "0:9",
"crate_id": 0,
"name": "b",
"visibility": "public",
"kind": "module",
"inner": {
"is_crate": false,
"items": [
"0:4" <--- Note: Also contains C
]
}
}, So if you were to encounter only |
Yes many relative "parents" but there is only one absolute parent. Ex: a struct |
What you call the "absolute parent" is not always present in the rustdoc JSON output though. For example in the sample code above, because Should we simply omit |
This will solved by #93518 who is introducing the I have already been locally experimenting with #93518 and |
Problem:
Currently, the only way to accurately (see #93522 for reason why
paths
is not accurate) know the position of an item is to traverse all modules and items down to the item that we want, this is costly and inefficient especially forId
s that comes from the documentation (ie intra-doc-links) because they can link to outside.Solution:
Have a
parent_id
field that link the currentItem
to it's direct parent. This would mean that we could go from down (item) to upper (module) in a straightforward way.The text was updated successfully, but these errors were encountered: