Skip to content

Commit

Permalink
Merge pull request #342 from JunoLab/avi/morecache
Browse files Browse the repository at this point in the history
cache kw descriptions, update to latest SnoopCompile
  • Loading branch information
aviatesk authored Jul 20, 2020
2 parents bef22f5 + e0d5351 commit 380d0a2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
2 changes: 1 addition & 1 deletion scripts/generate_precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ try
open(precompile_file, "w") do io
println(io, "# This file is mostly generated by `scripts/generate_precompile.jl`\n")
if any(str->occursin("__lookup", str), stmts)
println(io, SnoopCompile.lookup_kwbody_str)
println(io, SnoopCompile.SnoopCompileAnalysis.lookup_kwbody_str)
end
println(io, "function _precompile_()")
println(io, " ccall(:jl_generating_output, Cint, ()) == 1 || return nothing")
Expand Down
39 changes: 20 additions & 19 deletions src/completions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -361,16 +361,32 @@ function completiondetail!(comp)
return comp
end

using Markdown

description(docs) = ""
description(docs::Markdown.MD) = begin
md = CodeTools.flatten(docs).content
for part in md
if part isa Markdown.Paragraph
desc = Markdown.plain(part)
occursin("No documentation found.", desc) && return ""
return strlimit(desc, DESCRIPTION_LIMIT)
end
end
return ""
end

handle(completiondetail!, "completiondetail")

function completiondetail_module!(comp, mod, word)
mod = getmodule(mod)
cangetdocs(mod, word) || return
comp["description"] = completiondescription(getdocs(mod, word))
comp["description"] = description(getdocs(mod, word))
end

completiondetail_keyword!(comp, word) =
comp["description"] = completiondescription(getdocs(Main, word))
const KEYWORD_DESCRIPTIONS = Dict(k => description(getdocs(Main, k)) for k in string.(keys(Docs.keywords)))

completiondetail_keyword!(comp, word) = comp["description"] = get(KEYWORD_DESCRIPTIONS, word, "")

using JuliaInterpreter: sparam_syms
using Base.Docs
Expand Down Expand Up @@ -399,7 +415,7 @@ function completiondetail_method!(comp, k)
desc = if cangetdocs(mod, fsym)
try
docs = Docs.doc(Docs.Binding(mod, fsym), Base.tuple_type_tail(m.sig))
completiondescription(docs)
description(docs)
catch
""
end
Expand Down Expand Up @@ -439,18 +455,3 @@ function rt_inf(@nospecialize(f), m, @nospecialize(tt::Type))
end
return ""
end

using Markdown

completiondescription(docs) = ""
completiondescription(docs::Markdown.MD) = begin
md = CodeTools.flatten(docs).content
for part in md
if part isa Markdown.Paragraph
desc = Markdown.plain(part)
occursin("No documentation found.", desc) && return ""
return strlimit(desc, DESCRIPTION_LIMIT)
end
end
return ""
end
9 changes: 7 additions & 2 deletions src/precompile.jl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 380d0a2

Please sign in to comment.