Skip to content

Commit e0d1d8a

Browse files
committed
Create a stub implementation
This implementation is designed to allow people to start using this package in other projects. The Revise integration will come later.
1 parent ae5f9da commit e0d1d8a

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name = "CodeTracking"
2-
uuid = "e566d876-1fe1-11e9-33c3-297fb9d9bdc3"
2+
uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
33
authors = ["Tim Holy <[email protected]>"]
44
version = "0.1.0"
55

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
11
# CodeTracking
2+
3+
CodeTracking is a minimal package designed to work with (a future version of)
4+
[Revise.jl](https://github.com/timholy/Revise.jl).
5+
Its main purpose is to allow packages that need to know the location
6+
(file and line number) of code that might move around as it's edited.
7+
8+
CodeTracking is a very lightweight dependency.
9+
10+
Demo:
11+
12+
```julia
13+
julia> using CodeTracking
14+
15+
julia> m = @which sum([1,2,3])
16+
sum(a::AbstractArray) in Base at reducedim.jl:648
17+
18+
julia> file, line = whereis(m)
19+
("/home/tim/src/julia-1/usr/share/julia/base/reducedim.jl", 648)
20+
```

src/CodeTracking.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
module CodeTracking
22

3-
greet() = print("Hello World!")
3+
export whereis
4+
5+
# This is just a stub implementation for now
6+
function whereis(method::Method)
7+
file, line = String(method.file), method.line
8+
if !isabspath(file)
9+
# This is a Base method
10+
file = Base.find_source_file(file)
11+
end
12+
return normpath(file), line
13+
end
414

515
end # module

0 commit comments

Comments
 (0)