Skip to content

Commit 25b66f1

Browse files
authored
Build: shrink preview comment (#12391)
Implement what we discussed in #12295. This is not perfect and it doesn't pretend to be, it's just one of the implementations after a few discussion iterations in the comments. The idea of this PR is to have something a little better than what we have to be able to merge and move forward with. Closes #12295
1 parent 6676ed5 commit 25b66f1

File tree

3 files changed

+21
-27
lines changed

3 files changed

+21
-27
lines changed

readthedocs/builds/tests/test_tasks.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -202,22 +202,20 @@ def test_post_build_overview(self, get_diff, post_comment):
202202
post_build_overview(build_pk=self.current_version_build.pk)
203203
expected_comment = dedent(
204204
f"""
205-
## Documentation build overview
205+
### Documentation build overview
206206
207-
> 📚 [My project](https://readthedocs.org/projects/my-project/) | 🛠️ build [#{self.current_version_build.id}](https://readthedocs.org/projects/my-project/builds/{self.current_version_build.id}/) (5678abcd) | 🔍 [preview](http://my-project--1.readthedocs.build/en/1/)
207+
> 📚 [My project](https://readthedocs.org/projects/my-project/) | 🛠️ Build [#{self.current_version_build.id}](https://readthedocs.org/projects/my-project/builds/{self.current_version_build.id}/) | 📁 Comparing 5678abcd against [latest](http://my-project.readthedocs.io/en/latest/) (1234abcd)
208208
209-
### Files changed
210-
211-
> Comparing with [latest](http://my-project.readthedocs.io/en/latest/) (1234abcd...5678abcd)
209+
[<kbd><br />🔍 Preview build <br /></kbd>](http://my-project--1.readthedocs.build/en/1/)
212210
213211
214212
<details>
215-
<summary>Show files (3) | 1 modified | 1 added | 1 deleted</summary>
213+
<summary>Show files changed (3 files in total): 📝 1 modified | 1 added | 1 deleted</summary>
216214
217215
| File | Status |
218216
| --- | --- |
219217
| [changes.html](http://my-project--1.readthedocs.build/en/1/changes.html) | ➕ added |
220-
| [deleteme.html](http://my-project--1.readthedocs.build/en/1/deleteme.html) | deleted |
218+
| [deleteme.html](http://my-project--1.readthedocs.build/en/1/deleteme.html) | deleted |
221219
| [index.html](http://my-project--1.readthedocs.build/en/1/index.html) | 📝 modified |
222220
223221
@@ -252,22 +250,20 @@ def test_post_build_overview_more_than_5_files(self, get_diff, post_comment):
252250
post_build_overview(build_pk=self.current_version_build.pk)
253251
expected_comment = dedent(
254252
f"""
255-
## Documentation build overview
256-
257-
> 📚 [My project](https://readthedocs.org/projects/my-project/) | 🛠️ build [#{self.current_version_build.id}](https://readthedocs.org/projects/my-project/builds/{self.current_version_build.id}/) (5678abcd) | 🔍 [preview](http://my-project--1.readthedocs.build/en/1/)
253+
### Documentation build overview
258254
259-
### Files changed
255+
> 📚 [My project](https://readthedocs.org/projects/my-project/) | 🛠️ Build [#{self.current_version_build.id}](https://readthedocs.org/projects/my-project/builds/{self.current_version_build.id}/) | 📁 Comparing 5678abcd against [latest](http://my-project.readthedocs.io/en/latest/) (1234abcd)
260256
261-
> Comparing with [latest](http://my-project.readthedocs.io/en/latest/) (1234abcd...5678abcd)
257+
[<kbd><br />🔍 Preview build <br /></kbd>](http://my-project--1.readthedocs.build/en/1/)
262258
263259
264260
<details>
265-
<summary>Show files (6) | 4 modified | 1 added | 1 deleted</summary>
261+
<summary>Show files changed (6 files in total): 📝 4 modified | 1 added | 1 deleted</summary>
266262
267263
| File | Status |
268264
| --- | --- |
269265
| [changes.html](http://my-project--1.readthedocs.build/en/1/changes.html) | ➕ added |
270-
| [deleteme.html](http://my-project--1.readthedocs.build/en/1/deleteme.html) | deleted |
266+
| [deleteme.html](http://my-project--1.readthedocs.build/en/1/deleteme.html) | deleted |
271267
| [index.html](http://my-project--1.readthedocs.build/en/1/index.html) | 📝 modified |
272268
| [one.html](http://my-project--1.readthedocs.build/en/1/one.html) | 📝 modified |
273269
| [three.html](http://my-project--1.readthedocs.build/en/1/three.html) | 📝 modified |
@@ -278,6 +274,7 @@ def test_post_build_overview_more_than_5_files(self, get_diff, post_comment):
278274
279275
"""
280276
)
277+
281278
post_comment.assert_called_once_with(
282279
build=self.current_version_build,
283280
comment=expected_comment,
@@ -298,19 +295,18 @@ def test_post_build_overview_no_files_changed(self, get_diff, post_comment):
298295
post_build_overview(build_pk=self.current_version_build.pk)
299296
expected_comment = dedent(
300297
f"""
301-
## Documentation build overview
298+
### Documentation build overview
302299
303-
> 📚 [My project](https://readthedocs.org/projects/my-project/) | 🛠️ build [#{self.current_version_build.id}](https://readthedocs.org/projects/my-project/builds/{self.current_version_build.id}/) (5678abcd) | 🔍 [preview](http://my-project--1.readthedocs.build/en/1/)
300+
> 📚 [My project](https://readthedocs.org/projects/my-project/) | 🛠️ Build [#{self.current_version_build.id}](https://readthedocs.org/projects/my-project/builds/{self.current_version_build.id}/) | 📁 Comparing 5678abcd against [latest](http://my-project.readthedocs.io/en/latest/) (1234abcd)
304301
305-
### Files changed
306-
307-
> Comparing with [latest](http://my-project.readthedocs.io/en/latest/) (1234abcd...5678abcd)
302+
[<kbd><br />🔍 Preview build <br /></kbd>](http://my-project--1.readthedocs.build/en/1/)
308303
309304
310305
No files changed.
311306
312307
"""
313308
)
309+
314310
post_comment.assert_called_once_with(
315311
build=self.current_version_build,
316312
comment=expected_comment,

readthedocs/filetreediff/dataclasses.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def emoji(self) -> str:
7070
if self == FileTreeDiffFileStatus.added:
7171
return "➕"
7272
elif self == FileTreeDiffFileStatus.deleted:
73-
return ""
73+
return ""
7474
elif self == FileTreeDiffFileStatus.modified:
7575
return "📝"
7676
return ""
@@ -155,7 +155,7 @@ def _sortpath(self, file: FileTreeDiffFile):
155155
However, it doesn't group the results by directory.
156156
157157
Ideally, this should sort file names by hierarchy (less deep directory
158-
first), groupping them by directory and alphabetically. We should update
158+
first), grouping them by directory and alphabetically. We should update
159159
this function to achieve that goal if we find a simple way to do it.
160160
"""
161161
parts = file.path.split("/")

readthedocs/templates/core/build-overview.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@ Template used for generating the build overview page that is posted as a comment
44
Whitespaces and newlines are important in some places like lists and tables,
55
make sure to adjust the tags accordingly, as they introduce newlines.
66
{% endcomment %}
7-
## Documentation build overview
7+
### Documentation build overview
88

9-
> 📚 [{{ project.name }}](https://{{ PRODUCTION_DOMAIN }}{% url "projects_detail" project.slug %}) | 🛠️ build [#{{ current_version_build.pk }}](https://{{ PRODUCTION_DOMAIN }}{% url "builds_detail" project.slug current_version_build.pk %}) ({{ current_version_build.commit }}) | 🔍 [preview]({{ current_version.get_absolute_url }})
9+
> 📚 [{{ project.name }}](https://{{ PRODUCTION_DOMAIN }}{% url "projects_detail" project.slug %}) | 🛠️ Build [#{{ current_version_build.pk }}](https://{{ PRODUCTION_DOMAIN }}{% url "builds_detail" project.slug current_version_build.pk %}) | 📁 Comparing {{ current_version_build.commit }} against [{{ base_version.verbose_name }}]({{ base_version.get_absolute_url }}) ({{ base_version_build.commit }})
1010
11-
### Files changed
12-
13-
> Comparing with [{{ base_version.verbose_name }}]({{ base_version.get_absolute_url }}) ({{ base_version_build.commit }}...{{ current_version_build.commit }})
11+
[<kbd><br />🔍 Preview build <br /></kbd>]({{ current_version.get_absolute_url }})
1412

1513
{% if diff.files %}
1614
<details>
17-
<summary>Show files ({{ diff.files|length }}) | {{ diff.modified|length }} modified | {{ diff.added|length }} added | {{ diff.deleted|length }} deleted</summary>
15+
<summary>Show files changed ({{ diff.files|length }} files in total): 📝 {{ diff.modified|length }} modified | {{ diff.added|length }} added | {{ diff.deleted|length }} deleted</summary>
1816

1917
| File | Status |
2018
| --- | --- |

0 commit comments

Comments
 (0)