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

2.0.0b1: Warning builder.script_files is deprecated. Please use app.add_js_file() instead #6088

Closed
terrisgit opened this issue Feb 18, 2019 · 5 comments · Fixed by readthedocs/sphinx_rtd_theme#728

Comments

@terrisgit
Copy link

terrisgit commented Feb 18, 2019

When building HTML documentation using Python 3.6, I get the warning :

.venv/lib/python3.7/site-packages/sphinx/builders/html.py:137: RemovedInSphinx30Warning: builder.script_files is deprecated. Please use app.add_js_file() instead.

Sphinx 2.0.0b1
sphinx-rtd-theme 0.4.3
sphinxcontrib-applehelp 1.0.1
sphinxcontrib-devhelp 1.0.1
sphinxcontrib-htmlhelp 1.0.1
sphinxcontrib-jsmath 1.0.1
sphinxcontrib-qthelp 1.0.1
sphinxcontrib-serializinghtml 1.1.1
sphinxcontrib-websupport 1.1.0

@tk0miya
Copy link
Member

tk0miya commented Feb 22, 2019

This is not a bug. Since 1.6, appending script_files were deprecated. I guess your theme appends
a script via script_files like following:

{% set script_files = script_files + ['/path/to/script.js'] %}

There are two ways as an alternative.

  1. Insert a <script> tag directly in scripts block in your theme.

    {% block scripts %}
       <script type="text/script" src="/path/to/script.js"></script>
    {% endblock %}
    
  2. Use app.add_js_file() API on your conf.py.

    def setup(app):
        app.add_js_file('script.js')
    

    Note: script.js should be placed under html_static_path.

Both are okay.

@terrisgit
Copy link
Author

terrisgit commented Feb 22, 2019

This is not in my code. Where would it be coming from? This is a new warning that only appears in 2.0 beta. Is this a problem with the rtd theme? I grepped my source dir and .venv and can’t find any usage of script_files

@tk0miya
Copy link
Member

tk0miya commented Feb 22, 2019

Are you using sphinx-rtd-theme, right? If so, it should be fixed on the theme. Could you file a issue to thier project?
It seems they have still used deprecated API.
https://github.com/rtfd/sphinx_rtd_theme/blob/ecbc09f22a076b6ca985f6c5cab0967976dad12a/sphinx_rtd_theme/search.html#L12

@tk0miya
Copy link
Member

tk0miya commented Feb 24, 2019

I just updated the warning message because of not understandable (see #6093).
I'm closing this now.

Thanks,

@Blendify
Copy link
Contributor

Hi I saw this from the mailing list, I opened a PR for our theme and waiting for an approval. See above for a link to the PR.

Blendify added a commit to readthedocs/sphinx_rtd_theme that referenced this issue Apr 3, 2019
* Remove deprecated use of script_files

Fixes sphinx-doc/sphinx#6088

* Add script block

* Fix build error
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants