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

Switch to css imports rather than css_files hackery. #159

Merged
merged 5 commits into from
May 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
History
=========

Unreleased
==========
* Fix ``css_files`` breakage from Sphinx ``1.6+`` update.
`#158 <https://github.com/ryan-roemer/sphinx-bootstrap-theme/pull/158>`_,
`#160 <https://github.com/ryan-roemer/sphinx-bootstrap-theme/pull/160>`_.

* **Breaking Change**: Remove ``bootswatch_css_custom`` override, and instead opt for documenting idiomatic Sphinx-version specific generic overrides for custom CSS.

v0.4.14
=======
* Fix visibiliy of multiple footnote references. (`@drewhutchison`_)
Expand Down
27 changes: 20 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,26 +204,39 @@ file to override a style, which in the demo would be something like::
$ mkdir source/_static
$ touch source/_static/my-styles.css

In the new file "source/_static/my-styles.css", add any appropriate styling,
e.g. a bold background color::

footer {
background-color: red;
}

Then, in "conf.py", edit this line::

html_static_path = ["_static"]

You will also need the override template "source/_templates/layout.html" file
From there it depends on which version of Sphinx you are using:

**Sphinx <= 1.5**

You will need the override template "source/_templates/layout.html" file
configured as above, but with the following code::

{# Import the theme's layout. #}
{% extends "!layout.html" %}

{# Custom CSS overrides #}
{% set bootswatch_css_custom = ['_static/my-styles.css'] %}
{% set css_files = css_files + ['_static/my-styles.css'] %}

Then, in the new file "source/_static/my-styles.css", add any appropriate
styling, e.g. a bold background color::
**Sphinx >= 1.6**

footer {
background-color: red;
}
Add a `setup` function in "conf.py" with stylesheet paths added relative to the
static path::

def setup(app):
app.add_stylesheet("my-styles.css") # also can be a full URL
# app.add_stylesheet("ANOTHER.css")
# app.add_stylesheet("AND_ANOTHER.css")

Theme Notes
===========
Expand Down
5 changes: 0 additions & 5 deletions demo/source/_templates/layout.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{% extends "!layout.html" %}

{# Custom CSS overrides #}
{# set bootswatch_css_custom = ['_static/my-styles.css'] #}

{# Add github banner (from: https://github.com/blog/273-github-ribbons). #}
{% block header %}
{{ super() }}
Expand All @@ -20,5 +17,3 @@
});
</script>
{% endblock %}


3 changes: 3 additions & 0 deletions demo/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@
# Output file base name for HTML help builder.
htmlhelp_basename = 'MyProjectDoc'

# # Custom style overrides
# def setup(app):
# app.add_stylesheet('my-styles.css') # may also be an URL

# -- Options for LaTeX output --------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Fabric==1.6.0
Sphinx==1.2.1
Sphinx==1.6.1
35 changes: 2 additions & 33 deletions sphinx_bootstrap_theme/bootstrap/layout.html
Original file line number Diff line number Diff line change
@@ -1,44 +1,13 @@
{% extends "basic/layout.html" %}

{% set theme_css_files = [] %}
{% if theme_bootstrap_version == "3" %}
{% set bootstrap_version, bootstrap_additional_css, navbar_version = "3.3.6", "theme", "" %}
{% set bootstrap_version, navbar_version = "3.3.6", "" %}
{% set bs_span_prefix = "col-md-" %}
{% else %}
{% set bootstrap_version, bootstrap_additional_css, navbar_version = "2.3.2", "responsive", "-2" %}
{% set bootstrap_version, navbar_version = "2.3.2", "-2" %}
{% set bs_span_prefix = "span" %}
{% endif %}

{% if theme_bootswatch_theme and theme_bootswatch_theme != "\"\"" %}
{# BS2 needs "bootstrap-responsive.css". BS3 doesn't. #}
{% if theme_bootstrap_version == "3" %}
{% set theme_css_files = theme_css_files + [
'_static/bootswatch-' + bootstrap_version + '/' + theme_bootswatch_theme + '/bootstrap.min.css',
'_static/bootstrap-sphinx.css'
]
%}
{% else %}
{% set theme_css_files = theme_css_files + [
'_static/bootswatch-' + bootstrap_version + '/' + theme_bootswatch_theme + '/bootstrap.min.css',
'_static/bootstrap-' + bootstrap_version + '/css/bootstrap-' + bootstrap_additional_css + '.min.css',
'_static/bootstrap-sphinx.css'
]
%}
{% endif %}
{% else %}
{% set theme_css_files = theme_css_files + [
'_static/bootstrap-' + bootstrap_version + '/css/bootstrap.min.css',
'_static/bootstrap-' + bootstrap_version + '/css/bootstrap-' + bootstrap_additional_css + '.min.css',
'_static/bootstrap-sphinx.css'
]
%}
{% endif %}

{% if not bootswatch_css_custom %}
{% set bootswatch_css_custom = [] %}
{% endif %}
{% set css_files = css_files + theme_css_files + bootswatch_css_custom %}

{% set script_files = script_files + [
'_static/js/jquery-1.11.0.min.js',
'_static/js/jquery-fix.js',
Expand Down
29 changes: 29 additions & 0 deletions sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.css_t
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,35 @@
* Sphinx stylesheet -- Bootstrap theme.
*/

/*
* Imports to aggregate everything together.
*/

@import url("basic.css");

{% if theme_bootstrap_version == "3" %}
{% set bootstrap_version, bootstrap_additional_css = "3.3.6", "theme" %}
{% else %}
{% set bootstrap_version, bootstrap_additional_css = "2.3.2", "responsive" %}
{% endif %}

{% if theme_bootswatch_theme and theme_bootswatch_theme != "\"\"" %}
{# BS2 needs "bootstrap-responsive.css". BS3 doesn't. #}
{% if theme_bootstrap_version == "3" %}
@import url("{{ 'bootswatch-' + bootstrap_version + '/' + theme_bootswatch_theme + '/bootstrap.min.css' }}");
{% else %}
@import url("{{ 'bootswatch-' + bootstrap_version + '/' + theme_bootswatch_theme + '/bootstrap.min.css' }}");
@import url("{{ 'bootstrap-' + bootstrap_version + '/css/bootstrap-' + bootstrap_additional_css + '.min.css' }}");
{% endif %}
{% else %}
@import url("{{ 'bootstrap-' + bootstrap_version + '/css/bootstrap.min.css' }}");
@import url("{{ 'bootstrap-' + bootstrap_version + '/css/bootstrap-' + bootstrap_additional_css + '.min.css' }}");
{% endif %}

/*
* Styles
*/

.navbar-inverse .brand {
color: #FFF;
}
Expand Down
2 changes: 1 addition & 1 deletion sphinx_bootstrap_theme/bootstrap/theme.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Bootstrap Theme
[theme]
inherit = basic
stylesheet = basic.css
stylesheet = bootstrap-sphinx.css
pygments_style = tango

# Configurable options.
Expand Down