Testing the use of a "diff" view for some code samples #7455

Closed
wants to merge 5 commits into
from

Projects

None yet

3 participants

@javiereguiluz
Member

@weaverryan pointed out that some docs use the diff view for code samples (e.g. https://webpack.js.org/guides/code-splitting-css/#using-extracttextwebpackplugin) This is a test to see if this could work for us too. If it works, it'd be used selectively and only when it really makes sense.

@javiereguiluz javiereguiluz changed the base branch to symfony:2.7 from symfony:master Feb 8, 2017
@javiereguiluz javiereguiluz Testing the use of a "diff" view for some code samples
c8316d2
components/dependency_injection.rst
$container
->register('mailer', 'Mailer')
- ->addArgument('%mailer.transport%');
++ ->addArgument('%mailer.transport%');
@lyrixx
lyrixx Feb 8, 2017 edited Member

the (php) diff mean in the previous version a semicolon was missing.
(same comment applies to other php diff)

javiereguiluz added some commits Feb 8, 2017
@javiereguiluz javiereguiluz Import the DiffLexer 2df634d
@javiereguiluz javiereguiluz Fixed the code syntax
3d0b2a1
@javiereguiluz
Member

This is how it looks by default (we could tweak the design a bit):

diff-code

See the rest at http://pr-7455-6snzjvi-6qmocelev2lwe.eu.platform.sh/components/dependency_injection.html


Personally I like this idea a lot because in some specific cases, the diff view is the best one when following an article from the start to the end.

The only negative points may be that:

  • It's a bit more difficult to go to a sample code and copy paste it without having to read all the previous code samples.
  • We lose the underlying language highlight (PHP in this example).
javiereguiluz added some commits Feb 8, 2017
@javiereguiluz javiereguiluz Testing the real diff format syntax
b295fd8
@javiereguiluz javiereguiluz Reverted the last change because it doesn't improve anything
20da87f
@javiereguiluz
Member

Closing it because this was just an experiment to see if it was going to work.

@wouterj
Member
wouterj commented Feb 10, 2017 edited

Ideally, we could support both in one syntax block (just like GitHub is doing recently in their diff views). I'm not 100% sure how to implement this as a Pygments lexer though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment