Skip to content

Commit aec4f32

Browse files
nhz2fredrikekre
authored andcommitted
remove LibGit2 dep and fix test
1 parent f65720c commit aec4f32

File tree

3 files changed

+5
-49
lines changed

3 files changed

+5
-49
lines changed

Project.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@ name = "DocStringExtensions"
22
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
33
version = "0.9.3"
44

5-
[deps]
6-
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
7-
85
[compat]
96
julia = "1"
107

118
[extras]
9+
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
1210
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
1311
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
1412
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1513

1614
[targets]
17-
test = ["Markdown", "Pkg", "Test"]
15+
test = ["LibGit2", "Markdown", "Pkg", "Test"]

src/DocStringExtensions.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ module DocStringExtensions
7575

7676
# Imports.
7777

78-
import LibGit2
7978

8079
# Exports.
8180

src/utilities.jl

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ function keywords(func, m::Method)
459459
if !(Base.fieldindex(Core.MethodTable, :kwsorter, false) > 0) || isdefined(table, :kwsorter)
460460
# Fetching method keywords stolen from base/replutil.jl:572-576 (commit 3b45cdc9aab0):
461461
kwargs = VERSION < v"1.4.0-DEV.215" ? Base.kwarg_decl(m, typeof(table.kwsorter)) : Base.kwarg_decl(m)
462-
if isa(kwargs, Vector) && length(kwargs) > 0
462+
if isa(kwargs, Vector) && length(kwargs) > 0 && kwargs != [:...] # in julia 1.10 sometimes kwargs is `[:...]`, ignore that
463463
filter!(arg -> !occursin("#", string(arg)), kwargs)
464464
# Keywords *may* not be sorted correctly. We move the vararg one to the end.
465465
index = findfirst(arg -> endswith(string(arg), "..."), kwargs)
@@ -519,50 +519,9 @@ $(:SIGNATURES)
519519
520520
Get the URL (file and line number) where a method `m` is defined.
521521
522-
Note that this is based on the implementation of `Base.url`, but handles URLs correctly
523-
on TravisCI as well.
522+
Note that this is `Base.url`.
524523
"""
525-
url(m::Method) = url(m.module, string(m.file), m.line)
526-
527-
function url(mod::Module, file::AbstractString, line::Integer)
528-
file = Sys.iswindows() ? replace(file, '\\' => '/') : file
529-
if Base.inbase(mod) && !isabspath(file)
530-
local base = "https://github.com/JuliaLang/julia/tree"
531-
if isempty(Base.GIT_VERSION_INFO.commit)
532-
return "$base/v$VERSION/base/$file#L$line"
533-
else
534-
local commit = Base.GIT_VERSION_INFO.commit
535-
return "$base/$commit/base/$file#L$line"
536-
end
537-
else
538-
if isfile(file)
539-
local d = dirname(file)
540-
try # might not be in a git repo
541-
LibGit2.with(LibGit2.GitRepoExt(d)) do repo
542-
LibGit2.with(LibGit2.GitConfig(repo)) do cfg
543-
local u = LibGit2.get(cfg, "remote.origin.url", "")
544-
local m = match(LibGit2.GITHUB_REGEX, u)
545-
u = m === nothing ? get(ENV, "TRAVIS_REPO_SLUG", "") : m.captures[1]
546-
local commit = string(LibGit2.head_oid(repo))
547-
local root = LibGit2.path(repo)
548-
if startswith(file, root) || startswith(realpath(file), root)
549-
local base = "https://github.com/$u/tree"
550-
local filename = file[(length(root) + 1):end]
551-
return "$base/$commit/$filename#L$line"
552-
else
553-
return ""
554-
end
555-
end
556-
end
557-
catch err
558-
isa(err, LibGit2.GitError) || rethrow()
559-
return ""
560-
end
561-
else
562-
return ""
563-
end
564-
end
565-
end
524+
url(m::Method) = Base.url(m)
566525

567526
# This is compat to make sure that we have ismutabletype available pre-1.7.
568527
# Implementation borrowed from JuliaLang/julia (MIT license).

0 commit comments

Comments
 (0)