Skip to content

Conversation

@lucyleeow
Copy link
Contributor

@lucyleeow lucyleeow commented Jan 9, 2020

closes #544

Added CSS for pandas df, copied from nbsphinx (suggested here: #544 (comment)).

I can include a border:
bord

Or remove the black border:
nobord

The latter makes it look exactly like in jupyter notebook:
image

Note that rows become highlighted in light blue on hover, just like in notebooks.

@larsoner
Copy link
Contributor

larsoner commented Jan 9, 2020

I like the second one (no border)

@lucyleeow
Copy link
Contributor Author

lucyleeow commented Jan 9, 2020

I'm having trouble removing the border and I think it is because of the inline border="1" of the _repr_html_:

<table border="1" class="dataframe">      <-----here
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>a</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>1</td>
    </tr>
    <tr>
      <th>1</th>
      <td>2</td>
    </tr>
    <tr>
      <th>2</th>
      <td>3</td>
    </tr>
  </tbody>
</table>

I can make it go away by adding border: none in inspect element.
Screenshot_2020-01-09_16-23-44

But border: none is already in the CSS I added...it just doesn't appear in the theme.css file after building.

@lucyleeow
Copy link
Contributor Author

Manually adding border: none to doc/_build/html/_static/css/theme.css file works - but how is this theme.css file created?

@larsoner
Copy link
Contributor

larsoner commented Jan 9, 2020

doc/_build/html/_static/css/theme.css

This probably comes from sphinx_rtd_theme so we can't easily modify it.

One we can modify is doc/_static/theme_override.css, which gets copied to doc/_build/html/_static/theme_override.css, but this will only affect our (SG's) particular doc build, not the doc build of projects that use SG, so I wouldn't look at that one.

If you want to modify it for all downstream projects (and SG's doc build, too), change sphinx_gallery/_static/gallery.css which ends up being copied to doc/_build/html/_static/gallery.css. So for testing you can see if changing doc/_build/html/_static/gallery.css (maybe with a !important if absolutely necessary) fixes things, and if it does, modify sphinx_gallery/_static/gallery.css the same way.

@codecov-io
Copy link

codecov-io commented Jan 9, 2020

Codecov Report

Merging #590 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #590      +/-   ##
==========================================
+ Coverage   97.63%   97.63%   +<.01%     
==========================================
  Files          29       29              
  Lines        3000     3002       +2     
==========================================
+ Hits         2929     2931       +2     
  Misses         71       71
Impacted Files Coverage Δ
sphinx_gallery/tests/test_full.py 100% <0%> (ø) ⬆️
sphinx_gallery/docs_resolv.py 89.27% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4cee8a0...338cb32. Read the comment docs.

@lucyleeow
Copy link
Contributor Author

lucyleeow commented Jan 9, 2020

I was adding the CSS to sphinx_gallery/_static/gallery.css but I guess it was over-ridden/ignored for some reason?

Anyway adding !important to border: none in sphinx_gallery/_static/gallery.css worked.

@lucyleeow lucyleeow changed the title [WIP] [ENH] Add css for pandas df [MRG] [ENH] Add css for pandas df Jan 9, 2020
@larsoner
Copy link
Contributor

@choldgraf
Copy link
Contributor

FWIW I really like the change, +1 once the border is fixed :-)

@lucyleeow
Copy link
Contributor Author

Got it working, see here.

@larsoner larsoner merged commit f945ce2 into sphinx-gallery:master Jan 13, 2020
@larsoner
Copy link
Contributor

Thanks @lucyleeow !

@lucyleeow lucyleeow deleted the IS/544 branch April 6, 2020 13:35
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.

ENH Add CSS for pandas dataframe

4 participants