Skip to content

Commit d7686d6

Browse files
authored
Merge pull request #7 from timholy/teh/printing
Don't export PkgFiles and improve printing
2 parents 652aeae + a3302dd commit d7686d6

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

src/CodeTracking.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ using Base: PkgId
44
using Core: LineInfoNode
55
using UUIDs
66

7-
export PkgFiles
87
export whereis, definition, pkgfiles
98

109
include("pkgfiles.jl")
@@ -97,8 +96,8 @@ definition(method::Method) = definition(method, Expr)
9796
info = pkgfiles(name::AbstractString)
9897
info = pkgfiles(name::AbstractString, uuid::UUID)
9998
100-
Return a [`PkgFiles`](@ref) structure with information about the files that define the package
101-
specified by `name` and `uuid`.
99+
Return a [`CodeTracking.PkgFiles`](@ref) structure with information about the files that
100+
define the package specified by `name` and `uuid`.
102101
Returns `nothing` if this package has not been loaded.
103102
"""
104103
pkgfiles(name::AbstractString, uuid::UUID) = pkgfiles(PkgId(uuid, name))
@@ -113,8 +112,8 @@ pkgfiles(id::PkgId) = get(_pkgfiles, id, nothing)
113112
"""
114113
info = pkgfiles(mod::Module)
115114
116-
Return a [`PkgFiles`](@ref) structure with information about the files that were loaded to
117-
define the package that defined `mod`.
115+
Return a [`CodeTracking.PkgFiles`](@ref) structure with information about the files that
116+
were loaded to define the package that defined `mod`.
118117
"""
119118
pkgfiles(mod::Module) = pkgfiles(PkgId(mod))
120119

src/pkgfiles.jl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,15 @@ srcfiles(info::PkgFiles) = info.files
2525
basedir(info::PkgFiles) = info.basedir
2626

2727
function Base.show(io::IO, info::PkgFiles)
28-
println(io, "PkgFiles(", info.id, "):")
29-
println(io, " basedir: \"", info.basedir, '"')
30-
print(io, " files: ")
31-
show(io, info.files)
28+
compact = get(io, :compact, false)
29+
if compact
30+
print(io, "PkgFiles(", info.id.name, ", ", info.basedir, ", ")
31+
show(io, info.files)
32+
print(io, ')')
33+
else
34+
println(io, "PkgFiles(", info.id, "):")
35+
println(io, " basedir: \"", info.basedir, '"')
36+
print(io, " files: ")
37+
show(io, info.files)
38+
end
3239
end

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using CodeTracking
22
using Test
3-
# Note: ColorTypes needs to be installed, but note the absence of `using`
3+
# Note: ColorTypes needs to be installed, but note the intentional absence of `using ColorTypes`
44

55
include("script.jl")
66

@@ -21,7 +21,7 @@ include("script.jl")
2121
f2(x, y) = x + y
2222
"""
2323

24-
info = PkgFiles(Base.PkgId(CodeTracking))
24+
info = CodeTracking.PkgFiles(Base.PkgId(CodeTracking))
2525
@test Base.PkgId(info) === info.id
2626
@test CodeTracking.basedir(info) == dirname(@__DIR__)
2727

0 commit comments

Comments
 (0)