I'm using the Sphinx autodoc feature in making documentation for my Python project. Building the HTML locally works fine, but it seems to fail on Read The Docs. I have RTD connected to my Github account, with a hook on commit. It seems to be reading my code and importing the package just fine.
The error I see seems to indicate that it's failing because of the formatted strings in my Python code:
WARNING: autodoc: failed to import module 'letterboxd.api'; the following exception was raised:
Traceback (most recent call last):
...
File "/home/docs/checkouts/readthedocs.org/user_builds/letterboxd/envs/latest/lib/python3.5/site-packages/letterboxd-0.1.0a5-py3.5.egg/letterboxd/api.py", line 77
headers["Authorization"] = f"Bearer {self.user.token}"
^
SyntaxError: invalid syntax
I am running Python 3.6 locally, so my guess is that the issue may be that Read the Docs doesn't support 3.6 yet. I do have the RTD Admin > Advanced Settings > Python interpreter set to CPython 3.x, and have also checked the box for “Install your project inside a virtualenv using setup.py install
”
Is this currently a known issue with RTD, or is there some setting I can tweak to correct this?
Based on the bug link that @sehafoc provided in a comment above (thanks!), I read and clicked through to find this doc page about building a YAML config file for RTD.
Adding this config file resolved this issue, where build:image:
and python:version:
are the relevant bits:
# .readthedocs.yml
build:
image: latest
python:
version: 3.6
setup_py_install: true
requirements_file: requirements.txt