Skip to content

Commit 5325ef1

Browse files
committed
Project: suggest a simple config file on project import wizard
As part of the "Import Wizard" steps, we add an extra step now that shows a simple suggestion for a config file v2 (the same we currently have in our documentation) that uses `build.os: ubuntu-22.04` and `build.tools.python: "3.11"`. This is an initial work to show the value we can add to this wizard with something pretty simple. There is more work required on the copy for this intermediate step and the UX (I added a checkbox for now to force the user to read the message, not ideal, but works for now). Also, it would be good to find a way to highlight the YAML syntaxis using nice colors and add more useful copy to that intermediate page. Related #10352
1 parent 8c3d06d commit 5325ef1

File tree

3 files changed

+70
-5
lines changed

3 files changed

+70
-5
lines changed

readthedocs/projects/forms.py

+15
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,21 @@ def clean_tags(self):
191191
return tags
192192

193193

194+
class ProjectConfigForm(forms.Form):
195+
196+
"""Simple intermediate step to communicate about the .readthedocs.yaml file."""
197+
198+
confirm = forms.BooleanField(
199+
help_text="I've already added a '.readthedocs.yaml' file to my project",
200+
required=True,
201+
)
202+
203+
def __init__(self, *args, **kwargs):
204+
# Remove 'user' field since it's not expected by BaseForm.
205+
kwargs.pop("user")
206+
super().__init__(*args, **kwargs)
207+
208+
194209
class ProjectAdvancedForm(ProjectTriggerBuildMixin, ProjectForm):
195210

196211
"""Advanced project option form."""

readthedocs/projects/views/private.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
ProjectAdvancedForm,
5454
ProjectAdvertisingForm,
5555
ProjectBasicsForm,
56+
ProjectConfigForm,
5657
ProjectExtraForm,
5758
ProjectRelationshipForm,
5859
RedirectForm,
@@ -260,8 +261,9 @@ class ImportWizardView(ProjectImportMixin, PrivateViewMixin, SessionWizardView):
260261
"""
261262

262263
form_list = [
263-
('basics', ProjectBasicsForm),
264-
('extra', ProjectExtraForm),
264+
("basics", ProjectBasicsForm),
265+
("config", ProjectConfigForm),
266+
("extra", ProjectExtraForm),
265267
]
266268
condition_dict = {'extra': lambda self: self.is_advanced()}
267269

@@ -315,9 +317,7 @@ def done(self, form_list, **kwargs):
315317
"""
316318
form_data = self.get_all_cleaned_data()
317319
extra_fields = ProjectExtraForm.Meta.fields
318-
# expect the first form; manually wrap in a list in case it's a
319-
# View Object, as it is in Python 3.
320-
basics_form = list(form_list)[0]
320+
basics_form = form_list[0]
321321
# Save the basics form to create the project instance, then alter
322322
# attributes directly from other forms
323323
project = basics_form.save()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{% extends "projects/import_base.html" %}
2+
{% load i18n %}
3+
4+
{% block content %}
5+
<h3>{% trans "Project configuration file (<code>.readthedocs.yaml</code>)" %}</h3>
6+
7+
<p class="info">
8+
{% blocktrans trimmed %}
9+
Make sure your project has a <code>.readthedocs.yaml</code> at the root of your repository. This file is required by Read the Docs to be able to build your documentation. You can read more about this at https://docs.readthedocs.io/en/stable/config-file/v2.html
10+
{% endblocktrans %}
11+
</p>
12+
13+
<p class="info">
14+
Here you have an example for a Sphinx project:
15+
16+
<code><pre>
17+
# .readthedocs.yaml
18+
# Read the Docs configuration file
19+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
20+
21+
# Required
22+
version: 2
23+
24+
# Set the version of Python and other tools you might need
25+
build:
26+
os: ubuntu-22.04
27+
tools:
28+
python: "3.11"
29+
# You can also specify other tool versions:
30+
# nodejs: "19"
31+
# rust: "1.64"
32+
# golang: "1.19"
33+
34+
# Build documentation in the docs/ directory with Sphinx
35+
sphinx:
36+
configuration: docs/conf.py
37+
38+
# If using Sphinx, optionally build your docs in additional formats such as PDF
39+
# formats:
40+
# - pdf
41+
42+
# Optionally declare the Python requirements required to build your docs
43+
python:
44+
install:
45+
- requirements: docs/requirements.txt
46+
</pre></code>
47+
</p>
48+
49+
{{ block.super }}
50+
{% endblock %}

0 commit comments

Comments
 (0)