A follow-up to #1843034: Make Twig settings configurable, when debug is enabled, let's add our own custom debugging output as HTML comments wrapped around the template. The debugging output helps themers determine which template is being rendered, which theme suggestions are available and which theme /template suggestion has been selected for each piece of theme output.
Something like this:
<!-- THEME DEBUG -->
<!-- CALL: theme('node') -->
<!-- FILE NAME SUGGESTIONS:
* node--article.html.twig
* node--2.html.twig
x node.html.twig
-->
<!-- BEGIN OUTPUT from 'core/modules/node/templates/node.html.twig' -->
<article id="node-1" class="node node-article promoted view-mode-full clearfix" role="article" about="/node/1" typeof="sioc:Item foaf:Document">
<p>(content)</p>
</article>
<!-- END OUTPUT from 'core/modules/node/templates/node.html.twig' -->