Skip to content

Commit 73dcc8a

Browse files
committed
Update pkgid-spec docs.
1 parent e78f1c8 commit 73dcc8a

File tree

1 file changed

+37
-14
lines changed

1 file changed

+37
-14
lines changed

Diff for: src/doc/src/reference/pkgid-spec.md

+37-14
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,60 @@
44

55
Subcommands of Cargo frequently need to refer to a particular package within a
66
dependency graph for various operations like updating, cleaning, building, etc.
7-
To solve this problem, Cargo supports Package ID Specifications. A specification
7+
To solve this problem, Cargo supports *Package ID Specifications*. A specification
88
is a string which is used to uniquely refer to one package within a graph of
99
packages.
1010

11+
The specification may be fully qualified, such as
12+
`https://github.com/rust-lang/crates.io-index#regex:1.4.3` or it may be
13+
abbreviated, such as `regex`. The abbreviated form may be used as long as it
14+
uniquely identifies a single package in the dependency graph. If there is
15+
ambiguity, additional qualifiers can be added to make it unique. For example,
16+
if there are two versions of the `regex` package in the graph, then it can be
17+
qualified with a version to make it unique, such as `regex:1.4.3`.
18+
1119
#### Specification grammar
1220

1321
The formal grammar for a Package Id Specification is:
1422

1523
```notrust
16-
pkgid := pkgname
17-
| [ proto "://" ] hostname-and-path [ "#" ( pkgname | semver ) ]
24+
spec := pkgname
25+
| proto "://" hostname-and-path [ "#" ( pkgname | semver ) ]
1826
pkgname := name [ ":" semver ]
1927
2028
proto := "http" | "git" | ...
2129
```
2230

2331
Here, brackets indicate that the contents are optional.
2432

33+
The URL form can be used for git dependencies, or to differentiate packages
34+
that come from different sources such as different registries.
35+
2536
#### Example specifications
2637

27-
These could all be references to a package `foo` version `1.2.3` from the
28-
registry at `crates.io`
29-
30-
| pkgid | name | version | url |
31-
|:-----------------------------|:-----:|:-------:|:----------------------:|
32-
| `foo` | `foo` | `*` | `*` |
33-
| `foo:1.2.3` | `foo` | `1.2.3` | `*` |
34-
| `crates.io/foo` | `foo` | `*` | `*://crates.io/foo` |
35-
| `crates.io/foo#1.2.3` | `foo` | `1.2.3` | `*://crates.io/foo` |
36-
| `crates.io/bar#foo:1.2.3` | `foo` | `1.2.3` | `*://crates.io/bar` |
37-
| `https://crates.io/foo#1.2.3`| `foo` | `1.2.3` | `https://crates.io/foo` |
38+
The following are references to the `regex` package on `crates.io`:
39+
40+
| Spec | Name | Version |
41+
|:------------------------------------------------------------|:-------:|:-------:|
42+
| `regex` | `regex` | `*` |
43+
| `regex:1.4.3` | `regex` | `1.4.3` |
44+
| `https://github.com/rust-lang/crates.io-index#regex` | `regex` | `*` |
45+
| `https://github.com/rust-lang/crates.io-index#regex:1.4.3` | `regex` | `1.4.3` |
46+
47+
The following are some examples of specs for several different git dependencies:
48+
49+
| Spec | Name | Version |
50+
|:----------------------------------------------------------|:----------------:|:--------:|
51+
| `https://github.com/rust-lang/cargo#0.52.0` | `cargo` | `0.52.0` |
52+
| `https://github.com/rust-lang/cargo#cargo-platform:0.1.1` | <nobr>`cargo-platform`</nobr> | `0.1.1` |
53+
| `ssh://git@github.com/rust-lang/regex.git#regex:1.4.3` | `regex` | `1.4.3` |
54+
55+
Local packages on the filesystem can use `file://` URLs to reference them:
56+
57+
| Spec | Name | Version |
58+
|:---------------------------------------|:-----:|:-------:|
59+
| `file:///path/to/my/project/foo` | `foo` | `*` |
60+
| `file:///path/to/my/project/foo#1.1.8` | `foo` | `1.1.8` |
3861

3962
#### Brevity of specifications
4063

0 commit comments

Comments
 (0)