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

All admonitions are red #1825

Closed
petsuter opened this issue Apr 1, 2015 · 15 comments
Closed

All admonitions are red #1825

petsuter opened this issue Apr 1, 2015 · 15 comments

Comments

@petsuter
Copy link
Contributor

petsuter commented Apr 1, 2015

Generic admonitions used to look just like normal text. Now they are all red.

This also affects plugins that derives custom items from admonitions.

@tk0miya
Copy link
Member

tk0miya commented Jan 18, 2016

@petsuter Could you tell me about this problem in detail (if you can remember)?
I can not reproduce the problem.

I used Sphinx-1.3.4 and following reST on investigation::

.. admonition:: test

   Hello world

@petsuter
Copy link
Contributor Author

@tk0miya I used Spinx-1.3.1 on Windows. I just reproduced it with these steps:

  • sphinx-quickstart (accept all defaults except y to get Windows command file)
  • Replace content of index.rst with your .. admonition ... example.
  • make.bat html
  • start _build\html\index.html
  • It is red.

Inspecting HTML I see:

<div class="admonition-test admonition">
<p class="first admonition-title">test</p>
<p class="last">Hello world</p>
</div>

and in CSS (alabaster.css:226)

div.admonition {
    margin: 20px 0px;
    padding: 10px 30px;
    background-color: #FCC;
    border: 1px solid #FAA;
}

@petsuter
Copy link
Contributor Author

I now ran pip install sphinx --upgrade to get Sphinx-1.3.4. This did not change anything. pip list shows alabaster 0.7.7. pip install alabaster --upgrade says this is already up-to-date.

@tk0miya
Copy link
Member

tk0miya commented Jan 20, 2016

Thanks, I missed it. I used the classic theme for testing.
I reproduce it. Thanks,

@tk0miya
Copy link
Member

tk0miya commented Jan 20, 2016

@birkenfeld @shimizukawa This is a issue about alabaster theme.
Who is better to resolve this?

@shimizukawa
Copy link
Member

(FYI. #1346 is a discussion of new default theme.)
I think @bitprophet is the man who can resolve it.

@bitprophet
Copy link
Contributor

It's hard to tell from these comments - @petsuter which exact version of Sphinx and which theme were you using where the admonition was not red/pink? I need to look at when Alabaster made that change but I've tried to be backwards compatible since the point where Sphinx added Alabaster as the default theme.

In addition, the implied statement here is that "admonitions should not have any distinct styling" and I'm not sure if I agree with that - many popular themes have e.g. warnings as red and notes as yellow, etc. The lack of coloring earlier in Alabaster's history was largely an oversight IIRC.

There are also configuration options in Alabaster allowing one to change both the background and border colors for the admonition blocks, so you can change it to suit your taste easily :) see https://github.com/bitprophet/alabaster#style-colors

@petsuter
Copy link
Contributor Author

I was probably using Sphinx 1.2.2 and the default theme of that version when generic admonitions where still looking like normal text.

I don't care if warnings etc. are yellow. But a plugin I use is providing a custom admonition subclass item that should definitely look like normal text.

I have had a look at the site you linked before, but it does not mention the word "admonition" anywhere and sadly I have no clue what that list of "style colors" are for. An example might be helpful?

@shimizukawa
Copy link
Member

@petsuter please attach (some where) your Sphinx project that includes source and html build output

@petsuter
Copy link
Contributor Author

@shimizukawa T1825.zip contains four Sphinx projects including source and html build output. (Two without plugins, and two with the traceability plugin. In each case one with the alabaster theme in red and one with the classic theme without red.) Hope this helps.

(All html build output was created with Sphinx 1.3.4 and alabaster 0.7.7)

@bitprophet
Copy link
Contributor

@petsuter See the warn_* options on that linked subsection; the rest of the page notes in detail how to configure such options in your Sphinx conf.py.

@petsuter
Copy link
Contributor Author

OK thanks. So if I understand correctly I have to use this to get the plugin items to appear normal again:

html_theme_options = {
    'warn_bg': '#FFFFFF',
    'warn_border': '#FFFFFF',
}

Is there a way to keep warnings red? Or to specify the color as "like normal text" without hardcoding #FFFFFF?

Would you say the root problem is with the plugin, and it shouldn't subclass nodes.Admonition for things that should look like normal text? If yes, what should it do instead?

@bitprophet
Copy link
Contributor

@petsuter Oh, I see - is the issue that you've got a plugin adding additional admonition types besides the default (which I think is just .. warn:: and nothing else)? Yea, that could be problematic. The CSS stylesheet won't know to style these other admonitions differently, offhand.

I checked your zipfile real briefly and it does just look like your sources end up generating <div class="admonition-test admonition">, so any theme that cares to style div.admonition in CSS is going to affect these.

So yes, I think your best bet is to figure out how to make your plugin emit some other class for these, or alternately, whip up a basic theme inheriting from Alabaster which adds additional stylesheet rules for admonition-test.

EDIT: I backed up and checked my own stuff, and when I use .. warn:: Sphinx generates <div class="admonition warn">. Not sure if "vanilla" admonitions ever actually appear, but seems like we could break out the colorization to affect only warn. I'll make a ticket on my theme's tracker for this. Thanks!

@bitprophet
Copy link
Contributor

points up at the link github handily inserted there

@tk0miya
Copy link
Member

tk0miya commented Jan 8, 2017

It seems alabater theme was already fixed. So I close this now.
Thanks,

@tk0miya tk0miya closed this as completed Jan 8, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants