Repository: readthedocs/readthedocs.org

Issue:
Use sphinx_rtd_theme directly instead of vendoring it
Are there any reasons why the sphinx rtd theme is copied into the RTD code base instead of referenced as dependency?

There were bugs like #1497 that would not have been raised if the theme would have been up to date.



Discussion:
ha, read my mind :)

I have a refactor that i'd like in v0.1.9 of the theme which will allow us to use it as a bower dependency

@agjohnson Whats the planned ETA for this? Why not integrating as a python dependency?

Our two options here:
- Bring it in as a python dependency and import the global declaration in our bundled javascript for built docs.
- Treat it as a javascript dependency as part of the bundling process and bundle the theme javascript into our bundles

I still lean towards the latter, as it's more consistent with how we treat the rest of our javascript dependencies. It's one less spurious script include as well, as it would be bundled in, if that's important. I think the only argument for the python package method is that we're already installing the theme on RTD. This should change though, as I can't think of any reason why the theme should exist outside version virtualenvs.

I'm going to try for this week, it's at the top of my list. I had to bump it from my list last week as my focus wasn't on rtd.org.


Resolving patch:
diff --git a/fabfile.py b/fabfile.py
--- a/fabfile.py
+++ b/fabfile.py
@@ -6,20 +6,6 @@
 fabfile_dir = os.path.dirname(__file__)
 
 
-def update_theme():
-    theme_dir = os.path.join(fabfile_dir, 'readthedocs', 'templates', 'sphinx')
-    if not os.path.exists('/tmp/sphinx_rtd_theme'):
-        local('git clone https://github.com/snide/sphinx_rtd_theme.git /tmp/sphinx_rtd_theme')
-    with lcd('/tmp/sphinx_rtd_theme'):
-        local('git remote update')
-        local('git reset --hard origin/master ')
-        local('cp -r /tmp/sphinx_rtd_theme/sphinx_rtd_theme %s' % theme_dir)
-        local('cp -r /tmp/sphinx_rtd_theme/sphinx_rtd_theme/static/fonts/ %s' % os.path.join(fabfile_dir, 'media', 'font'))
-        local('cp /tmp/sphinx_rtd_theme/sphinx_rtd_theme/static/css/badge_only.css %s' % os.path.join(fabfile_dir, 'media', 'css'))
-        local('cp /tmp/sphinx_rtd_theme/sphinx_rtd_theme/static/css/theme.css %s' %
-              os.path.join(fabfile_dir, 'media', 'css', 'sphinx_rtd_theme.css'))
-
-
 def i18n():
     with lcd('readthedocs'):
         local('rm -rf rtd_tests/tests/builds/')
diff --git a/readthedocs/projects/tasks.py b/readthedocs/projects/tasks.py
--- a/readthedocs/projects/tasks.py
+++ b/readthedocs/projects/tasks.py
@@ -252,7 +252,8 @@ def setup_environment(self):
             'mock==1.0.1',
             'pillow==2.6.1',
             'readthedocs-sphinx-ext==0.5.4',
-            'sphinx-rtd-theme==0.1.8',
+            'git+http://github.com/snide/sphinx-rtd-theme@js-refactor#egg=sphinx-rtd-theme',
+            # 'sphinx-rtd-theme==0.1.8',
             'alabaster>=0.7,<0.8,!=0.7.5',
             'recommonmark==0.1.1',
         ]
diff --git a/readthedocs/templates/sphinx/sphinx_rtd_theme/__init__.py b/readthedocs/templates/sphinx/sphinx_rtd_theme/__init__.py
deleted file mode 100644
--- a/readthedocs/templates/sphinx/sphinx_rtd_theme/__init__.py
+++ /dev/null
@@ -1,17 +0,0 @@
-"""Sphinx ReadTheDocs theme.
-
-From https://github.com/ryan-roemer/sphinx-bootstrap-theme.
-
-"""
-import os
-
-VERSION = (0, 1, 8)
-
-__version__ = ".".join(str(v) for v in VERSION)
-__version_full__ = __version__
-
-
-def get_html_theme_path():
-    """Return list of HTML theme paths."""
-    cur_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
-    return cur_dir


Test patch: