It shows you semantically relevant code context around the lines that match your search. This lets you see the loops, functions, methods, classes, etc that contain all the matching lines. You can get a sense of what's inside a matched class or function definition. It shows relevant code from every layer of the abstract syntax tree, above and below the matches.
https://github.com/paul-gauthier/grep-ast
Here's an example, which would also have colorized matches when run in the terminal:
django$ grep-ast ROOT_URLCONF
middleware/locale.py:
│from django.conf import settings
│from django.conf.urls.i18n import is_language_prefix_patterns_used
│from django.http import HttpResponseRedirect
⋮...
│class LocaleMiddleware(MiddlewareMixin):
│ """
│ Parse a request and decide what translation object to install in the
│ current thread context. This allows pages to be dynamically translated to
│ the language the user desires (if the language is available).
⋮...
│ def process_request(self, request):
▶ urlconf = getattr(request, "urlconf", settings.ROOT_URLCONF)
│ (
│ i18n_patterns_used,
│ prefixed_default_language,
│ ) = is_language_prefix_patterns_used(urlconf)
⋮...
│ if (
│ not language_from_path
│ and i18n_patterns_used
│ and not prefixed_default_language
│ ):
│ language = settings.LANGUAGE_CODE
│ translation.activate(language)
│ request.LANGUAGE_CODE = translation.get_language()
│
│ def process_response(self, request, response):
│ language = translation.get_language()
│ language_from_path = translation.get_language_from_path(request.path_info)
▶ urlconf = getattr(request, "urlconf", settings.ROOT_URLCONF)
│ (
⋮...
│ return response