kou commented on code in PR #35103:
URL: https://github.com/apache/arrow/pull/35103#discussion_r1167285094


##########
dev/release/utils-update-docs-versions.py:
##########
@@ -26,6 +26,7 @@
 
 main_versions_path = dir_path + "/docs/source/_static/versions.json"
 r_versions_path = dir_path + "/r/pkgdown/assets/versions.json"
+r_html_path = dir_path + "/r/pkgdown/assets/versions.html"

Review Comment:
   Could you add a generated HTML to this pull request?
   We should version control the HTML, right?



##########
dev/release/utils-update-docs-versions.py:
##########
@@ -87,3 +88,15 @@
 with open(r_versions_path, 'w') as json_file:
     json.dump(new_r_versions, json_file, indent=4)
     json_file.write("\n")
+
+# Load the updated versions JSON file
+with open(r_versions_path) as json_file:
+    data = json.load(json_file)
+
+# Write HTML to file
+with open(r_html_path, 'w') as html_file:
+    html_file.write('<!DOCTYPE html>\n<html>\n<body>')
+    for i in data:
+        html_file.write('<p><a href="../' + i['version'] + 'r/">' + i['name'] 
+ '</a></p>\n')

Review Comment:
   I think that `i['version']` and `i['name']` will not include any HTML 
special characters such as `<` but how about escape them for safety?
   
   ```python
   import html
   html.escape(i['version'])
   ```
   
   How about using f-string?
   
   ```suggestion
           html_file.write(f'<p><a 
href="../{i["version"]}/r/">{i["name"]}</a></p>\n')
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to