<div class="markdown">
<p dir="auto">On 16 May 2014, at 14:22, Ken Snyder wrote:</p>
<blockquote>
<p dir="auto">As I don't really know *ruby *at all the second option would be hard<br>
without an example.</p>
</blockquote>
<p dir="auto">I pointed you to two examples… but you can also write it in PHP (which from the request, I assume you know).</p>
<p dir="auto">Create a new command and set input to ‘Document’, output format to ‘Snippet’, and then write a command a la:</p>
<pre><code>#!/usr/bin/php
<?php
$namespace = NULL;
$document = file_get_contents('php://stdin');
if(preg_match('/^\s*namespace (.+);/m', $document, $matches))
$namespace = $matches[1];
switch($namespace) {
case 'foo':
echo "Documentation for $\{1:foo}…\n";
break;
case 'bar':
echo "Documentation for $\{1:bar}…\n";
break;
default:
echo "Documentation for $\{1:unknown}…\n";
break;
}
</code></pre>
<blockquote>
<p dir="auto">I am gravitating to your first option but I'm not sure<br>
what's involved in creating the namespace scope […]</p>
</blockquote>
<p dir="auto">You would have to create a grammar rule for the PHP grammar like this:</p>
<pre><code>{ name = 'meta.namespace.$1.php';
begin = '\bnamespace ([A-Za-z\\]+)';
end = '\z';
patterns = ( { include = '$self'; } );
},
</code></pre>
<p dir="auto">This should make the scope contain ‘meta.namespace.LG\API.php’ when the caret is below the namespace directive (declaring that namespace).</p>
<p dir="auto">Given the complexity of the PHP grammar (it’s written as injections for the HTML grammar), I’d only suggest this to people who are experienced with TextMate language grammars.</p>
</div>