Skip to content
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

Guide users to the YAML config from the build detail page #5519

Merged
merged 2 commits into from
Mar 22, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions readthedocs/builds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from jsonfield import JSONField
from taggit.managers import TaggableManager

from readthedocs.config import LATEST_CONFIGURATION_VERSION
from readthedocs.core.utils import broadcast
from readthedocs.projects.constants import (
BITBUCKET_URL,
Expand Down Expand Up @@ -640,6 +641,9 @@ def is_stale(self):
mins_ago = timezone.now() - datetime.timedelta(minutes=5)
return self.state == BUILD_STATE_TRIGGERED and self.date < mins_ago

def using_latest_config(self):
return int(self.config.get('version', '1')) == LATEST_CONFIGURATION_VERSION


class BuildCommandResultMixin:

Expand Down
3 changes: 3 additions & 0 deletions readthedocs/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
'InvalidConfig',
'PIP',
'SETUPTOOLS',
'LATEST_CONFIGURATION_VERSION',
)

ALL = 'all'
Expand Down Expand Up @@ -78,6 +79,8 @@
)
DOCKER_IMAGE_SETTINGS = getattr(settings, 'DOCKER_IMAGE_SETTINGS', {})

LATEST_CONFIGURATION_VERSION = 2


class ConfigError(Exception):

Expand Down
18 changes: 18 additions & 0 deletions readthedocs/rtd_tests/tests/test_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,3 +562,21 @@ def test_build_is_stale(self):
self.assertFalse(build_one.is_stale)
self.assertTrue(build_two.is_stale)
self.assertFalse(build_three.is_stale)

def test_using_latest_config(self):
now = timezone.now()

build = get(
Build,
project=self.project,
version=self.version,
date=now - datetime.timedelta(minutes=8),
state='finished',
)

self.assertFalse(build.using_latest_config())

build.config = {'version': 2}
build.save()

self.assertTrue(build.using_latest_config())
12 changes: 12 additions & 0 deletions readthedocs/templates/builds/build_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@
</p>
</div>
{% endif %}
{% if build.finished and not build.using_latest_config %}
<div class="build-ideas">
<p>
{% blocktrans trimmed with config_file_link="https://docs.readthedocs.io/page/config-file/v2.html" %}
<strong>Configure your documentation builds!</strong>
Adding a <a href="{{ config_file_link }}">.readthedocs.yml</a> file to your project
is the recommended way to configure your documentation builds.
You can declare dependencies, set up submodules, build for different output formats, and many other great features.
Copy link
Member

Choose a reason for hiding this comment

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

build for different output formats

This is only true for sphinx, so not sure if we should advertise it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll drop that one.

{% endblocktrans %}
</p>
</div>
{% endif %}
{% endif %}

{% if build.output %}
Expand Down