Skip to content

CSS issue in rendered documentation with diff code #14472

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
jderusse opened this issue Oct 23, 2020 · 9 comments
Closed

CSS issue in rendered documentation with diff code #14472

jderusse opened this issue Oct 23, 2020 · 9 comments
Assignees
Labels

Comments

@jderusse
Copy link
Member

jderusse commented Oct 23, 2020

Hello,
The documentation on Symfony has a CSS bug in rendering diff.
This is more visible on the fast track https://symfony.com/doc/current/the-fast-track/en/6-controller.html#adding-an-easter-egg

The issue is the .highlight-diff .highlight>pre has a padding-left: 1.5em
But the .highlight-diff .gd and .highlight-diff .gi (used to display - and +) have a padding-left: 1px + margin-left: -15px.

current rendering Expected
symfony com_doc_current_the-fast-track_en_6-controller html (1) symfony com_doc_current_the-fast-track_en_6-controller html

Maybe this is because the documentation indent diff with spaces (https://github.com/symfony/symfony-docs/blame/5.x/http_cache.rst#L98-L99) ?
But the render is not perfect
Screenshot from 2020-10-23 18-32-29

From my tests, using a margin: -1.2em; pading: 0 but maybe it vary on browser and OS?

@OskarStark
Copy link
Contributor

Thank you Jérémy, I assigned this issue to Javier 👍

@javiereguiluz
Copy link
Member

javiereguiluz commented Oct 29, 2020

The problem, as usual with Sphinx, is that if we fix this, we break other things. Check out for example the diff in this page: https://symfony.com/doc/current/page_creation.html#annotation-routes

Here's the comparison of the current CSS and the result of removing the -15px left margin:

Current style Removing the -15px left margin
image image

The problem is that the + and - markers need to be in the margin of the code block ... otherwise all the code listings break. This works for most of the code blocks, but that one from the Fast Track book is not working. I can't find out why.

@wouterj
Copy link
Member

wouterj commented Oct 29, 2020

@javiereguiluz I think it's because we incorrectly indent the code in the Symfony docs. Each line that doesn't start with + or - should start with 2 spaces:

bad

.. code-block:: diff

    // src/Controller/LuckyController.php

    // ...
    + use Symfony\Component\Routing\Annotation\Route;

    class LuckyController
    {
    +     /**
    +      * @Route("/lucky/number")
    +      */
        public function number()
        {
            // this looks exactly the same
        }
    }

correct

.. code-block:: diff

      // src/Controller/LuckyController.php

      // ...
    + use Symfony\Component\Routing\Annotation\Route;

      class LuckyController
      {
    +     /**
    +      * @Route("/lucky/number")
    +      */
          public function number()
          {
              // this looks exactly the same
          }
      }

@javiereguiluz
Copy link
Member

Oh no! All our diffs are wrong? It will take a lot of time to fix everything from 4.4 to 5.x and upmerge and fix all conflicts. 😢

@wouterj
Copy link
Member

wouterj commented Oct 29, 2020

@javiereguiluz I'll check this weekend if I can (a) write a DOCtor rule and (b) can automate the fix. If that doesn't take much time, we can fix it quickly.

@jderusse
Copy link
Member Author

I wonder if this is solvable... In the diff format, the not-changed line should start with a space. In that case, I wonder if Sphinx is able to detect the extra space from the indentation?.

ie:

.. code-block:: diff
·····not change <= is it a 5 spaces indentation? or a 4 space indentation + a line starting with space.
····-Delete
····+Add

@wouterj
Copy link
Member

wouterj commented Oct 29, 2020

@jderusse good point! I think this is why all diffs normally should start with a --- ... / +++ ... line (see the examples you posted). The first line determines the level of indent for the complete next block.

@javiereguiluz
Copy link
Member

What could we do here? Is this solvable in an automated way? Thanks!

@javiereguiluz
Copy link
Member

Closing as fixed by #15009.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants