I have something like this in my conf.py::

  import os
  on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
  if on_rtd:
      ...
  else:
      ...

This is documented here:

  http://docs.readthedocs.org/en/latest/faq.html

hth,
Luc


On 14/04/15 10:09, Alexander Belchenko wrote:
> Hi,
> 
> I need help on the subject.
> I'd like to explain. Recently I've installed sphinx with `pip install
> sphinx` and got version 1.3.1. I should admit that I haven't been using
> Sphinx doc for 2 years, so I don't even remeber which latest version I
> used earlier. Anyway, the version number should not matter for me, but
> in fact it does matter. And I should say that I'm not very happy with my
> situation.
> 
> As I've discovered your version 1.3.1 requires new option in conf.py:
> 
> html_theme = 'classic'
> 
> in order to get the same look as in older versions. That was OK until I
> tried to publish my docs to readthedocs.org site.
> 
> Probably you had very important reasons to change the defaults, although
> I don't understand them. Why not using classic as default theme?
> 
> Now the bad part of the story: readthedocs tried to build documentation
> with sphinx 1.2.2. I don't know why they're using this version.
> But result is quite disappointing: html docs didn't build. Here is
> excerpt from the failed build log:
> ----------------------------------------------------------------------
> html
> -----
> Making output directory...
> Running Sphinx v1.2.2
> loading translations [en]... done
> 
> Build Standard Error
> 
> html
> -----
> Traceback (most recent call last):
>   File
> "/home/docs/checkouts/readthedocs.org/user_builds/python-intelhex/envs/2.0/local/lib/python2.7/site-packages/sphinx/cmdline.py",
> line 253, in main
>     warningiserror, tags, verbosity, parallel)
>   File
> "/home/docs/checkouts/readthedocs.org/user_builds/python-intelhex/envs/2.0/local/lib/python2.7/site-packages/sphinx/application.py",
> line 139, in __init__
>     self._init_builder(buildername)
>   File
> "/home/docs/checkouts/readthedocs.org/user_builds/python-intelhex/envs/2.0/local/lib/python2.7/site-packages/sphinx/application.py",
> line 200, in _init_builder
>     self.builder = builderclass(self)
>   File
> "/home/docs/checkouts/readthedocs.org/user_builds/python-intelhex/envs/2.0/local/lib/python2.7/site-packages/sphinx/builders/__init__.py",
> line 68, in __init__
>     self.init()
>   File
> "/home/docs/checkouts/readthedocs.org/user_builds/python-intelhex/envs/2.0/local/lib/python2.7/site-packages/readthedocs_ext/readthedocs.py",
> line 77, in init
>     StandaloneHTMLBuilder.init(self)
>   File
> "/home/docs/checkouts/readthedocs.org/user_builds/python-intelhex/envs/2.0/local/lib/python2.7/site-packages/sphinx/builders/html.py",
> line 108, in init
>     self.init_templates()
>   File
> "/home/docs/checkouts/readthedocs.org/user_builds/python-intelhex/envs/2.0/local/lib/python2.7/site-packages/sphinx/builders/html.py",
> line 143, in init_templates
>     self.theme = Theme(themename)
>   File
> "/home/docs/checkouts/readthedocs.org/user_builds/python-intelhex/envs/2.0/local/lib/python2.7/site-packages/sphinx/theming.py",
> line 82, in __init__
>     '(missing theme.conf?)' % name)
> ThemeError: no theme named 'classic' found (missing theme.conf?)
> 
> Theme error:
> no theme named 'classic' found (missing theme.conf?)
> -----------------------------------------------------------------------------------
> 
> I can reproduce this error locally with sphinx 1.2.2.
> 
> After I removed html_theme='classic' from conf.py - readthedocs can
> build my docs.
> 
> So far I've put -D html_theme=classic to Makefile but I don't like this
> hack, esp. because it does not play well with sphinx-autobuild.
> 
> So, I'd like to know, is there any way to put some conditional to
> conf.py itself to check whether it's building with sphinx 1.3.1 and
> later to put required option, something like:
> 
> if sphinx_version >= '1.3.1':
>     html_theme = 'classic'
> 
> I hope it's possible.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/sphinx-users.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to