Skip to content

Commit 7ef39dd

Browse files
author
Release Manager
committed
gh-36888: Fix failure of doc preview changes when an html is removed Fixes #36887. Tested with #36892 and #36885. <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> - #36871 <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #36888 Reported by: Kwankyu Lee Reviewer(s):
2 parents 8ba4c46 + 778195a commit 7ef39dd

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

.ci/create-changes-html.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,12 @@ for block in diff_blocks:
6262
match = re.search(r'^diff --git a/(.*) b/\1', block, flags=re.MULTILINE)
6363
if match:
6464
doc = match.group(1)
65-
path = 'html/' + doc
6665
file_path = os.path.join('$DOC_REPOSITORY', doc)
67-
with open(file_path, 'r') as file:
68-
content = file.readlines()
66+
try:
67+
with open(file_path, 'r') as file:
68+
content = file.readlines()
69+
except FileNotFoundError:
70+
content = []
6971
count = 0
7072
for line in block.splitlines():
7173
if line.startswith('@@ -'):
@@ -77,8 +79,10 @@ for block in diff_blocks:
7779
count += 1
7880
content[i] = f'<span id="hunk{count}" style="visibility: hidden;"></span>' + content[i]
7981
break
80-
with open(file_path, 'w') as file:
81-
file.writelines(content)
82+
if content:
83+
with open(file_path, 'w') as file:
84+
file.writelines(content)
85+
path = 'html/' + doc
8286
hunks = '&nbsp;'.join(f'<a href="{path}#hunk{i+1}" class="hunk" target="_blank">#{i + 1}</a>' for i in range(count))
8387
out_blocks.append(f'<p class="diff"><a href="{path}">{doc}</a>&nbsp;' + hunks + '&emsp;</p>'
8488
+ '\n<pre><code class="language-diff">'

0 commit comments

Comments
 (0)