Skip to content

Fix indentation of diff code blocks #15009

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 2 commits into from
Closed

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Feb 20, 2021

This continues #14971, the difference:

  • The script is run on 4.4 instead
  • Keep the starting file line comment at the original indentation (Sphinx takes the first line of the example as the initial indentation)
  • If the file is JSON, there is no file line comment, in these cases use the little :dedent: 0 "hack" (this changes nothing, but makes sure Sphinx knows the indentation).

@carsonbot carsonbot added this to the 4.4 milestone Feb 20, 2021
@wouterj wouterj mentioned this pull request Feb 20, 2021
Copy link
Member

@jderusse jderusse left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

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

Nice work! Thanks Wouter for taking the time to do this and thanks Jérémy for being the original creator of the script and the proposal.

@wouterj
Copy link
Member Author

wouterj commented Feb 22, 2021

Alright, so I found out that Sphinx doesn't use the first line of a code example. Somehow, Sphinx/reStructuredText captures a whole indented block and uses the left most line as the indentation. (fyi, seems like the PHP doc builder doesn't capture diff blocks correctly at all)

So I'll update the script and this PR to instead indent everything properly and remove the :dedent: 0.

@wouterj wouterj marked this pull request as draft February 22, 2021 11:55
@wouterj wouterj marked this pull request as ready for review February 23, 2021 20:27
@wouterj
Copy link
Member Author

wouterj commented Feb 23, 2021

I've updated the script and this PR. No crazy indentation magic anymore, Sphinx just calculates the indent level completely correct at any times.

@javiereguiluz this requires the symfony.com to remove margin-left: -15px; on .gd and .gi. Are you able to create a PR for this and ping me here whenever it's merged (so ready for the deploy)? That way, we can somewhat coordinate doing it at least at the same day.

@jderusse
Copy link
Member

That's awesome. Thanks you very much @wouterj for taking care of this PR ❤️

@javiereguiluz
Copy link
Member

@wouter I'll send you some DM on Slack when this is merged/deployed. Thanks.

wouterj added a commit that referenced this pull request Mar 2, 2021
wouterj added a commit that referenced this pull request Mar 2, 2021
* 4.4:
  [#15009] Fix inconsistent diff examples
wouterj added a commit that referenced this pull request Mar 2, 2021
* 5.2:
  [#15009] Fix inconsistent diff examples
wouterj added a commit to wouterj/symfony-docs that referenced this pull request Mar 2, 2021
wouterj added a commit to wouterj/symfony-docs that referenced this pull request Mar 2, 2021
* 5.2:
  [symfony#15009] Fix indentation of all diff code blocks
wouterj added a commit that referenced this pull request Mar 2, 2021
* 4.4:
  [#15009] Fix indentation of all diff code blocks
@wouterj
Copy link
Member Author

wouterj commented Mar 2, 2021

Thanks @jderusse and @javiereguiluz. This has now been merged in all versions. The tool made it very easy to counter the merge conflicts between 4.4 and 5.2 💚

@wouterj wouterj closed this Mar 2, 2021
@wouterj wouterj deleted the fix-diff branch March 2, 2021 12:55
@jderusse
Copy link
Member

jderusse commented Mar 2, 2021

Thank you @wouterj

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.

4 participants