Skip to content

Commit c9cec38

Browse files
bors[bot]Arnaud
andauthored
Merge #7181
7181: Document project_model::PackageData and project_model::TargetData r=arnaudgolfouse a=arnaudgolfouse This PR adds some documentation for the `project_model` crate. Some of the field descriptions were taken directly from their `cargo_metadata` counterpart : - `PackageData` -> `cargo_metadata::Package` - `TargetData` -> `cargo_metadata::Target` Co-authored-by: Arnaud <arnaud.golfouse@free.fr>
2 parents 1b2d80d + ef636ba commit c9cec38

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

crates/project_model/src/cargo_workspace.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,35 @@ pub type Package = Idx<PackageData>;
8080

8181
pub type Target = Idx<TargetData>;
8282

83+
/// Information associated with a cargo crate
8384
#[derive(Debug, Clone, Eq, PartialEq)]
8485
pub struct PackageData {
86+
/// Version given in the `Cargo.toml`
8587
pub version: String,
88+
/// Name as given in the `Cargo.toml`
8689
pub name: String,
90+
/// Path containing the `Cargo.toml`
8791
pub manifest: AbsPathBuf,
92+
/// Targets provided by the crate (lib, bin, example, test, ...)
8893
pub targets: Vec<Target>,
94+
/// Is this package a member of the current workspace
8995
pub is_member: bool,
96+
/// List of packages this package depends on
9097
pub dependencies: Vec<PackageDependency>,
98+
/// Rust edition for this package
9199
pub edition: Edition,
100+
/// List of features to activate
92101
pub features: Vec<String>,
102+
/// List of config flags defined by this package's build script
93103
pub cfgs: Vec<CfgFlag>,
104+
/// List of cargo-related environment variables with their value
105+
///
106+
/// If the package has a build script which defines environment variables,
107+
/// they can also be found here.
94108
pub envs: Vec<(String, String)>,
109+
/// Directory where a build script might place its output
95110
pub out_dir: Option<AbsPathBuf>,
111+
/// Path to the proc-macro library file if this package exposes proc-macros
96112
pub proc_macro_dylib_path: Option<AbsPathBuf>,
97113
}
98114

@@ -102,12 +118,18 @@ pub struct PackageDependency {
102118
pub name: String,
103119
}
104120

121+
/// Information associated with a package's target
105122
#[derive(Debug, Clone, Eq, PartialEq)]
106123
pub struct TargetData {
124+
/// Package that provided this target
107125
pub package: Package,
126+
/// Name as given in the `Cargo.toml` or generated from the file name
108127
pub name: String,
128+
/// Path to the main source file of the target
109129
pub root: AbsPathBuf,
130+
/// Kind of target
110131
pub kind: TargetKind,
132+
/// Is this target a proc-macro
111133
pub is_proc_macro: bool,
112134
}
113135

crates/project_model/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! FIXME: write short doc here
22
33
mod cargo_workspace;
4+
mod cfg_flag;
45
mod project_json;
56
mod sysroot;
6-
mod cfg_flag;
77
mod workspace;
88

99
use std::{
@@ -17,7 +17,10 @@ use paths::{AbsPath, AbsPathBuf};
1717
use rustc_hash::FxHashSet;
1818

1919
pub use crate::{
20-
cargo_workspace::{CargoConfig, CargoWorkspace, Package, Target, TargetKind},
20+
cargo_workspace::{
21+
CargoConfig, CargoWorkspace, Package, PackageData, PackageDependency, Target, TargetData,
22+
TargetKind,
23+
},
2124
project_json::{ProjectJson, ProjectJsonData},
2225
sysroot::Sysroot,
2326
workspace::{PackageRoot, ProjectWorkspace},

0 commit comments

Comments
 (0)