Skip to content

Commit de1cccd

Browse files
committed
docs(package): document Catalogs field mapping with YAML examples
1 parent df172e8 commit de1cccd

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

crates/biome_package/src/node_js_package/package_json.rs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,41 @@ impl PackageJson {
182182
}
183183
}
184184

185+
/// Parsed catalogs from `pnpm-workspace.yaml`.
186+
///
187+
/// Mapping from YAML to this type:
188+
/// ```yaml
189+
/// catalog:
190+
/// <dep>: <version>
191+
/// catalogs:
192+
/// <name>:
193+
/// <dep>: <version>
194+
/// ```
195+
/// - top-level `catalog` -> [`Catalogs::default`]
196+
/// - top-level `catalogs` -> [`Catalogs::named`]
197+
///
185198
#[derive(Debug, Default, Clone)]
186199
pub struct Catalogs {
187-
/// Dependencies listed under the top-level `catalog:` key in pnpm-workspace.yaml.
200+
/// Dependency map declared under the top-level `catalog:` key.
201+
///
202+
/// Example:
203+
/// ```yaml
204+
/// catalog:
205+
/// react: 19.2.0
206+
/// ```
207+
/// -> `default["react"] == "19.2.0"`.
188208
pub default: Option<Dependencies>,
189-
/// Named catalogs listed under `catalogs:` in pnpm-workspace.yaml, keyed by catalog name.
209+
210+
/// Dependency maps declared under top-level `catalogs:`.
211+
///
212+
/// The key is the catalog name, and the value is its dependencies map.
213+
/// Example:
214+
/// ```yaml
215+
/// catalogs:
216+
/// react19:
217+
/// react: 19.2.0
218+
/// ```
219+
/// -> `named["react19"]["react"] == "19.2.0"`.
190220
pub named: FxHashMap<Box<str>, Dependencies>,
191221
}
192222

0 commit comments

Comments
 (0)