Skip to content

Fix code-diff #14971

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

Closed
wants to merge 1 commit into from
Closed

Fix code-diff #14971

wants to merge 1 commit into from

Conversation

jderusse
Copy link
Member

Fixes #14472

To fix the code, I used an home made script https://gist.github.com/jderusse/a2f9275239f3b9204583fea52b314dc0 (I put in the _build directory and called `php ./_build/fix.php).

Note: I had to manually patch the setup/flex.rst and quick_tour/flex_recipes.rst because were malformated.

I know this is the wrong branch and this should be applied to previous versions. Please tell me ho you want to proceed.

@@ -55,17 +55,18 @@ changes can be made to any Symfony 3.4 or higher app:
#. Update ``.gitignore``:

.. code-block:: diff
:dedent: 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to set this in the config without the need to change all examples?

Copy link
Member Author

@jderusse jderusse Feb 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact we don't care about this flag, it just helps Sphinx to get the indentation.
Here are 2 identical exemples

.. code-block:: diff
    + added
      not changed
.. code-block:: diff
      added
    + not changed

In the first one, Sphinx is able to get that indentation of the bloc is 4. But in the second, is it 6 like suggested by the first line? or 4?
So we need something to help Sphinx to figure out the indentation of the bloc.

I would need Sphinx locally to test if this is really needed, maybe you can help me with that?

@javiereguiluz
Copy link
Member

This is really nice! We should merge this in 4.4 first. Then, I'm not sure about the "upmerging" process: merge 4.4 in 5.2 and then try to fix conflicts? or merge 4.4 in 5.2, ignore all changes and then re-run the command in 5.2?

That's why I'm not confident about merging this myself. Any volunteer? Thanks!

@jderusse
Copy link
Member Author

This is really nice! We should merge this in 4.4 first. Then, I'm not sure about the "upmerging" process: merge 4.4 in 5.2 and then try to fix conflicts? or merge 4.4 in 5.2, ignore all changes and then re-run the command in 5.2?

That's why I'm not confident about merging this myself. Any volunteer? Thanks!

beware, the CSS of the website have to be changed after this patch (today, it looks OK, because + and - does not have the same padding-left than the rest of the code).

And if we fix the CSS, all previous versions will be affected. :(

I can handle the merge, but don't have write permission on the repo.

We also have to find a solution for this #14971 (comment)

@wouterj
Copy link
Member

wouterj commented Feb 19, 2021

So you created a script that does this automatically (except from the 2 you mentioned)? If that's the case, I can manage the upmerge if you provide the script (no need to fix conflicts).

About the comment, as said in the issue, a real diff (and the diff's in the Fast Track book) start with this:

--- a/public/index.php
+++ b/public/index.php

I guess if we replace the file comment with this, it's all fixed. Imho, we can even just let the file comment start at indent = 0 (same column as + / -), as they aren't valid diff files anyway.

@jderusse
Copy link
Member Author

@wouterj thank you. The script is linked in the description of this PR.

Adding a +++/--- header fixes the issue, but can not be easily automated :-(

@wouterj
Copy link
Member

wouterj commented Feb 20, 2021

Sorry, I somehow missed the gist. We can automate it I think (we only need to run this script once, so no need to check if a diff is already patched previously): https://gist.github.com/wouterj/6bf693f097ed523a51e9ca6e7dc98c11

This script produces changes like this e.g.:

--- a/configuration/dot-env-changes.rst
+++ b/configuration/dot-env-changes.rst
@@ -61,15 +61,15 @@ changes can be made to any Symfony 3.4 or higher app:
    .. code-block:: diff

        # .gitignore
-       # ...
+         # ...

-       ###> symfony/framework-bundle ###
+         ###> symfony/framework-bundle ###
        - /.env
        + /.env.local
        + /.env.local.php
        + /.env.*.local

-       # ...
+         # ...

(a diff diff 🤯 )

This isn't a valid patch file, but we're missing the @@ line markings anyway. I think it's the most clear for our users (the a//b/ part can be quite confusing if you're not used to read diffs).

During the merge, I plan to discard the changes of the merge, run the tool again and commit merge. As it's all automated, there is no need to make a more detailed merge.

What do you think?

@jderusse
Copy link
Member Author

So we ignore the first meaningful line of the diff which should be a comment to the file.

Sounds like a plan 👍

@wouterj
Copy link
Member

wouterj commented Feb 20, 2021

Alright, I was very unsure on updating this PR. So I've started a new one with your script based on 4.4: #15009 . Please let me know if you agree with the changes there. We can take merging, up merging and fixing the CSS from there.

Thanks for building the script!

@wouterj wouterj closed this Feb 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CSS issue in rendered documentation with diff code
5 participants