Skip to content

Fix broken url on sphinx projects #4696

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

Merged
merged 3 commits into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion readthedocs/doc_builder/backends/sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ def get_config_params(self):
# TODO this should be handled better in the theme
conf_py_path = os.path.join(
os.path.sep,
self.config_file,
os.path.dirname(
os.path.relpath(
self.config_file,
self.project.checkout_path(self.version.slug)
)
),
'',
)
remote_version = self.version.commit_name
Expand Down
33 changes: 33 additions & 0 deletions readthedocs/rtd_tests/tests/test_doc_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,39 @@ def setUp(self):
BaseSphinx.type = 'base'
BaseSphinx.sphinx_build_dir = tempfile.mkdtemp()

@patch('readthedocs.doc_builder.backends.sphinx.BaseSphinx.docs_dir')
@patch('readthedocs.projects.models.Project.checkout_path')
@override_settings(DONT_HIT_API=True)
def test_conf_py_path(self, checkout_path, docs_dir):
"""
Test the conf_py_path that is added to the conf.py file.

This value is used from the theme and footer
to build the ``View`` and ``Edit`` on link.
"""
tmp_dir = tempfile.mkdtemp()
checkout_path.return_value = tmp_dir
docs_dir.return_value = tmp_dir
python_env = Virtualenv(
version=self.version,
build_env=self.build_env,
config=None,
)
base_sphinx = BaseSphinx(
build_env=self.build_env,
python_env=python_env,
)

for value, expected in (('conf.py', '/'), ('docs/conf.py', '/docs/')):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't use pytests parametrize here :(

base_sphinx.config_file = os.path.join(
tmp_dir, value
)
params = base_sphinx.get_config_params()
self.assertEqual(
params['conf_py_path'],
expected
)

@patch(
'readthedocs.doc_builder.backends.sphinx.SPHINX_TEMPLATE_DIR',
'/tmp/sphinx-template-dir',
Expand Down