<p dir="auto">In 1.6, stack traces got syntax highlighting in the REPL, but <code class="notranslate">methods</code> did not.<br>
Syntax highlighting would help with readability. Presumably the code can be reused.</p>
<p dir="auto">Hello!</p>
<p dir="auto">I love being able to see all the various implement methods, or methods using a certain type in Julia.<br>
However, I didn't find it easy to find what I was looking for at a glance. Particularly for functions with many (tens-hundreds) of implementations. So, I've tried adding a bit of colour. I've found it really helpful, and think it would be good if something like it were the default.</p>
<p dir="auto">Happy to make a PR, or just see my work used.</p>
<h3 dir="auto">Example</h3>
<p dir="auto">Current output for <code class="notranslate">methods(sum)</code></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/20903656/119236490-4bf1d700-bb6a-11eb-9ed4-27ea55d7baef.png"><img src="https://user-images.githubusercontent.com/20903656/119236490-4bf1d700-bb6a-11eb-9ed4-27ea55d7baef.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">My output for <code class="notranslate">methods(sum)</code></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/20903656/119236502-59a75c80-bb6a-11eb-844d-aff9cb0f9c14.png"><img src="https://user-images.githubusercontent.com/20903656/119236502-59a75c80-bb6a-11eb-844d-aff9cb0f9c14.png" alt="image" style="max-width: 100%;"></a></p>
<h3 dir="auto">Code</h3>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function Base.show(io::IO, m::Method)
    tv, decls, file, line = Base.arg_decl_parts(m)
    sig = Base.unwrap_unionall(m.sig)
    if sig === Tuple
        # Builtin
        print(io, m.name, &quot;(...) in &quot;, m.module)
        return
    end
    printstyled(io, decls[1][2]; color=:blue)
    print(io, &quot;(&quot;)
    for (d, i) in zip(decls[2:end], 2:length(decls))
        if isempty(d[2])
            printstyled(io, d[1]; color=:magenta)
        else
            printstyled(io, d[1]; color=:magenta)
            typespec = split(d[2], &quot;{&quot;; limit=2)
            if length(typespec) == 1
                printstyled(io, &quot;::&quot;, d[2]; color=:yellow)
            else
                printstyled(io, &quot;::&quot;, typespec[1]; color=:yellow)
                printstyled(io, &quot;{&quot;, typespec[2]; color=247)
            end
        end
        if i &lt; length(decls)
            printstyled(io, &quot;, &quot;)
        end
    end
    kwargs = Base.kwarg_decl(m)
    if !isempty(kwargs)
        printstyled(io, &quot;; &quot;; bold=true)
        for (k, i) in zip(kwargs, 1:length(kwargs))
            printstyled(io, Base.sym_to_string(k); color=:magenta)
            if i &lt; length(kwargs)
                printstyled(io, &quot;, &quot;)
            end
        end
    end
    print(io, &quot;)&quot;)
    Base.show_method_params(io, tv)
    printstyled(io, &quot; in &quot;; color=:light_black)
    printstyled(io, m.module; color=:light_red)
    if line &gt; 0
        file, line = Base.updated_methodloc(m)
        printstyled(io, &quot; at &quot;; color=:light_black)
        printstyled(io, file; color=:green)
        printstyled(io, &quot;:&quot;, line)
    end
end

function Base.show_method_list_header(io::IO, ms::Base.MethodList, namefmt::Function)
    mt = ms.mt
    name = mt.name
    hasname = isdefined(mt.module, name) &amp;&amp;
              typeof(getfield(mt.module, name)) &lt;: Function
    n = length(ms)
    if mt.module === Core &amp;&amp; n == 0 &amp;&amp; mt.defs === nothing &amp;&amp; mt.cache !== nothing
        # try to detect Builtin
        print(io, &quot;# built-in function; no methods&quot;)
    else
        printstyled(io, &quot;# &quot;; color=:light_black)
        printstyled(io, n; color=:cyan, bold=true)
        print(io, &quot; &quot;, n==1 ? &quot;method&quot; : &quot;methods&quot;)
        sname = string(name)
        if hasname
            what = startswith(sname, '@') ? &quot;macro&quot; : &quot;generic function&quot;
            print(io, &quot; for &quot;, what, &quot; &quot;)
            printstyled(io, sname; color=:blue)
        elseif '#' in sname
            print(io, &quot; for anonymous function &quot;, namefmt(sname))
        elseif mt === Base._TYPE_NAME.mt
            print(io, &quot; for type constructor&quot;)
        end
        print(io, &quot;:&quot;)
    end
end"><pre class="notranslate"><span class="pl-k">function</span> Base<span class="pl-k">.</span><span class="pl-en">show</span>(io<span class="pl-k">::</span><span class="pl-c1">IO</span>, m<span class="pl-k">::</span><span class="pl-c1">Method</span>)
    tv, decls, file, line <span class="pl-k">=</span> Base<span class="pl-k">.</span><span class="pl-c1">arg_decl_parts</span>(m)
    sig <span class="pl-k">=</span> Base<span class="pl-k">.</span><span class="pl-c1">unwrap_unionall</span>(m<span class="pl-k">.</span>sig)
    <span class="pl-k">if</span> sig <span class="pl-k">===</span> Tuple
        <span class="pl-c"><span class="pl-c">#</span> Builtin</span>
        <span class="pl-c1">print</span>(io, m<span class="pl-k">.</span>name, <span class="pl-s"><span class="pl-pds">"</span>(...) in <span class="pl-pds">"</span></span>, m<span class="pl-k">.</span>module)
        <span class="pl-k">return</span>
    <span class="pl-k">end</span>
    <span class="pl-c1">printstyled</span>(io, decls[<span class="pl-c1">1</span>][<span class="pl-c1">2</span>]; color<span class="pl-k">=</span><span class="pl-c1">:blue</span>)
    <span class="pl-c1">print</span>(io, <span class="pl-s"><span class="pl-pds">"</span>(<span class="pl-pds">"</span></span>)
    <span class="pl-k">for</span> (d, i) <span class="pl-k">in</span> <span class="pl-c1">zip</span>(decls[<span class="pl-c1">2</span><span class="pl-k">:</span><span class="pl-c1">end</span>], <span class="pl-c1">2</span><span class="pl-k">:</span><span class="pl-c1">length</span>(decls))
        <span class="pl-k">if</span> <span class="pl-c1">isempty</span>(d[<span class="pl-c1">2</span>])
            <span class="pl-c1">printstyled</span>(io, d[<span class="pl-c1">1</span>]; color<span class="pl-k">=</span><span class="pl-c1">:magenta</span>)
        <span class="pl-k">else</span>
            <span class="pl-c1">printstyled</span>(io, d[<span class="pl-c1">1</span>]; color<span class="pl-k">=</span><span class="pl-c1">:magenta</span>)
            typespec <span class="pl-k">=</span> <span class="pl-c1">split</span>(d[<span class="pl-c1">2</span>], <span class="pl-s"><span class="pl-pds">"</span>{<span class="pl-pds">"</span></span>; limit<span class="pl-k">=</span><span class="pl-c1">2</span>)
            <span class="pl-k">if</span> <span class="pl-c1">length</span>(typespec) <span class="pl-k">==</span> <span class="pl-c1">1</span>
                <span class="pl-c1">printstyled</span>(io, <span class="pl-s"><span class="pl-pds">"</span>::<span class="pl-pds">"</span></span>, d[<span class="pl-c1">2</span>]; color<span class="pl-k">=</span><span class="pl-c1">:yellow</span>)
            <span class="pl-k">else</span>
                <span class="pl-c1">printstyled</span>(io, <span class="pl-s"><span class="pl-pds">"</span>::<span class="pl-pds">"</span></span>, typespec[<span class="pl-c1">1</span>]; color<span class="pl-k">=</span><span class="pl-c1">:yellow</span>)
                <span class="pl-c1">printstyled</span>(io, <span class="pl-s"><span class="pl-pds">"</span>{<span class="pl-pds">"</span></span>, typespec[<span class="pl-c1">2</span>]; color<span class="pl-k">=</span><span class="pl-c1">247</span>)
            <span class="pl-k">end</span>
        <span class="pl-k">end</span>
        <span class="pl-k">if</span> i <span class="pl-k">&lt;</span> <span class="pl-c1">length</span>(decls)
            <span class="pl-c1">printstyled</span>(io, <span class="pl-s"><span class="pl-pds">"</span>, <span class="pl-pds">"</span></span>)
        <span class="pl-k">end</span>
    <span class="pl-k">end</span>
    kwargs <span class="pl-k">=</span> Base<span class="pl-k">.</span><span class="pl-c1">kwarg_decl</span>(m)
    <span class="pl-k">if</span> <span class="pl-k">!</span><span class="pl-c1">isempty</span>(kwargs)
        <span class="pl-c1">printstyled</span>(io, <span class="pl-s"><span class="pl-pds">"</span>; <span class="pl-pds">"</span></span>; bold<span class="pl-k">=</span><span class="pl-c1">true</span>)
        <span class="pl-k">for</span> (k, i) <span class="pl-k">in</span> <span class="pl-c1">zip</span>(kwargs, <span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">length</span>(kwargs))
            <span class="pl-c1">printstyled</span>(io, Base<span class="pl-k">.</span><span class="pl-c1">sym_to_string</span>(k); color<span class="pl-k">=</span><span class="pl-c1">:magenta</span>)
            <span class="pl-k">if</span> i <span class="pl-k">&lt;</span> <span class="pl-c1">length</span>(kwargs)
                <span class="pl-c1">printstyled</span>(io, <span class="pl-s"><span class="pl-pds">"</span>, <span class="pl-pds">"</span></span>)
            <span class="pl-k">end</span>
        <span class="pl-k">end</span>
    <span class="pl-k">end</span>
    <span class="pl-c1">print</span>(io, <span class="pl-s"><span class="pl-pds">"</span>)<span class="pl-pds">"</span></span>)
    Base<span class="pl-k">.</span><span class="pl-c1">show_method_params</span>(io, tv)
    <span class="pl-c1">printstyled</span>(io, <span class="pl-s"><span class="pl-pds">"</span> in <span class="pl-pds">"</span></span>; color<span class="pl-k">=</span><span class="pl-c1">:light_black</span>)
    <span class="pl-c1">printstyled</span>(io, m<span class="pl-k">.</span>module; color<span class="pl-k">=</span><span class="pl-c1">:light_red</span>)
    <span class="pl-k">if</span> line <span class="pl-k">&gt;</span> <span class="pl-c1">0</span>
        file, line <span class="pl-k">=</span> Base<span class="pl-k">.</span><span class="pl-c1">updated_methodloc</span>(m)
        <span class="pl-c1">printstyled</span>(io, <span class="pl-s"><span class="pl-pds">"</span> at <span class="pl-pds">"</span></span>; color<span class="pl-k">=</span><span class="pl-c1">:light_black</span>)
        <span class="pl-c1">printstyled</span>(io, file; color<span class="pl-k">=</span><span class="pl-c1">:green</span>)
        <span class="pl-c1">printstyled</span>(io, <span class="pl-s"><span class="pl-pds">"</span>:<span class="pl-pds">"</span></span>, line)
    <span class="pl-k">end</span>
<span class="pl-k">end</span>

<span class="pl-k">function</span> Base<span class="pl-k">.</span><span class="pl-en">show_method_list_header</span>(io<span class="pl-k">::</span><span class="pl-c1">IO</span>, ms<span class="pl-k">::</span><span class="pl-c1">Base.MethodList</span>, namefmt<span class="pl-k">::</span><span class="pl-c1">Function</span>)
    mt <span class="pl-k">=</span> ms<span class="pl-k">.</span>mt
    name <span class="pl-k">=</span> mt<span class="pl-k">.</span>name
    hasname <span class="pl-k">=</span> <span class="pl-c1">isdefined</span>(mt<span class="pl-k">.</span>module, name) <span class="pl-k">&amp;&amp;</span>
              <span class="pl-c1">typeof</span>(<span class="pl-c1">getfield</span>(mt<span class="pl-k">.</span>module, name)) <span class="pl-k">&lt;:</span> <span class="pl-c1">Function</span>
    n <span class="pl-k">=</span> <span class="pl-c1">length</span>(ms)
    <span class="pl-k">if</span> mt<span class="pl-k">.</span>module <span class="pl-k">===</span> Core <span class="pl-k">&amp;&amp;</span> n <span class="pl-k">==</span> <span class="pl-c1">0</span> <span class="pl-k">&amp;&amp;</span> mt<span class="pl-k">.</span>defs <span class="pl-k">===</span> <span class="pl-c1">nothing</span> <span class="pl-k">&amp;&amp;</span> mt<span class="pl-k">.</span>cache <span class="pl-k">!==</span> <span class="pl-c1">nothing</span>
        <span class="pl-c"><span class="pl-c">#</span> try to detect Builtin</span>
        <span class="pl-c1">print</span>(io, <span class="pl-s"><span class="pl-pds">"</span># built-in function; no methods<span class="pl-pds">"</span></span>)
    <span class="pl-k">else</span>
        <span class="pl-c1">printstyled</span>(io, <span class="pl-s"><span class="pl-pds">"</span># <span class="pl-pds">"</span></span>; color<span class="pl-k">=</span><span class="pl-c1">:light_black</span>)
        <span class="pl-c1">printstyled</span>(io, n; color<span class="pl-k">=</span><span class="pl-c1">:cyan</span>, bold<span class="pl-k">=</span><span class="pl-c1">true</span>)
        <span class="pl-c1">print</span>(io, <span class="pl-s"><span class="pl-pds">"</span> <span class="pl-pds">"</span></span>, n<span class="pl-k">==</span><span class="pl-c1">1</span> <span class="pl-k">?</span> <span class="pl-s"><span class="pl-pds">"</span>method<span class="pl-pds">"</span></span> <span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>methods<span class="pl-pds">"</span></span>)
        sname <span class="pl-k">=</span> <span class="pl-c1">string</span>(name)
        <span class="pl-k">if</span> hasname
            what <span class="pl-k">=</span> <span class="pl-c1">startswith</span>(sname, <span class="pl-s"><span class="pl-pds">'</span>@<span class="pl-pds">'</span></span>) <span class="pl-k">?</span> <span class="pl-s"><span class="pl-pds">"</span>macro<span class="pl-pds">"</span></span> <span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>generic function<span class="pl-pds">"</span></span>
            <span class="pl-c1">print</span>(io, <span class="pl-s"><span class="pl-pds">"</span> for <span class="pl-pds">"</span></span>, what, <span class="pl-s"><span class="pl-pds">"</span> <span class="pl-pds">"</span></span>)
            <span class="pl-c1">printstyled</span>(io, sname; color<span class="pl-k">=</span><span class="pl-c1">:blue</span>)
        <span class="pl-k">elseif</span> <span class="pl-s"><span class="pl-pds">'</span>#<span class="pl-pds">'</span></span> <span class="pl-k">in</span> sname
            <span class="pl-c1">print</span>(io, <span class="pl-s"><span class="pl-pds">"</span> for anonymous function <span class="pl-pds">"</span></span>, <span class="pl-c1">namefmt</span>(sname))
        <span class="pl-k">elseif</span> mt <span class="pl-k">===</span> Base<span class="pl-k">.</span>_TYPE_NAME<span class="pl-k">.</span>mt
            <span class="pl-c1">print</span>(io, <span class="pl-s"><span class="pl-pds">"</span> for type constructor<span class="pl-pds">"</span></span>)
        <span class="pl-k">end</span>
        <span class="pl-c1">print</span>(io, <span class="pl-s"><span class="pl-pds">"</span>:<span class="pl-pds">"</span></span>)
    <span class="pl-k">end</span>
<span class="pl-k">end</span></pre></div>