mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
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>
This commit is contained in:
commit
c9cec381bc
2 changed files with 27 additions and 2 deletions
|
@ -80,19 +80,35 @@ pub type Package = Idx<PackageData>;
|
||||||
|
|
||||||
pub type Target = Idx<TargetData>;
|
pub type Target = Idx<TargetData>;
|
||||||
|
|
||||||
|
/// Information associated with a cargo crate
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub struct PackageData {
|
pub struct PackageData {
|
||||||
|
/// Version given in the `Cargo.toml`
|
||||||
pub version: String,
|
pub version: String,
|
||||||
|
/// Name as given in the `Cargo.toml`
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
/// Path containing the `Cargo.toml`
|
||||||
pub manifest: AbsPathBuf,
|
pub manifest: AbsPathBuf,
|
||||||
|
/// Targets provided by the crate (lib, bin, example, test, ...)
|
||||||
pub targets: Vec<Target>,
|
pub targets: Vec<Target>,
|
||||||
|
/// Is this package a member of the current workspace
|
||||||
pub is_member: bool,
|
pub is_member: bool,
|
||||||
|
/// List of packages this package depends on
|
||||||
pub dependencies: Vec<PackageDependency>,
|
pub dependencies: Vec<PackageDependency>,
|
||||||
|
/// Rust edition for this package
|
||||||
pub edition: Edition,
|
pub edition: Edition,
|
||||||
|
/// List of features to activate
|
||||||
pub features: Vec<String>,
|
pub features: Vec<String>,
|
||||||
|
/// List of config flags defined by this package's build script
|
||||||
pub cfgs: Vec<CfgFlag>,
|
pub cfgs: Vec<CfgFlag>,
|
||||||
|
/// List of cargo-related environment variables with their value
|
||||||
|
///
|
||||||
|
/// If the package has a build script which defines environment variables,
|
||||||
|
/// they can also be found here.
|
||||||
pub envs: Vec<(String, String)>,
|
pub envs: Vec<(String, String)>,
|
||||||
|
/// Directory where a build script might place its output
|
||||||
pub out_dir: Option<AbsPathBuf>,
|
pub out_dir: Option<AbsPathBuf>,
|
||||||
|
/// Path to the proc-macro library file if this package exposes proc-macros
|
||||||
pub proc_macro_dylib_path: Option<AbsPathBuf>,
|
pub proc_macro_dylib_path: Option<AbsPathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,12 +118,18 @@ pub struct PackageDependency {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Information associated with a package's target
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub struct TargetData {
|
pub struct TargetData {
|
||||||
|
/// Package that provided this target
|
||||||
pub package: Package,
|
pub package: Package,
|
||||||
|
/// Name as given in the `Cargo.toml` or generated from the file name
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
/// Path to the main source file of the target
|
||||||
pub root: AbsPathBuf,
|
pub root: AbsPathBuf,
|
||||||
|
/// Kind of target
|
||||||
pub kind: TargetKind,
|
pub kind: TargetKind,
|
||||||
|
/// Is this target a proc-macro
|
||||||
pub is_proc_macro: bool,
|
pub is_proc_macro: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
//! FIXME: write short doc here
|
//! FIXME: write short doc here
|
||||||
|
|
||||||
mod cargo_workspace;
|
mod cargo_workspace;
|
||||||
|
mod cfg_flag;
|
||||||
mod project_json;
|
mod project_json;
|
||||||
mod sysroot;
|
mod sysroot;
|
||||||
mod cfg_flag;
|
|
||||||
mod workspace;
|
mod workspace;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -17,7 +17,10 @@ use paths::{AbsPath, AbsPathBuf};
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
|
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
cargo_workspace::{CargoConfig, CargoWorkspace, Package, Target, TargetKind},
|
cargo_workspace::{
|
||||||
|
CargoConfig, CargoWorkspace, Package, PackageData, PackageDependency, Target, TargetData,
|
||||||
|
TargetKind,
|
||||||
|
},
|
||||||
project_json::{ProjectJson, ProjectJsonData},
|
project_json::{ProjectJson, ProjectJsonData},
|
||||||
sysroot::Sysroot,
|
sysroot::Sysroot,
|
||||||
workspace::{PackageRoot, ProjectWorkspace},
|
workspace::{PackageRoot, ProjectWorkspace},
|
||||||
|
|
Loading…
Reference in a new issue