diff --git a/readthedocs/builds/tests/test_tasks.py b/readthedocs/builds/tests/test_tasks.py index 88b80d679d1..c521488f663 100644 --- a/readthedocs/builds/tests/test_tasks.py +++ b/readthedocs/builds/tests/test_tasks.py @@ -352,16 +352,12 @@ def test_post_build_overview(self, get_diff, post_comment): [   ๐Ÿ” Preview build   ](http://my-project--1.readthedocs.build/en/1/) -
- Show files changed (3 files in total): ๐Ÿ“ 1 modified | โž• 1 added | โž– 1 deleted - - | File | Status | - | --- | --- | - | [changes.html](http://my-project--1.readthedocs.build/en/1/changes.html) | โž• added | - | [deleteme.html](http://my-project--1.readthedocs.build/en/1/deleteme.html) | โž– deleted | - | [index.html](http://my-project--1.readthedocs.build/en/1/index.html) | ๐Ÿ“ modified | - - +
+ 3 files changed +
+ + changes.html
+ ยฑ index.html
+ - deleteme.html
""" @@ -401,17 +397,20 @@ def test_post_build_overview_more_than_5_files(self, get_diff, post_comment):
- Show files changed (6 files in total): ๐Ÿ“ 4 modified | โž• 1 added | โž– 1 deleted + 6 files changed ยท + 1 added ยท ยฑ 4 modified ยท - 1 deleted +
+ + `+` **Added** + - [`changes.html`](http://my-project--1.readthedocs.build/en/1/changes.html) - | File | Status | - | --- | --- | - | [changes.html](http://my-project--1.readthedocs.build/en/1/changes.html) | โž• added | - | [deleteme.html](http://my-project--1.readthedocs.build/en/1/deleteme.html) | โž– deleted | - | [index.html](http://my-project--1.readthedocs.build/en/1/index.html) | ๐Ÿ“ modified | - | [one.html](http://my-project--1.readthedocs.build/en/1/one.html) | ๐Ÿ“ modified | - | [three.html](http://my-project--1.readthedocs.build/en/1/three.html) | ๐Ÿ“ modified | - | [two.html](http://my-project--1.readthedocs.build/en/1/two.html) | ๐Ÿ“ modified | + `ยฑ` **Modified** + - [`index.html`](http://my-project--1.readthedocs.build/en/1/index.html) + - [`one.html`](http://my-project--1.readthedocs.build/en/1/one.html) + - [`three.html`](http://my-project--1.readthedocs.build/en/1/three.html) + - [`two.html`](http://my-project--1.readthedocs.build/en/1/two.html) + `-` **Deleted** + - [`deleteme.html`](http://my-project--1.readthedocs.build/en/1/deleteme.html)
diff --git a/readthedocs/filetreediff/dataclasses.py b/readthedocs/filetreediff/dataclasses.py index 99a8e37c09c..f69e82a2ba4 100644 --- a/readthedocs/filetreediff/dataclasses.py +++ b/readthedocs/filetreediff/dataclasses.py @@ -175,3 +175,8 @@ def deleted(self): def modified(self): """List of modified files.""" return [file for file in self.files if file.status == FileTreeDiffFileStatus.modified] + + @cached_property + def should_auto_expand(self): + """Auto-expand the details view when there are few files.""" + return len(self.files) < 5 diff --git a/readthedocs/templates/core/build-overview.md b/readthedocs/templates/core/build-overview.md index a7017034f11..cb5381b2ba1 100644 --- a/readthedocs/templates/core/build-overview.md +++ b/readthedocs/templates/core/build-overview.md @@ -3,6 +3,8 @@ Template used for generating the build overview page that is posted as a comment Whitespaces and newlines are important in some places like lists and tables, make sure to adjust the tags accordingly, as they introduce newlines. + +Markdown inside
requires a blank line after . {% endcomment %} ### Documentation build overview @@ -10,16 +12,32 @@ make sure to adjust the tags accordingly, as they introduce newlines. [   ๐Ÿ” Preview build   ]({{ current_version.get_absolute_url }}) -{% if diff.files %} +{% if diff.files %}{% if diff.should_auto_expand %} +
+{{ diff.files|length }} files changed +
+{% for file in diff.added %}+ {{ file.path }}
+{% endfor %}{% for file in diff.modified %}ยฑ {{ file.path }}
+{% endfor %}{% for file in diff.deleted %}- {{ file.path }}
+{% endfor %}
+{% else %}
-Show files changed ({{ diff.files|length }} files in total): ๐Ÿ“ {{ diff.modified|length }} modified | โž• {{ diff.added|length }} added | โž– {{ diff.deleted|length }} deleted - -| File | Status | -| --- | --- | -{% for file in diff.files %}| [{{ file.path }}]({{ file.url }}) | {{ file.status.emoji }} {{ file.status }} | -{% endfor %} - +{{ diff.files|length }} files changed{% if diff.added %} ยท + {{ diff.added|length }} added{% endif %}{% if diff.modified %} ยท ยฑ {{ diff.modified|length }} modified{% endif %}{% if diff.deleted %} ยท - {{ diff.deleted|length }} deleted{% endif %} +
+{% if diff.added %} +`+` **Added** +{% for file in diff.added|slice:":10" %}- [`{{ file.path }}`]({{ file.url }}) +{% endfor %}{% if diff.added|length > 10 %}- *and {{ diff.added|length|add:"-10" }} more...* +{% endif %}{% endif %}{% if diff.modified %} +`ยฑ` **Modified** +{% for file in diff.modified|slice:":10" %}- [`{{ file.path }}`]({{ file.url }}) +{% endfor %}{% if diff.modified|length > 10 %}- *and {{ diff.modified|length|add:"-10" }} more...* +{% endif %}{% endif %}{% if diff.deleted %} +`-` **Deleted** +{% for file in diff.deleted|slice:":10" %}- [`{{ file.path }}`]({{ file.url }}) +{% endfor %}{% if diff.deleted|length > 10 %}- *and {{ diff.deleted|length|add:"-10" }} more...* +{% endif %}{% endif %}
-{% else %} +{% endif %}{% else %} No files changed. {% endif %}