Skip to content
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

ENH: Configurable highlight style #38

Merged
merged 4 commits into from Feb 25, 2019

Conversation

2 participants
@KyleKing
Copy link
Contributor

commented Feb 24, 2019

Fixes #34


I'd be happy to undo any (hopefully not all 😄 ) of these changes, so let me know if you want to implement 1, 3, and 5 but not 2 and 4, etc. The four main changes are listed below and shown in side-by-side screenshot comparisons below:

  1. Implement Atom One Light Highlight.js style (other alternatives could be Foundation, Github Gist, A 11 Y Light, or others from https://highlightjs.org/static/demo/). This directly addresses #34
  2. Preserve newlines from source code docstrings with white-space: pre-wrap;. At work, we have a compact docstring style where the newlines need to be preserved in the documentation. See discussion from pdoc: pdoc/179#comment. I think keeping the newlines is more consistent with how the comments were written in a text editor, but I'm open to dropping this change
  3. Highlight the entire click region for SOURCE CODE with the same background color as the hljs style (and add a small amount of padding) (background-color: #fafafa; /* Match HLJS backgd */)
  4. Shrink the code text to 12px so it fits more compactly for easier review
  5. Remove the blue selection box when clicking the SOURCE CODE element (outline: none !important;)

Screenshots

Each example shows all of the proposed changes, but I call-out specific changes for each example. Generated with:

  1. pip install beautifulsoup4
  2. pdoc bs4 --http localhost:8000

Example 1

Proposed

screen shot 2019-02-24 at 05 53 04

Current

screen shot 2019-02-24 at 05 55 30

Notes

2 - Examples 1 and 2 show how the pre-wrap change comes into play causing the newlines from the source code to be preserved

5 - Because of cursor: pointer;, when you click SOURCE CODE, the browser will momentary highlight the div. In the proposed version, outline: none !important; prevents the blue highlight from appearing on click (focus)

Example 2

Proposed

screen shot 2019-02-24 at 06 28 58

Current

screen shot 2019-02-24 at 06 30 11

Notes

2 - See how the pre-wrap change comes into play causing the newlines from the source code to be preserved (decode() and handle_starttag())

3 - The clickable region for source code is lightly highlighted

Example 3

Proposed

screen shot 2019-02-24 at 05 52 14

Current

screen shot 2019-02-24 at 05 58 26

Notes

1,4 - The source code variable and built-ins are more clearly highlighted and the code better fits within the height-limited section

@kernc

This comment has been minimized.

Copy link
Contributor

commented Feb 24, 2019

  1. Implement Atom One Light Highlight.js style (other alternatives could be Foundation, Github Gist, A 11 Y Light, or others from https://highlightjs.org/static/demo/). This directly addresses #34

Bikeshedding. Imho #34 (comment) is a better way to address #34.

  1. Preserve newlines from source code docstrings with white-space: pre-wrap;. At work, we have a compact docstring style where the newlines need to be preserved in the documentation. See discussion from pdoc: pdoc/179#comment. I think keeping the newlines is more consistent with how the comments were written in a text editor, but I'm open to dropping this change

I'd prefer to drop it too. If you need this at work, you can use a custom head.mako file with contents such as:

<style>
  dd p {
    white-space: pre-wrap;
  }
</style>
  1. Highlight the entire click region for SOURCE CODE with the same background color as the hljs style (and add a small amount of padding) (background-color: #fafafa; /* Match HLJS backgd */)

I'm ok with this, but only when the details are expanded (open), i.e. on:

.source details[open] summary { background: ... }
  1. Shrink the code text to 12px so it fits more compactly for easier review

👍

  1. Remove the blue selection box when clicking the SOURCE CODE element (outline: none !important;)

The blue box is compliments of your chosen OS / widget toolkit. For me, the outline is far less conspicuous. See also: http://www.outlinenone.com. You can override CSS without overriding the rest of the HTML template by using the mentioned head.mako file.

@KyleKing KyleKing force-pushed the KyleKing:dev/CSS-Improvements branch 2 times, most recently from d04081a to 26d1a9d Feb 25, 2019

@KyleKing

This comment has been minimized.

Copy link
Contributor Author

commented Feb 25, 2019

Thanks for the feedback. I dropped 2,3,5 and kept 4 (12 px code).
I pushed new changes to support an hljs_stylename in config.mako that keeps github as the default. Let me know if you like that change

Diff: https://github.com/pdoc3/pdoc/pull/38/files

@kernc

kernc approved these changes Feb 25, 2019

Show resolved Hide resolved pdoc/templates/config.mako Outdated
Show resolved Hide resolved pdoc/templates/config.mako Outdated

@kernc kernc changed the title Refac: Atom One Light hljs style & css tweaks ENH: Configurable highlight style Feb 25, 2019

@kernc kernc added this to the 0.6.0 milestone Feb 25, 2019

@KyleKing

This comment has been minimized.

Copy link
Contributor Author

commented Feb 25, 2019

I made the changes!

@kernc

This comment has been minimized.

Copy link
Contributor

commented Feb 25, 2019

Thanks!

@kernc kernc merged commit 5c3c8b1 into pdoc3:master Feb 25, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@KyleKing KyleKing deleted the KyleKing:dev/CSS-Improvements branch Feb 26, 2019

@kernc kernc modified the milestones: 0.6.0, 0.5.3 Mar 5, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.