Skip to content

integrated optional line numbering functionality#266

Closed
gerhard-boden wants to merge 34 commits intoleafo:masterfrom
gerhard-boden:develop
Closed

integrated optional line numbering functionality#266
gerhard-boden wants to merge 34 commits intoleafo:masterfrom
gerhard-boden:develop

Conversation

@gerhard-boden
Copy link

output the original SCSS line numbers within the compiled CSS file for better frontend debugging.

works great in combination with frontend debugging tools like https://addons.mozilla.org/de/firefox/addon/firecompass-for-firebug/

to activate this feature you need to call ->setLineNumbers(true) after creating a new instance of compiler.php

For full description see:
https://github.com/Screenchecker/scssphp/tree/develop#optional-output-scss-line-numbers

gerhard-boden and others added 30 commits January 17, 2015 00:23
…r easier frontend debugging

call "setLineNumbers(true)" when creating a new instance of the
compiler.php to output scss line numbers within the css file
for filepath output within line number commentary
* included scss files will now be considered (thanks to @handyface for
the hint)
* bugfix for scss functions in combination with line numbers
* less empty line numbers
* small test scss provided
* if, else, for, while and each won't get a line numbering comment
now we have a test to cover all scss test scenarios with integrated line
numbers
note:
Travis CI keeps failing 3 tests (for no apparent reason) but locally all
tests pass
note: maybe the reason for the Travis CI failures
since he keeps failing (differences on certain lines with CR and LF)
... since travis has now compiled the files himself and formatted the LF
and CR as he thinks it's correct for the assertions (finally)
since  \n is also used in other parts of the project.

this may solve the travis assertion issue
now you can also call the 'compile' method directly when using line
numbering (for more detailed information see readme)
better support for "map_get" in combination with curly braces
…r better frontend debugging.

works great in combination with frontend debugging tools like https://addons.mozilla.org/de/firefox/addon/firecompass-for-firebug/

to activate this feature you need to call ->setLineNumbers(true) after creating a new instance of compiler.php

For full description see:
https://github.com/Screenchecker/scssphp/tree/develop#optional-output-scss-line-numbers

latest update (10.6.2015)
* fixed test case issue
* better support for "map_get" in combination with curly braces
@robocoder
Copy link
Collaborator

It seems you weren't able to rebase and squash, so I opted to instead cherry-pick 2aab9e7 into the line-numbers-v2 branch as it seemed to have fewer merge conflicts for me to resolve.

https://github.com/leafo/scssphp/tree/line-numbers-v2

I'll finish reviewing the PR this week.

@gerhard-boden
Copy link
Author

That's odd, git reported "successfully rebased and updated" without any conflict or error, but you're right. For some reason all the commits (or at least most of them) are still there.
If you still need the commits squashed just say so and i'll look into it again.

The cherry pick strategy seems to be a good call, since there were only very minor changes since the first version of the "line-numbers" branch last week. Tests need to be rebuild of course, since the output will be different now.

@robocoder
Copy link
Collaborator

Seems to still have some edge cases, such as unexpected and/or missing line comments, e.g.,

Instead of the extra pass, maybe we could add hints to the Parser. I created an experiment-line-numbers branch to rough out this idea but it isn't without its own set of challenges:

  • line numbers are off
  • formatting: Nested adds an extra newline, while Expanded should add a newline
  • extra line comments with imports/partials

@gerhard-boden
Copy link
Author

The extra pass is indeed not the perfect solution. When I wrote the basic first version in a couple of hours I tried to interfere with the core scssphp parser as little as possible since I was looking for a quick solution. It's a more modular approach.

Like I said in the old PR the line comment output might not always be perfect, but in 99% of the real life cases the overhead is very low and the firebug debugger extension will get it right. Some scss input used for the test cases can't be described as realistic code (which is deliberate to cover a lot of scenarios of course).

Nonetheless, I welcome the new approach to integrate the line number functionality directly into the parser and I'm very happy to help. This would also be a great chance to integrate sourcemaps, since the basic approach would be the same. Or should we drop line numbers completely in favour of sourcemaps which would be a more elegant debugging solution?

update: on second thought i don't think that we can completely drop the line number debugging in favour of sourcemaps, since some people want to use the output as string(s) and not seperate file(s).

@robocoder
Copy link
Collaborator

Both approaches have their +/-. I agree this will probably set the stage for source maps. Let's tinker with this a bit.

@gerhard-boden
Copy link
Author

will the line-numbers-v2 branch stay a development branch in the meantime or will it still be merged into into the master branch until a better solution becomes available? Some people have been waiting for official debugging support for quite some time now and I think it would be a pity they would have to wait again just because of minor flaws.

Or will line-numbers-v2 still receive the latest updates like the master branch?

@robocoder
Copy link
Collaborator

I'm going to keep both branches updated until a decision is made on which to mainline. I've started looking at source maps support, so that will weigh in.

@gerhard-boden
Copy link
Author

That is awesome! I think it's worth mentioning that the line number branches will still receive the latest updates here: #88 (comment)

So people know that they can use it without having to use an older version of scssphp.

Source maps:
I already looked into it a couple of months ago, but i ran out of time.
I'm looking at my old code right now ... it was just a prototype approach (at best).
I used line numbered CSS output to generate a basic map output (not even in a separate file yet, but just as a JSON string for testing). So this approach would even require a third pass (not what we want)

But i guess it will be tricky knowing the exact line number for the final CSS file while parsing trough the SCSS code. Especially includes and functions will make things interesting.

@robocoder robocoder closed this Jun 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants