Skip to content

Commit b524a06

Browse files
committed
Add doc changes
Forgot to add these before merging #139
1 parent 41dd15f commit b524a06

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ CodeTracking can be thought of as an extension of Julia's
88
It provides an interface for obtaining:
99

1010
- the strings and expressions of method definitions
11-
- the method signatures at a specific file & line number
11+
- the method signatures (and their corresponding method table) at a specific file & line number
1212
- location information for "dynamic" code that might have moved since it was first loaded
1313
- a list of files that comprise a particular package.
1414

@@ -112,7 +112,7 @@ PkgFiles(ColorTypes [3da002f7-5984-5a60-b8a6-cbb66c0b333f]):
112112
```
113113
114114
115-
You can also find the method-signatures at a particular location:
115+
You can also find the method signatures at a particular location:
116116
117117
```julia
118118
julia> signatures_at(ColorTypes, "src/traits.jl", 14)
@@ -124,7 +124,7 @@ julia> signatures_at("/home/tim/.julia/packages/ColorTypes/BsAWO/src/traits.jl",
124124
nothing => Tuple{typeof(red),AbstractRGB}
125125
```
126126
127-
with the first element being the method table for which the method has been defined (a value of `nothing` denotes the default method table).
127+
with the first element being the method table for which the method was added (a value of `nothing` denotes the default method table).
128128
129129
CodeTracking also helps correcting for [Julia issue #26314](https://github.com/JuliaLang/julia/issues/26314):
130130

src/CodeTracking.jl

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ CodeTracking can be thought of as an extension of InteractiveUtils, and pairs we
66
- `definition`: a lower-level variant of the above
77
- `pkgfiles`: return information about the source files that define a package
88
- `whereis`: Return location information about methods (with Revise, it updates as you edit files)
9-
- `signatures_at`: return the signatures of all methods whose definition spans the specified location
9+
- `signatures_at`: return the signatures (and the corresponding method table) of all methods whose definition spans the specified location
1010
"""
1111
module CodeTracking
1212

@@ -54,8 +54,8 @@ const method_lookup_callback = Ref{Any}(nothing)
5454
# id is the PkgId of the corresponding package
5555
# relpath is the path of the file from the basedir of `id`
5656
# mod is the "active" module at that point in the source
57-
# exsigs is a ex=>sigs dictionary, where `ex` is the source expression and `sigs`
58-
# a list of method-signatures defined by that expression.
57+
# exsigs is a `ex => mt_sigs` dictionary, where `ex` is the source expression and `mt_sigs`
58+
# a list of `method_table => signature` pairs defined by that expression.
5959
const expressions_callback = Ref{Any}(nothing)
6060

6161
const juliabase = joinpath("julia", "base")
@@ -69,9 +69,7 @@ MethodInfoKey(method::Method) = MethodInfoKey(method_table(method), method.sig)
6969
"""
7070
filepath, line = whereis(method::Method)
7171
72-
Return the file and line of the definition of `method`. The meaning of `line`
73-
depends on the Julia version: on Julia 1.5 and higher it is the line number of
74-
the method declaration, otherwise it is the first line of the method's body.
72+
Return the file and line of the definition of `method`.
7573
"""
7674
function whereis(method::Method)
7775
file, line = String(method.file), method.line
@@ -140,11 +138,9 @@ function whereis(lineinfo::Core.LineInfoNode, method::Method)
140138
end
141139

142140
"""
143-
sigs = signatures_at(filename, line)
141+
mt_sigs = signatures_at(filename, line)
144142
145-
Return the signatures of all methods whose definition spans the specified location.
146-
Prior to Julia 1.5, `line` must correspond to a line in the method body
147-
(not the signature or final `end`).
143+
Return the `method_table => signature` pairs of all methods whose definition spans the specified location.
148144
149145
Returns `nothing` if there are no methods at that location.
150146
"""
@@ -181,11 +177,11 @@ function signatures_at(filename::AbstractString, line::Integer)
181177
end
182178

183179
"""
184-
sigs = signatures_at(mod::Module, relativepath, line)
180+
mt_sigs = signatures_at(mod::Module, relativepath, line)
185181
186-
For a package that defines module `mod`, return the signatures of all methods whose definition
187-
spans the specified location. `relativepath` indicates the path of the file relative to
188-
the packages top-level directory, e.g., `"src/utils.jl"`.
182+
For a package that defines module `mod`, return the `method_table => signature` pairs of
183+
all methods whose definition spans the specified location. `relativepath` indicates the
184+
path of the file relative to the packages top-level directory, e.g., `"src/utils.jl"`.
189185
`line` must correspond to a line in the method body (not the signature or final `end`).
190186
191187
Returns `nothing` if there are no methods at that location.
@@ -200,10 +196,10 @@ function signatures_at(id::PkgId, relpath::AbstractString, line::Integer)
200196
expressions === nothing && error("cannot look up methods by line number, try `using Revise` before loading other packages")
201197
try
202198
for (mod, exsigs) in Base.invokelatest(expressions, id, relpath)
203-
for (ex, sigs) in exsigs
199+
for (ex, mt_sigs) in exsigs
204200
lr = linerange(ex)
205201
lr === nothing && continue
206-
line lr && return sigs
202+
line lr && return mt_sigs
207203
end
208204
end
209205
catch

0 commit comments

Comments
 (0)