-
Notifications
You must be signed in to change notification settings - Fork 25
Changed a bit the way PHP code is highlighted #41
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
Changed a bit the way PHP code is highlighted #41
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a shame the library is not configurable...
I've updated tests ... but I don't know why this error is happening: 1) SymfonyDocsBuilder\Tests\IntegrationTest::testParseUnitBlock with data set "literal" ('nodes/literal')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
</span>
</span>
{
- <span class="hljs-variable">$routes</span>
+ <span class="hljs-variable">
+ <span class="hljs-variable-other-marker">$</span>
+ routes
+ </span>
<span class="hljs-operator">-></span>
add(
<span class="hljs-string">'about_us'</span>
docs-builder/tests/IntegrationTest.php:142 |
@javiereguiluz that is probably fine and you should make the "expected" test cases reflect this. Comparing HTML is SO hard due to HTML that is really the "same" but appears different due to meaningless spacing changes. To try to help with that (though it's not perfect), we use a library |
Yes, I usually don't care about HTML spacing but in this case the generated HTML is inside a |
actually we're forcing the indenter to indent spans: thus it is normal that we get this result. "real" generated code looks like this: <pre class="hljs php"><span class="hljs-comment">// config/routes.php</span>
<span class="hljs-keyword">namespace</span> <span class="hljs-title">Symfony</span>\<span class="hljs-title">Component</span>\<span class="hljs-title">Routing</span>\<span class="hljs-title">Loader</span>\<span class="hljs-title">Configurator</span>;
<span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">(RoutingConfigurator <span class="hljs-variable"><span class="hljs-variable-other-marker">$</span>routes</span>)</span> </span>{
<span class="hljs-variable"><span class="hljs-variable-other-marker">$</span>routes</span><span class="hljs-operator">-></span>add(<span class="hljs-string">'about_us'</span>, [<span class="hljs-string">'nl'</span> => <span class="hljs-string">'/over-ons'</span>, <span class="hljs-string">'en'</span> => <span class="hljs-string">'/about-us'</span>])
<span class="hljs-operator">-></span>controller(<span class="hljs-string">'App\Controller\CompanyController::about'</span>);
};</pre> so this is a false negative. We can create our expectation based on the result of the indenter, because we know it's ok, it sounds a bit like fragile test. |
fd82211
to
d2e8890
Compare
97d3c2b
to
4e4bbd0
Compare
This is an example of the endless possibilities that having a PHP-based docs builder brings to us. We can easily change or update anything.
For example, I want to highlight code in the same way that GitHub does ... which requires showing a different color for the
$
of the PHP variable names. The current highlighter doesn't support that:But thanks to this super simple change, it works now: