Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cache kw descriptions, update to latest SnoopCompile #342

Merged
merged 2 commits into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.