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

Getting NoneType css_files or theme_css_files after Sphinx Upgrade #158

Closed
alexhagen opened this issue May 17, 2017 · 6 comments
Closed

Comments

@alexhagen
Copy link

I upgraded my Sphinx (to 1.6.1) to install another package this morning, and now my build using sphinx_bootstrap_theme (version 0.4.14) gives me the following error:

Exception occurred:
  File "/usr/local/lib/python2.7/dist-packages/sphinx_bootstrap_theme/bootstrap/layout.html", line 40, in top-level template code
    {% set css_files = css_files + theme_css_files + bootswatch_css_custom %}
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'
The full traceback has been saved in /tmp/sphinx-err-Jz7JLa.log, if you want to report the issue to the developers.

Sphinx works with html_theme = 'alabaster' instead of sphinx-bootstrap, so I believe it's in sphinx-bootstrap-theme. My relevant configuration lines are:

html_theme = 'bootstrap'
html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()
html_theme_options = {
    # Tab name for entire site. (Default: "Site")
    'navbar_site_name': "Alex Hagen",
    'navbar_sidebarrel': True,
    'navbar_pagenav': True,
    'navbar_pagenav_name': "Page",
    'globaltoc_depth': 2,
    'globaltoc_includehidden': "true",
    'navbar_class': "navbar",
    'navbar_fixed_top': "true",
    'source_link_position': None,
    'bootswatch_theme': "journal",
    'bootstrap_version': "3",
}
@ryan-roemer
Copy link
Owner

Confirmed with:

Sphinx==1.6.1

and

$ fab clean && fab demo
...
Exception occurred:
  File "/Users/rye/scm/os/sphinx-bootstrap-theme/sphinx_bootstrap_theme/bootstrap/layout.html", line 40, in top-level template code
    {% set css_files = css_files + theme_css_files + bootswatch_css_custom %}
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'
The full traceback has been saved in /var/folders/p0/n23gplhx6xz72m7grb4mtqqh0000gp/T/sphinx-err-RsvPad.log, if you want to report the issue to the developers.
...

I don't think this should be too hard to fix... looks like undeclared jinja variables or something changed error asserts...

@has2k1
Copy link

has2k1 commented May 17, 2017

sphinx-doc/sphinx#3754

@alexhagen
Copy link
Author

Update:

Looked into sphinx-bootstrap-theme's layout.html and sphinx's basic/layout.html. Looks like sphinx never sets css_files if it's not explicitly defined.

Adding

{% extends "!layout.html" %}
{% set css_files = [] %}

to a custom layout.html in _templates removes the "unsupported operand type" error, but leaves me with a

Exception occurred:
  File "/usr/local/lib/python2.7/dist-packages/sphinx/util/osutil.py", line 61, in relative_uri
    if to.startswith(SEP):
UndefinedError: 'str object' has no attribute 'filename'
The full traceback has been saved in /tmp/sphinx-err-4DxoKf.log, if you want to report the issue to the developers.

It's possible Sphinx changed their css_files to objects and not just strings?

@ryan-roemer
Copy link
Owner

Possibly related: https://github.com/sphinx-doc/sphinx/blob/master/CHANGES#L318-L321

1.6b2

* #3662: ``builder.css_files`` is deprecated.  Please use ``add_stylesheet()``
  API instead.

@pcav
Copy link

pcav commented May 17, 2017 via email

@alexhagen
Copy link
Author

Fixed after installing Sphinx (1.6.2) from github.com/sphinx-doc/sphinx@stable. Thank you!

ryan-roemer added a commit that referenced this issue May 17, 2017
  `#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.
ryan-roemer added a commit that referenced this issue May 18, 2017
The theme uses `css_files` hackery, but that is deprecated in modern Sphinx and error prone because there are real object instances and not strings that now comprise `css_files`. See, e.g. #158 

This PR switches all of the conditionally-included CSS files into css `@import url("NAME.css");` statements and just now has _one_ root style sheet included the old fashioned way. Hopefully this is both backwards compatible with any previous Sphinx versions and works better as `css_files` goes off into deprecation sunset.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants