Skip to content

Allow build.commands without build.tools #10281

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
9 changes: 9 additions & 0 deletions docs/user/build-customization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,15 @@ Supported :ref:`formats <downloadable-documentation:accessing offline formats>`
* ``_readthedocs/pdf/``
* ``_readthedocs/epub/``

.. note::

Remember to create the folders before adding content to them.
You can ensure that the output folder exists by adding the following command:

.. code-block:: console

mkdir -p _readthedocs/html/

Search support
~~~~~~~~~~~~~~

Expand Down
6 changes: 3 additions & 3 deletions readthedocs/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Build,
BuildJobs,
BuildTool,
BuildWithTools,
BuildWithOs,
Conda,
Mkdocs,
Python,
Expand Down Expand Up @@ -274,7 +274,7 @@ def validate(self):

@property
def using_build_tools(self):
return isinstance(self.build, BuildWithTools)
return isinstance(self.build, BuildWithOs)

@property
def is_using_conda(self):
Expand Down Expand Up @@ -1331,7 +1331,7 @@ def build(self):
)
for tool, version in build['tools'].items()
}
return BuildWithTools(
return BuildWithOs(
os=build['os'],
tools=tools,
jobs=BuildJobs(**build["jobs"]),
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, **kwargs):
super().__init__(**kwargs)


class BuildWithTools(Base):
class BuildWithOs(Base):

__slots__ = ("os", "tools", "jobs", "apt_packages", "commands")

Expand Down
22 changes: 11 additions & 11 deletions readthedocs/config/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from readthedocs.config.models import (
Build,
BuildJobs,
BuildWithTools,
BuildWithOs,
Conda,
PythonInstall,
PythonInstallRequirements,
Expand Down Expand Up @@ -1051,7 +1051,7 @@ def test_new_build_config(self):
)
build.validate()
assert build.using_build_tools
assert isinstance(build.build, BuildWithTools)
assert isinstance(build.build, BuildWithOs)
assert build.build.os == 'ubuntu-20.04'
assert build.build.tools['python'].version == '3.9'
full_version = settings.RTD_DOCKER_BUILD_SETTINGS['tools']['python']['3.9']
Expand Down Expand Up @@ -1086,11 +1086,9 @@ def test_new_build_config_conflict_with_build_python_version(self):
build.validate()
assert excinfo.value.key == 'python.version'

def test_commands_build_config_with_legacy_tools(self):
def test_commands_build_config_tools_and_commands_valid(self):
"""
build.tools used to be required for build.commands but it isn't anymore.

It should remain possible, though.
Test that build.tools and build.commands are valid together.
"""
build = self.get_build_config(
{
Expand All @@ -1102,7 +1100,7 @@ def test_commands_build_config_with_legacy_tools(self):
},
)
build.validate()
assert isinstance(build.build, BuildWithTools)
assert isinstance(build.build, BuildWithOs)
assert build.build.commands == ["pip install pelican", "pelican content"]

def test_build_jobs_without_build_os_is_invalid(self):
Expand Down Expand Up @@ -1155,13 +1153,15 @@ def test_commands_build_config_valid(self):
{
"build": {
"os": "ubuntu-22.04",
"commands": ["pip install pelican", "pelican content"],
"commands": ["echo 'hello world' > _readthedocs/html/index.html"],
},
},
)
build.validate()
assert isinstance(build.build, BuildWithTools)
assert build.build.commands == ["pip install pelican", "pelican content"]
assert isinstance(build.build, BuildWithOs)
assert build.build.commands == [
"echo 'hello world' > _readthedocs/html/index.html"
]

@pytest.mark.parametrize("value", ["", None, "pre_invalid"])
def test_jobs_build_config_invalid_jobs(self, value):
Expand Down Expand Up @@ -1220,7 +1220,7 @@ def test_jobs_build_config(self):
},
)
build.validate()
assert isinstance(build.build, BuildWithTools)
assert isinstance(build.build, BuildWithOs)
assert isinstance(build.build.jobs, BuildJobs)
assert build.build.jobs.pre_checkout == ["echo pre_checkout"]
assert build.build.jobs.post_checkout == ["echo post_checkout"]
Expand Down