-
Notifications
You must be signed in to change notification settings - Fork 6
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
Automate WatchJuliaBurn with Glyphy.jl #32
Comments
I've updated this to autogenerate suggestions for any module: using Glyphy: _query_db
findstatement(name) = "select * from unicodechart where name like '%$name%' ESCAPE '`';"
# NOTE: this list most likely isn't complete
const unicode_emoji_ranges = [
# Miscellaneous Symbols
0x2600:0x26FF,
# Dingbats
0x2700:0x27BF,
# Miscellaneous Symbols and Arrows
0x2B00:0x2BFF,
# Miscellaneous Symbols and Pictographs
0x1F300:0x1F5FF,
# Smileys
0x1F600:0x1F64F,
# Transport and Map Symbols
0x1F680:0x1F6FF,
# Supplemental Symbols and Pictographs
0x1F900:0x1F9FF,
# Flags
0x1F1E6:0x1F1FF,
]
function isemoji(i::Integer)
# speed things up with a coarse check...
i < 0x2600 || i > 0x1F9FF && return false
i in 0x2BFF:0x1F300 && return false
# ...then check more precisely
for r in unicode_emoji_ranges
i in r && return true
end
return false
end
function glyphyfy(name::AbstractString)
query = _query_db(findstatement(name))
ids = [UInt(q.id) for q in query]
emoji = [Char(id) for id in ids if isemoji(id)]
return name => tuple(emoji...)
end
function wjb_candidates(m::Module)
fn_names = String.(names(m))
# short names match with too many glyphs
filter!(n -> length(n) > 2, fn_names)
glyphs = glyphyfy.(fn_names)
return Dict(k => v for (k, v) in glyphs if !isempty(v))
end
function print_md_table(io, candidates)
println(io, "| Function | Emoji |")
println(io, "|:---------|:------|")
for (k, v) in candidates
println(io, "| $k | $(join(v)) |")
end
end
print_md_table(candidates) = print_md_table(stdout, candidates)
# Apply it on LinearAlgebra.jl
using LinearAlgebra
candidates = wjb_candidates(LinearAlgebra)
print_md_table(candidates) which outputs
|
Running this on Julia Base returns:
|
Some suggestions I like:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Glyphy.jl could be used to run through all Julia Base functions and automatically generate entries for the
func_to_emojis
Dictionary.Proof of concept:
The text was updated successfully, but these errors were encountered: