Skip to content

Conversation

@drammock
Copy link
Member

@drammock drammock commented Nov 16, 2022

partially addresses #1052

  • fix our pygments overrides in __init__
  • change theme's pygments defaults to a11y-high-contrast-{dark|light}
  • test pygment theme selection
  • document what we're doing
  • update theme color palette to address text contrast issues -> subsequent PR
  • make our CIs test for text contrast issues -> subsequent PR

@trallard
Copy link
Collaborator

🎉 this looks great @drammock

"""
default_light_theme = "tango"
default_dark_theme = "monokai"
Overwrite pygments.css to allow dynamic light/dark switching.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would something like this work for all the Sphinx-based docs? I mean, adding this bit to allow for the dynamic switch?

If so I'd love to add this to the "mini-docs" of accessible-pygments

Copy link
Member Author

Choose a reason for hiding this comment

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

I think so? I think we adapted it from the Furo theme.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I confirm that I adapted it from Furo.

Copy link
Collaborator

@choldgraf choldgraf left a comment

Choose a reason for hiding this comment

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

This change looks good to me - could you add documentation about this in our user guide? I think we could add an Accessibility in this theme section to our Design and style section that could note the various accessibility-minded decisions that have been made here (such as the code blocks, and the default colors).

Also in the name of iteration I'd suggest scoping this PR to just the code blocks, and do the default colors in a follow up.

@12rambau
Copy link
Collaborator

Also in the name of iteration I'd suggest scoping this PR to just the code blocks, and do the default colors in a follow up.

@drammock could you then update the comment (avoid closing the issue) and the title ?

@drammock drammock changed the title make our colors more accessible use accessible code highlighting styles Nov 17, 2022
@drammock
Copy link
Member Author

This change looks good to me - could you add documentation about this in our user guide? I think we could add an Accessibility in this theme section to our Design and style section

done, though I put it on the "accessibility" page instead (seemed like the right place 😉).

Also in the name of iteration I'd suggest scoping this PR to just the code blocks, and do the default colors in a follow up.

done

could you then update the comment (avoid closing the issue) and the title ?

done, and CIs are happy. This one's ready from my end.

Copy link
Collaborator

@choldgraf choldgraf left a comment

Choose a reason for hiding this comment

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

Looks great - thanks for this improvement @drammock and to the QS folks for building the accessible pygments repository!

@choldgraf choldgraf changed the title use accessible code highlighting styles ENH: Accessible code highlighting styles Nov 19, 2022
@choldgraf choldgraf merged commit 3d37fc9 into pydata:main Nov 19, 2022
@drammock drammock deleted the a11y-colors branch November 30, 2022 17:19
@rsokl
Copy link

rsokl commented Mar 8, 2023

Is there a configuration option available to revert back to the old light/dark default themes? Or perhaps can the accessibility themes be toggled?

@drammock
Copy link
Member Author

drammock commented Mar 8, 2023

Is there a configuration option available to revert back to the old light/dark default themes? Or perhaps can the accessibility themes be toggled?

to get the old defaults you can specify this in your conf.py file:

html_theme_options = {
    # ...other config vals...
    "pygment_light_style": "tango",
    "pygment_dark_style": "monokai",
}

see https://pydata-sphinx-theme.readthedocs.io/en/stable/user_guide/styling.html#configure-pygments-theme

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.

5 participants