Skip to content

Commit 35d5165

Browse files
MichaelHatherlytkelman
authored andcommitted
Move Pkg docs inline.
1 parent fcfb999 commit 35d5165

File tree

1 file changed

+147
-0
lines changed

1 file changed

+147
-0
lines changed

base/pkg.jl

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,37 @@ end
1919
const cd = Dir.cd
2020

2121
dir(path...) = Dir.path(path...)
22+
23+
"""
24+
dir() -> AbstractString
25+
26+
Returns the absolute path of the package directory. This defaults to
27+
`joinpath(homedir(),".julia","v\$(VERSION.major).\$(VERSION.minor)")` on all platforms (i.e.
28+
`~/.julia/v$(VERSION.major).$(VERSION.minor)` in UNIX shell syntax). If the `JULIA_PKGDIR`
29+
environment variable is set, then that path is used in the returned value as
30+
`joinpath(ENV["JULIA_PKGDIR"],"v\$(VERSION.major).\$(VERSION.minor)")`. If `JULIA_PKGDIR` is
31+
a relative path, it is interpreted relative to whatever the current working directory is.
32+
"""
33+
dir()
34+
35+
"""
36+
dir(names...) -> AbstractString
37+
38+
Equivalent to `normpath(Pkg.dir(),names...)` – i.e. it appends path components to the
39+
package directory and normalizes the resulting path. In particular, `Pkg.dir(pkg)` returns
40+
the path to the package `pkg`.
41+
"""
42+
dir(names...)
43+
44+
"""
45+
init(meta::AbstractString=DEFAULT_META, branch::AbstractString=META_BRANCH)
46+
47+
Initialize `Pkg.dir()` as a package directory. This will be done automatically when the
48+
`JULIA_PKGDIR` is not set and `Pkg.dir()` uses its default value. As part of this process,
49+
clones a local METADATA git repository from the site and branch specified by its arguments,
50+
which are typically not provided. Explicit (non-default) arguments can be used to support a
51+
custom METADATA setup.
52+
"""
2253
init(meta::AbstractString=DEFAULT_META, branch::AbstractString=META_BRANCH) = Dir.init(meta,branch)
2354

2455
edit(f::Function, pkg, args...) = Dir.cd() do
@@ -339,33 +370,149 @@ function write_tag_metadata(pkg::String, ver::VersionNumber, commit::String)
339370
return nothing
340371
end
341372

373+
"""
374+
available() -> Vector{ASCIIString}
375+
376+
Returns the names of available packages.
377+
"""
342378
available() = cd(Entry.available)
379+
380+
"""
381+
available(pkg) -> Vector{VersionNumber}
382+
383+
Returns the version numbers available for package `pkg`.
384+
"""
343385
available(pkg::AbstractString) = cd(Entry.available,pkg)
344386

387+
"""
388+
installed() -> Dict{ASCIIString,VersionNumber}
389+
390+
Returns a dictionary mapping installed package names to the installed version number of each
391+
package.
392+
"""
345393
installed() = cd(Entry.installed)
394+
395+
"""
396+
installed(pkg) -> Void | VersionNumber
397+
398+
If `pkg` is installed, return the installed version number, otherwise return `nothing`.
399+
"""
346400
installed(pkg::AbstractString) = cd(Entry.installed,pkg)
347401

402+
"""
403+
status()
404+
405+
Prints out a summary of what packages are installed and what version and state they're in.
406+
"""
348407
status(io::IO=STDOUT) = cd(Entry.status,io)
349408
status(pkg::AbstractString = "", io::IO=STDOUT) = cd(Entry.status,io,pkg)
350409

410+
"""
411+
clone(pkg)
412+
413+
If `pkg` has a URL registered in `Pkg.dir("METADATA")`, clone it from that URL on the
414+
default branch. The package does not need to have any registered versions.
415+
"""
351416
clone(url_or_pkg::AbstractString) = cd(Entry.clone,url_or_pkg)
417+
418+
"""
419+
clone(url, [pkg])
420+
421+
Clone a package directly from the git URL `url`. The package does not need to be registered
422+
in `Pkg.dir("METADATA")`. The package repo is cloned by the name `pkg` if provided; if not
423+
provided, `pkg` is determined automatically from `url`.
424+
"""
352425
clone(url::AbstractString, pkg::AbstractString) = cd(Entry.clone,url,pkg)
353426

427+
"""
428+
checkout(pkg, [branch="master"]; merge=true, pull=true)
429+
430+
Checkout the `Pkg.dir(pkg)` repo to the branch `branch`. Defaults to checking out the
431+
"master" branch. To go back to using the newest compatible released version, use
432+
`Pkg.free(pkg)`. Changes are merged (fast-forward only) if the keyword argument `merge ==
433+
true`, and the latest version is pulled from the upstream repo if `pull == true`.
434+
"""
354435
checkout(pkg::AbstractString, branch::AbstractString="master"; merge::Bool=true, pull::Bool=true) =
355436
cd(Entry.checkout,pkg,branch,merge,pull)
356437

438+
"""
439+
free(pkg)
440+
441+
Free the package `pkg` to be managed by the package manager again. It calls `Pkg.resolve()`
442+
to determine optimal package versions after. This is an inverse for both `Pkg.checkout` and
443+
`Pkg.pin`.
444+
445+
You can also supply an iterable collection of package names, e.g., `Pkg.free(("Pkg1",
446+
"Pkg2"))` to free multiple packages at once.
447+
"""
357448
free(pkg) = cd(Entry.free,pkg)
358449

450+
"""
451+
pin(pkg)
452+
453+
Pin `pkg` at the current version. To go back to using the newest compatible released
454+
version, use `Pkg.free(pkg)`
455+
"""
359456
pin(pkg::AbstractString) = cd(Entry.pin,pkg)
457+
458+
"""
459+
pin(pkg, version)
460+
461+
Pin `pkg` at registered version `version`.
462+
"""
360463
pin(pkg::AbstractString, ver::VersionNumber) = cd(Entry.pin,pkg,ver)
361464

465+
"""
466+
update()
467+
468+
Update the metadata repo – kept in `Pkg.dir("METADATA")` – then update any fixed packages
469+
that can safely be pulled from their origin; then call `Pkg.resolve()` to determine a new
470+
optimal set of packages versions.
471+
"""
362472
update() = cd(Entry.update,Dir.getmetabranch())
473+
474+
"""
475+
resolve()
476+
477+
Determines an optimal, consistent set of package versions to install or upgrade to. The
478+
optimal set of package versions is based on the contents of `Pkg.dir("REQUIRE")` and the
479+
state of installed packages in `Pkg.dir()`, Packages that are no longer required are moved
480+
into `Pkg.dir(".trash")`.
481+
"""
363482
resolve() = cd(Entry.resolve)
364483

484+
"""
485+
build()
486+
487+
Run the build scripts for all installed packages in depth-first recursive order.
488+
"""
365489
build() = cd(Entry.build)
490+
491+
"""
492+
build(pkgs...)
493+
494+
Run the build script in `deps/build.jl` for each package in `pkgs` and all of their
495+
dependencies in depth-first recursive order. This is called automatically by `Pkg.resolve()`
496+
on all installed or updated packages.
497+
"""
366498
build(pkgs::AbstractString...) = cd(Entry.build,[pkgs...])
367499

500+
"""
501+
test()
502+
503+
Run the tests for all installed packages ensuring that each package's test dependencies are
504+
installed for the duration of the test. A package is tested by running its
505+
`test/runtests.jl` file and test dependencies are specified in `test/REQUIRE`.
506+
"""
368507
test(;coverage::Bool=false) = cd(Entry.test; coverage=coverage)
508+
509+
"""
510+
test(pkgs...)
511+
512+
Run the tests for each package in `pkgs` ensuring that each package's test dependencies are
513+
installed for the duration of the test. A package is tested by running its
514+
`test/runtests.jl` file and test dependencies are specified in `test/REQUIRE`.
515+
"""
369516
test(pkgs::AbstractString...; coverage::Bool=false) = cd(Entry.test,AbstractString[pkgs...]; coverage=coverage)
370517

371518
dependents(packagename::AbstractString) = Reqs.dependents(packagename)

0 commit comments

Comments
 (0)