Skip to content

Commit 707ef52

Browse files
committed
better docs
1 parent 027f6b0 commit 707ef52

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/rustdoc-json-types/lib.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -1038,8 +1038,17 @@ pub enum Type {
10381038
pub struct Path {
10391039
/// The path of the type.
10401040
///
1041-
/// This will be the path where the type is *used*, so it may be a
1042-
/// re-export.
1041+
/// This will be the path that is *used* (not where it is defined), so
1042+
/// multiple `Path`s may have different values for this field even if
1043+
/// they all refer to the same item. e.g.
1044+
///
1045+
/// ```rust
1046+
/// pub type Vec1 = std::vec::Vec<i32>; // path: "std::vec::Vec"
1047+
/// pub type Vec2 = Vec<i32>; // path: "Vec"
1048+
/// pub type Vec3 = std::prelude::v1::Vec<i32>; // path: "std::prelude::v1::Vec"
1049+
/// ```
1050+
//
1051+
// Example tested in ./tests/rustdoc-json/path_name.rs
10431052
pub path: String,
10441053
/// The ID of the type.
10451054
pub id: Id,

tests/rustdoc-json/path_name.rs

+9
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,12 @@ pub type Y4 = XPrivMod2;
7272
//@ has "$.paths[*].path" '["defines_and_reexports", "m2", "InPrivMod"]'
7373
//@ !has "$.paths[*].path" '["defines_and_reexports", "InPubMod"]'
7474
//@ !has "$.paths[*].path" '["defines_and_reexports", "InPrivMod"]'
75+
76+
// Tests for the example in the docs of Path::name.
77+
// If these change, chage the docs.
78+
//@ is "$.index[*][?(@.name=='Vec1')].inner.type_alias.type.resolved_path.path" '"std::vec::Vec"'
79+
pub type Vec1 = std::vec::Vec<i32>;
80+
//@ is "$.index[*][?(@.name=='Vec2')].inner.type_alias.type.resolved_path.path" '"Vec"'
81+
pub type Vec2 = Vec<i32>;
82+
//@ is "$.index[*][?(@.name=='Vec3')].inner.type_alias.type.resolved_path.path" '"std::prelude::v1::Vec"'
83+
pub type Vec3 = std::prelude::v1::Vec<i32>;

0 commit comments

Comments
 (0)