sphinx-copybutton icon indicating copy to clipboard operation
sphinx-copybutton copied to clipboard

Big copybutton the RTD Theme

Open tschinz opened this issue 5 years ago • 9 comments

How can I make the svg image smaller using the CSS? In case of the RTD Theme the button appears huge.

20200323_0802_ZELL

tschinz avatar Mar 23 '20 07:03 tschinz

holy moly! that is huge :-) I haven't seen that on the RTD theme before. Do you think you could try using the "master" branch and see if that fixes it? And if so, we can make a new release

choldgraf avatar Mar 23 '20 14:03 choldgraf

Well to add on each code cell that image would enlarge my content of the page drastically ;-) I've tried the master branch code from https://github.com/choldgraf/sphinx-copybutton/tree/master/sphinx_copybutton But then no button appears. I've also changed the icon in the conf.py with a smaller one, which helps ,but the location is still wrong. copybutton_image_path = 'img/copybutton.svg'

image

Like your css is not taken into consideration. I've also tried adding my own css but this has also no effect:

html_static_path = ['_static']

html_css_files = [
    'css/copybutton.css',
]
# or
html_context = {
  'cssfiles': ['_static/css/copybutton.css']
}

tschinz avatar Mar 23 '20 15:03 tschinz

hmmm - it is strange that no button appears when on master. I just tried out the sphinx_rtd_theme on my local master branch and it worked fine:

image

I'm not sure how to debug on your side, but you shouldn't need to manually add any extra CSS files yourself...maybe also make sure your Sphinx is updated?

choldgraf avatar Mar 26 '20 23:03 choldgraf

It was my error why the master had no button, I corrected it but got the same error as on the pip install version. In the mean time I also tried building without any extentions without luck. In the end I got it to work with the external css file. herafter my conf.py: https://github.com/tschinz/zawiki/blob/master/source/conf.py Thanks for your help

tschinz avatar Mar 27 '20 06:03 tschinz

FYI the RTD theme works fine for me: https://17-145482568-gh.circle-artifacts.com/0/html/intro/get_started.html#quick-installation

chrisjsewell avatar May 20 '20 09:05 chrisjsewell

The problem comes from extending the css to better handle the table width. There is this issue in the sphinx_rtd_theme repository. I copy the code from a comment fixing the issue, but generating the problem described in this issue:

/* _static/theme_overrides.css */
/* override table width restrictions */
.wy-table-responsive table td, .wy-table-responsive table th {
    white-space: normal;
}

.wy-table-responsive {
    margin-bottom: 24px;
    max-width: 100%;
    overflow: visible;
}
# conf.py
html_static_path = ['_static']

html_context = {
    'css_files': [
        '_static/theme_overrides.css',  # overrides for wide tables in RTD theme
        ],
    }

@chrisjsewell The link you posted does not work anymore.

swaldhoer avatar Jul 01 '20 05:07 swaldhoer

@choldgraf Did you have time to look into this issue based on my comment?

swaldhoer avatar Jul 11 '20 14:07 swaldhoer

I haven't had time - but I am more than happy to review a PR from somebody that both

  • Fixes this in the RTD theme
  • Doesn't break this in any other Sphinx theme

👍

choldgraf avatar Jul 11 '20 15:07 choldgraf

I don't know why and what has changed, but this problem no longer happens since

  • sphinx_rtd_theme 0.5.0
  • sphinx_copybutton 0.3.0

Edit: Just to document, that it really works: custom CSS from the issue I mentioned in https://github.com/executablebooks/sphinx-copybutton/issues/69#issuecomment-652201777: https://github.com/swaldhoer/native-lua/blob/a4d4f83fe16f2248b61d62ef740e6492a33869fd/docs/_static/custom.css and the documentation works fine: https://native-lua.readthedocs.io/en/latest/build.html

swaldhoer avatar Sep 06 '20 12:09 swaldhoer