From b9ceb3ad5b0cdb05e684926d5da2715e513c8b6f Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Tue, 21 Nov 2023 09:38:44 +0900 Subject: [PATCH 01/16] Plant anchors for hunks --- .github/workflows/doc-build.yml | 65 ++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 17 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index b0f3e4566bc..3744489b34a 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -144,18 +144,32 @@ jobs: cat >> ./docs/CHANGES.html << EOF @@ -164,19 +178,36 @@ jobs: echo '' >> ./docs/CHANGES.html (cd /sage/local/share/doc/sage/html && git diff HEAD^ -- *.html; rm -rf .git) > ./docs/diff.txt /sage/sage -python - << EOF - import re, html + import os, re, html with open('./docs/diff.txt', 'r') as f: - diff_text = f.read() - diff_blocks = re.split(r'^(?=diff --git)', diff_text, flags=re.MULTILINE) - out_blocks = [] - for block in diff_blocks: - match = re.search(r'^diff --git a/(.*) b/\1', block, flags=re.MULTILINE) - if match: - path = 'html/' + match.group(1) - out_blocks.append(f'

{path}

\n
' + html.escape(block).strip() + '
') - output_text = '\n'.join(out_blocks) + diff_text = f.read() + diff_blocks = re.split(r'^(?=diff --git)', diff_text, flags=re.MULTILINE) + out_blocks = [] + for block in diff_blocks: + match = re.search(r'^diff --git a/(.*) b/\1', block, flags=re.MULTILINE) + if match: + path = 'html/' + match.group(1) + file_path = os.path.join('/sage/local/share/doc/sage', path) + with open(file_path, 'r') as file: + content = file.readlines() + count = 0 + for line in block.splitlines(): + if line.startswith('@@ -'): + line_number = int(re.search(r'@@ -(\d+)', line).group(1)) + for i in range(line_number, -1, -1): + if content[i].startswith('<'): + count += 1 + content[i] = f'' + content[i] + break + with open(file_path, 'w') as file: + file.writelines(content) + hunks = ' '.join(f'#{i+1}' for i in range(count)) + out_blocks.append(f'

{path} ' + hunks + ' 

' + + '\n
'
+                                  + html.escape(block).strip() + '
') + output_text = '\n'.join(out_blocks) with open('./docs/diff.html', 'w') as f: - f.write(output_text) + f.write(output_text) EOF cat ./docs/diff.html >> ./docs/CHANGES.html echo '' >> ./docs/CHANGES.html From aca1279eb1d1d2a57d9de3c4b6369565fced698d Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Tue, 21 Nov 2023 13:28:44 +0900 Subject: [PATCH 02/16] Fix a typo --- .github/workflows/doc-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 3744489b34a..2721d5b420a 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -149,7 +149,7 @@ jobs: const diffParagraphs = document.querySelectorAll('p.diff'); diffParagraphs.forEach(paragraph => { const rootURL = window.location.origin; - const docAnchor = paragraph.querySelector('a'); # first "a" element + const docAnchor = paragraph.querySelector('a'); // first "a" element const url = new URL(docAnchor.href); const path = url.pathname; const anchor = document.createElement('a'); From 99eb4f354ec976c57ae6dbb5f481cb0b7878ecb1 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 24 Nov 2023 14:42:33 +0900 Subject: [PATCH 03/16] Split out script --- .ci/create-changes-html.sh | 92 +++++++++++++++++++++++++++++ .github/workflows/doc-build.yml | 100 ++++---------------------------- 2 files changed, 102 insertions(+), 90 deletions(-) create mode 100755 .ci/create-changes-html.sh diff --git a/.ci/create-changes-html.sh b/.ci/create-changes-html.sh new file mode 100755 index 00000000000..8399048c830 --- /dev/null +++ b/.ci/create-changes-html.sh @@ -0,0 +1,92 @@ +#!/bin/sh +if [ $# != 2 ]; then + echo >&2 "usage: $0 BASE_DOC_COMMIT DOC_REPOSITORY" + echo >&2 "Ensures that DOC_REPOSITORY is a git repository," + echo >&2 "then creates CHANGES.html in the docs subdirectory" + echo >&2 "for the diffs of DOC_REPOSITORY against BASE_DOC_COMMIT" +fi +BASE_DOC_COMMIT="$1" +DOC_REPOSITORY="$2" + +mkdir -p ./docs +(cd $DOC_REPOSITORY && git commit -a -m 'new') +# Wipe out chronic diffs between old doc and new doc +(cd $DOC_REPOSITORY && find . -name "*.html" | xargs sed -i -e '\;; d') +# Create CHANGES.html +echo '' > ./docs/CHANGES.html +echo '' >> ./docs/CHANGES.html +echo '' >> ./docs/CHANGES.html +echo '' >> ./docs/CHANGES.html +echo '' >> ./docs/CHANGES.html +cat >> ./docs/CHANGES.html << EOF + +EOF +echo '' >> ./docs/CHANGES.html +echo '' >> ./docs/CHANGES.html +(cd $DOC_REPOSITORY && git diff $BASE_DOC_COMMIT -- *.html; rm -rf .git) > ./docs/diff.txt +/sage/sage -python - << EOF +import os, re, html +with open('./docs/diff.txt', 'r') as f: +diff_text = f.read() +diff_blocks = re.split(r'^(?=diff --git)', diff_text, flags=re.MULTILINE) +out_blocks = [] +for block in diff_blocks: + match = re.search(r'^diff --git a/(.*) b/\1', block, flags=re.MULTILINE) + if match: + path = 'html/' + match.group(1) + file_path = os.path.join('/sage/local/share/doc/sage', path) + with open(file_path, 'r') as file: + content = file.readlines() + count = 0 + for line in block.splitlines(): + if line.startswith('@@ -'): + line_number = int(re.search(r'@@ -(\d+)', line).group(1)) + for i in range(line_number, -1, -1): + if content[i].startswith('<'): + count += 1 + content[i] = f'' + content[i] + break + with open(file_path, 'w') as file: + file.writelines(content) + hunks = ' '.join(f'#{i+1}' for i in range(count)) + out_blocks.append(f'

{path} ' + hunks + ' 

' + + '\n
'
+                      + html.escape(block).strip() + '
') +output_text = '\n'.join(out_blocks) +with open('./docs/diff.html', 'w') as f: +f.write(output_text) +EOF +cat ./docs/diff.html >> ./docs/CHANGES.html +echo '' >> ./docs/CHANGES.html +echo '' >>./docs/CHANGES.html +rm ./docs/diff.txt ./docs/diff.html diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 2721d5b420a..7ef2b0e406e 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -68,8 +68,8 @@ jobs: -e 's;'"$mathjax_path_from"';'"$mathjax_path_to"';' \ -e '\;; d') # Create git repo from old doc - (cd /sage/local/share/doc/sage/html && \ - git init && \ + DOC_DIR=/sage/local/share/doc/sage/html + (cd $DOC_DIR && git init && \ (echo "*.svg binary"; echo "*.pdf binary") >> .gitattributes && \ (echo ".buildinfo"; echo '*.inv'; echo '.git*'; echo '*.svg'; echo '*.pdf'; echo '*.png'; echo 'searchindex.js') > .gitignore; \ git add -A && git commit --quiet -m "old") @@ -115,10 +115,11 @@ jobs: # incremental docbuild may introduce broken links (inter-file references) though build succeeds run: | set -ex - export SAGE_USE_CDNS=yes - mv /sage/local/share/doc/sage/html/.git /sage/.git-doc + DOC_DIR=/sage/local/share/doc/sage/html + mv $DOC_DIR/.git /sage/.git-doc make doc-clean doc-uninstall - mkdir -p /sage/local/share/doc/sage/html/ && mv /sage/.git-doc /sage/local/share/doc/sage/html/.git + mkdir -p $DOC_DIR/ && mv /sage/.git-doc $DOC_DIR/.git + export SAGE_USE_CDNS=yes ./config.status && make sagemath_doc_html-no-deps working-directory: ./worktree-image env: @@ -130,94 +131,13 @@ jobs: if: (success() || failure()) && steps.docbuild.outcome == 'success' run: | set -ex - mkdir -p ./docs - (cd /sage/local/share/doc/sage/html && git commit -a -m 'new') - # Wipe out chronic diffs between old doc and new doc - (cd /sage/local/share/doc/sage/html && \ - find . -name "*.html" | xargs sed -i -e '\;; d') - # Create CHANGES.html - echo '' > ./docs/CHANGES.html - echo '' >> ./docs/CHANGES.html - echo '' >> ./docs/CHANGES.html - echo '' >> ./docs/CHANGES.html - echo '' >> ./docs/CHANGES.html - cat >> ./docs/CHANGES.html << EOF - - EOF - echo '' >> ./docs/CHANGES.html - echo '' >> ./docs/CHANGES.html - (cd /sage/local/share/doc/sage/html && git diff HEAD^ -- *.html; rm -rf .git) > ./docs/diff.txt - /sage/sage -python - << EOF - import os, re, html - with open('./docs/diff.txt', 'r') as f: - diff_text = f.read() - diff_blocks = re.split(r'^(?=diff --git)', diff_text, flags=re.MULTILINE) - out_blocks = [] - for block in diff_blocks: - match = re.search(r'^diff --git a/(.*) b/\1', block, flags=re.MULTILINE) - if match: - path = 'html/' + match.group(1) - file_path = os.path.join('/sage/local/share/doc/sage', path) - with open(file_path, 'r') as file: - content = file.readlines() - count = 0 - for line in block.splitlines(): - if line.startswith('@@ -'): - line_number = int(re.search(r'@@ -(\d+)', line).group(1)) - for i in range(line_number, -1, -1): - if content[i].startswith('<'): - count += 1 - content[i] = f'' + content[i] - break - with open(file_path, 'w') as file: - file.writelines(content) - hunks = ' '.join(f'#{i+1}' for i in range(count)) - out_blocks.append(f'

{path} ' + hunks + ' 

' - + '\n
'
-                                  + html.escape(block).strip() + '
') - output_text = '\n'.join(out_blocks) - with open('./docs/diff.html', 'w') as f: - f.write(output_text) - EOF - cat ./docs/diff.html >> ./docs/CHANGES.html - echo '' >> ./docs/CHANGES.html - echo '' >>./docs/CHANGES.html - rm ./docs/diff.txt ./docs/diff.html + DOC_DIR=/sage/local/share/doc/sage/html + .ci/create-doc-diffs-page.sh $(cd $DOC_DIR; git rev-parse HEAD^) $DOC_DIR # For some reason the deploy step below cannot find /sage/... # So copy everything from there to local folder # We also need to replace the symlinks because netlify is not following them - cp -r -L /sage/local/share/doc/sage/html ./docs - cp /sage/local/share/doc/sage/index.html ./docs + cp -r -L $DOC_DIR ./docs + cp $DOC_DIR/../index.html ./docs # Zip everything for increased performance zip -r docs.zip docs From fed139e5a9cd5525232c990d0056e343f3ac1960 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 24 Nov 2023 14:46:02 +0900 Subject: [PATCH 04/16] Error if wrong arguments --- .ci/create-changes-html.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.ci/create-changes-html.sh b/.ci/create-changes-html.sh index 8399048c830..aa45b810d79 100755 --- a/.ci/create-changes-html.sh +++ b/.ci/create-changes-html.sh @@ -4,6 +4,7 @@ if [ $# != 2 ]; then echo >&2 "Ensures that DOC_REPOSITORY is a git repository," echo >&2 "then creates CHANGES.html in the docs subdirectory" echo >&2 "for the diffs of DOC_REPOSITORY against BASE_DOC_COMMIT" + exit 1 fi BASE_DOC_COMMIT="$1" DOC_REPOSITORY="$2" From 0265da1aa93652d1d7c1f281108c1e48ed1be6ad Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 24 Nov 2023 14:49:11 +0900 Subject: [PATCH 05/16] Make script name right --- .github/workflows/doc-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 7ef2b0e406e..b4964e4e163 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -132,7 +132,7 @@ jobs: run: | set -ex DOC_DIR=/sage/local/share/doc/sage/html - .ci/create-doc-diffs-page.sh $(cd $DOC_DIR; git rev-parse HEAD^) $DOC_DIR + .ci/create-changes-html.sh $(cd $DOC_DIR; git rev-parse HEAD^) $DOC_DIR # For some reason the deploy step below cannot find /sage/... # So copy everything from there to local folder # We also need to replace the symlinks because netlify is not following them From 380cc8e705d93ef4bb384e22543fc1da5c76dd88 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 24 Nov 2023 14:51:30 +0900 Subject: [PATCH 06/16] Fix help text --- .ci/create-changes-html.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.ci/create-changes-html.sh b/.ci/create-changes-html.sh index aa45b810d79..9aa3e31b0f6 100755 --- a/.ci/create-changes-html.sh +++ b/.ci/create-changes-html.sh @@ -1,8 +1,7 @@ #!/bin/sh if [ $# != 2 ]; then echo >&2 "usage: $0 BASE_DOC_COMMIT DOC_REPOSITORY" - echo >&2 "Ensures that DOC_REPOSITORY is a git repository," - echo >&2 "then creates CHANGES.html in the docs subdirectory" + echo >&2 "creates CHANGES.html in the docs subdirectory" echo >&2 "for the diffs of DOC_REPOSITORY against BASE_DOC_COMMIT" exit 1 fi From e8a63abbcf8a23174c24efc61895eedbbf64238a Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 24 Nov 2023 16:04:26 +0900 Subject: [PATCH 07/16] Fix indentation --- .ci/create-changes-html.sh | 47 ++++++++++++++++----------------- .github/workflows/doc-build.yml | 1 + 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.ci/create-changes-html.sh b/.ci/create-changes-html.sh index 9aa3e31b0f6..05a41e5f521 100755 --- a/.ci/create-changes-html.sh +++ b/.ci/create-changes-html.sh @@ -9,7 +9,6 @@ BASE_DOC_COMMIT="$1" DOC_REPOSITORY="$2" mkdir -p ./docs -(cd $DOC_REPOSITORY && git commit -a -m 'new') # Wipe out chronic diffs between old doc and new doc (cd $DOC_REPOSITORY && find . -name "*.html" | xargs sed -i -e '\;; d') # Create CHANGES.html @@ -57,34 +56,34 @@ echo '' >> ./docs/CHANGES.html /sage/sage -python - << EOF import os, re, html with open('./docs/diff.txt', 'r') as f: -diff_text = f.read() + diff_text = f.read() diff_blocks = re.split(r'^(?=diff --git)', diff_text, flags=re.MULTILINE) out_blocks = [] for block in diff_blocks: - match = re.search(r'^diff --git a/(.*) b/\1', block, flags=re.MULTILINE) - if match: - path = 'html/' + match.group(1) - file_path = os.path.join('/sage/local/share/doc/sage', path) - with open(file_path, 'r') as file: - content = file.readlines() - count = 0 - for line in block.splitlines(): - if line.startswith('@@ -'): - line_number = int(re.search(r'@@ -(\d+)', line).group(1)) - for i in range(line_number, -1, -1): - if content[i].startswith('<'): - count += 1 - content[i] = f'' + content[i] - break - with open(file_path, 'w') as file: - file.writelines(content) - hunks = ' '.join(f'#{i+1}' for i in range(count)) - out_blocks.append(f'

{path} ' + hunks + ' 

' - + '\n
'
-                      + html.escape(block).strip() + '
') + match = re.search(r'^diff --git a/(.*) b/\1', block, flags=re.MULTILINE) + if match: + path = 'html/' + match.group(1) + file_path = os.path.join('$DOC_REPOSITORY/..', path) + with open(file_path, 'r') as file: + content = file.readlines() + count = 0 + for line in block.splitlines(): + if line.startswith('@@ -'): + line_number = int(re.search(r'@@ -(\d+)', line).group(1)) + for i in range(line_number, -1, -1): + if content[i].startswith('<'): + count += 1 + content[i] = f'' + content[i] + break + with open(file_path, 'w') as file: + file.writelines(content) + hunks = ' '.join(f'#{i+1}' for i in range(count)) + out_blocks.append(f'

{path} ' + hunks + ' 

' + + '\n
'
+                            + html.escape(block).strip() + '
') output_text = '\n'.join(out_blocks) with open('./docs/diff.html', 'w') as f: -f.write(output_text) + f.write(output_text) EOF cat ./docs/diff.html >> ./docs/CHANGES.html echo '' >> ./docs/CHANGES.html diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index b4964e4e163..46e4e3badb2 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -132,6 +132,7 @@ jobs: run: | set -ex DOC_DIR=/sage/local/share/doc/sage/html + (cd $DOC_DIR && git commit -a -m 'new') .ci/create-changes-html.sh $(cd $DOC_DIR; git rev-parse HEAD^) $DOC_DIR # For some reason the deploy step below cannot find /sage/... # So copy everything from there to local folder From b637cc13307061f60edbb137ed554438a54866cf Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 24 Nov 2023 16:50:52 +0900 Subject: [PATCH 08/16] Separate the script more --- .ci/create-changes-html.sh | 29 ++++++++++++++--------------- .github/workflows/doc-build.yml | 6 ++++-- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.ci/create-changes-html.sh b/.ci/create-changes-html.sh index 05a41e5f521..76f13650a64 100755 --- a/.ci/create-changes-html.sh +++ b/.ci/create-changes-html.sh @@ -1,23 +1,22 @@ #!/bin/sh if [ $# != 2 ]; then echo >&2 "usage: $0 BASE_DOC_COMMIT DOC_REPOSITORY" - echo >&2 "creates CHANGES.html in the docs subdirectory" + echo >&2 "creates CHANGES.html in the current directory" echo >&2 "for the diffs of DOC_REPOSITORY against BASE_DOC_COMMIT" exit 1 fi BASE_DOC_COMMIT="$1" DOC_REPOSITORY="$2" -mkdir -p ./docs # Wipe out chronic diffs between old doc and new doc (cd $DOC_REPOSITORY && find . -name "*.html" | xargs sed -i -e '\;; d') # Create CHANGES.html -echo '' > ./docs/CHANGES.html -echo '' >> ./docs/CHANGES.html -echo '' >> ./docs/CHANGES.html -echo '' >> ./docs/CHANGES.html -echo '' >> ./docs/CHANGES.html -cat >> ./docs/CHANGES.html << EOF +echo '' > CHANGES.html +echo '' >> CHANGES.html +echo '' >> CHANGES.html +echo '' >> CHANGES.html +echo '' >> CHANGES.html +cat >> CHANGES.html << EOF EOF -echo '' >> ./docs/CHANGES.html -echo '' >> ./docs/CHANGES.html -(cd $DOC_REPOSITORY && git diff $BASE_DOC_COMMIT -- *.html; rm -rf .git) > ./docs/diff.txt +echo '' >> CHANGES.html +echo '' >> CHANGES.html +(cd $DOC_REPOSITORY && git diff $BASE_DOC_COMMIT -- *.html) > diff.txt /sage/sage -python - << EOF import os, re, html with open('./docs/diff.txt', 'r') as f: @@ -85,7 +84,7 @@ output_text = '\n'.join(out_blocks) with open('./docs/diff.html', 'w') as f: f.write(output_text) EOF -cat ./docs/diff.html >> ./docs/CHANGES.html -echo '' >> ./docs/CHANGES.html -echo '' >>./docs/CHANGES.html -rm ./docs/diff.txt ./docs/diff.html +cat diff.html >> CHANGES.html +echo '' >> CHANGES.html +echo '' >> CHANGES.html +rm diff.txt diff.html diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 46e4e3badb2..b83c1c801be 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -134,9 +134,11 @@ jobs: DOC_DIR=/sage/local/share/doc/sage/html (cd $DOC_DIR && git commit -a -m 'new') .ci/create-changes-html.sh $(cd $DOC_DIR; git rev-parse HEAD^) $DOC_DIR - # For some reason the deploy step below cannot find /sage/... - # So copy everything from there to local folder + (cd $DOC_DIR && rm -rf .git) + # We copy everything to a local folder # We also need to replace the symlinks because netlify is not following them + mkdir -p ./docs + mv CHANGES.html ./docs cp -r -L $DOC_DIR ./docs cp $DOC_DIR/../index.html ./docs # Zip everything for increased performance From 65a5e01c7a1b947fe74d65ed5aa37ece7c5e6706 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 24 Nov 2023 17:03:42 +0900 Subject: [PATCH 09/16] Remove ./docs prefix --- .ci/create-changes-html.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.ci/create-changes-html.sh b/.ci/create-changes-html.sh index 76f13650a64..f4d85ec503b 100755 --- a/.ci/create-changes-html.sh +++ b/.ci/create-changes-html.sh @@ -54,15 +54,16 @@ echo '' >> CHANGES.html (cd $DOC_REPOSITORY && git diff $BASE_DOC_COMMIT -- *.html) > diff.txt /sage/sage -python - << EOF import os, re, html -with open('./docs/diff.txt', 'r') as f: +with open('diff.txt', 'r') as f: diff_text = f.read() diff_blocks = re.split(r'^(?=diff --git)', diff_text, flags=re.MULTILINE) out_blocks = [] for block in diff_blocks: match = re.search(r'^diff --git a/(.*) b/\1', block, flags=re.MULTILINE) if match: - path = 'html/' + match.group(1) - file_path = os.path.join('$DOC_REPOSITORY/..', path) + doc = match.group(1) + path = 'html/' + doc + file_path = os.path.join('$DOC_REPOSITORY', doc) with open(file_path, 'r') as file: content = file.readlines() count = 0 @@ -76,12 +77,12 @@ for block in diff_blocks: break with open(file_path, 'w') as file: file.writelines(content) - hunks = ' '.join(f'#{i+1}' for i in range(count)) - out_blocks.append(f'

{path} ' + hunks + ' 

' + hunks = ' '.join(f'#{i + 1}' for i in range(count)) + out_blocks.append(f'

{doc} ' + hunks + ' 

' + '\n
'
                             + html.escape(block).strip() + '
') output_text = '\n'.join(out_blocks) -with open('./docs/diff.html', 'w') as f: +with open('diff.html', 'w') as f: f.write(output_text) EOF cat diff.html >> CHANGES.html From bd423eb23c204f75c1561ab791365cb8e8daa081 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Sat, 25 Nov 2023 17:06:14 +0900 Subject: [PATCH 10/16] Use system python --- .ci/create-changes-html.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/create-changes-html.sh b/.ci/create-changes-html.sh index f4d85ec503b..80e5a389959 100755 --- a/.ci/create-changes-html.sh +++ b/.ci/create-changes-html.sh @@ -52,7 +52,7 @@ EOF echo '' >> CHANGES.html echo '' >> CHANGES.html (cd $DOC_REPOSITORY && git diff $BASE_DOC_COMMIT -- *.html) > diff.txt -/sage/sage -python - << EOF +python - << EOF import os, re, html with open('diff.txt', 'r') as f: diff_text = f.read() From 00778d7ba4c23ecf675effec5790f191b56e3f06 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Sat, 25 Nov 2023 18:55:37 +0900 Subject: [PATCH 11/16] Supply Sage root --- .ci/create-changes-html.sh | 7 ++++--- .github/workflows/doc-build.yml | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.ci/create-changes-html.sh b/.ci/create-changes-html.sh index 80e5a389959..6034e20e153 100755 --- a/.ci/create-changes-html.sh +++ b/.ci/create-changes-html.sh @@ -1,12 +1,13 @@ #!/bin/sh if [ $# != 2 ]; then - echo >&2 "usage: $0 BASE_DOC_COMMIT DOC_REPOSITORY" + echo >&2 "usage: $0 BASE_DOC_COMMIT DOC_REPO SAGE_ROOT" echo >&2 "creates CHANGES.html in the current directory" - echo >&2 "for the diffs of DOC_REPOSITORY against BASE_DOC_COMMIT" + echo >&2 "for the diffs of DOC_REPO against BASE_DOC_COMMIT" exit 1 fi BASE_DOC_COMMIT="$1" DOC_REPOSITORY="$2" +SAGE_ROOT="$3" # Wipe out chronic diffs between old doc and new doc (cd $DOC_REPOSITORY && find . -name "*.html" | xargs sed -i -e '\;; d') @@ -52,7 +53,7 @@ EOF echo '' >> CHANGES.html echo '' >> CHANGES.html (cd $DOC_REPOSITORY && git diff $BASE_DOC_COMMIT -- *.html) > diff.txt -python - << EOF +$SAGE_ROOT/sage -python - << EOF import os, re, html with open('diff.txt', 'r') as f: diff_text = f.read() diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index b83c1c801be..9ba52f28595 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -131,9 +131,10 @@ jobs: if: (success() || failure()) && steps.docbuild.outcome == 'success' run: | set -ex + SAGE_ROOT=/sage DOC_DIR=/sage/local/share/doc/sage/html (cd $DOC_DIR && git commit -a -m 'new') - .ci/create-changes-html.sh $(cd $DOC_DIR; git rev-parse HEAD^) $DOC_DIR + .ci/create-changes-html.sh $(cd $DOC_DIR; git rev-parse HEAD^) $DOC_DIR $SAGE_ROOT (cd $DOC_DIR && rm -rf .git) # We copy everything to a local folder # We also need to replace the symlinks because netlify is not following them From e1242810386725586412c673c4c08d231ef34eca Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Sat, 25 Nov 2023 19:47:14 +0900 Subject: [PATCH 12/16] There are 3 arguments to the script --- .ci/create-changes-html.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/create-changes-html.sh b/.ci/create-changes-html.sh index 6034e20e153..ff0ae4cd131 100755 --- a/.ci/create-changes-html.sh +++ b/.ci/create-changes-html.sh @@ -1,5 +1,5 @@ #!/bin/sh -if [ $# != 2 ]; then +if [ $# != 3 ]; then echo >&2 "usage: $0 BASE_DOC_COMMIT DOC_REPO SAGE_ROOT" echo >&2 "creates CHANGES.html in the current directory" echo >&2 "for the diffs of DOC_REPO against BASE_DOC_COMMIT" From ac82ac4c61adab26df2a826cd3b38a576f9e18cd Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Sun, 26 Nov 2023 06:36:20 +0900 Subject: [PATCH 13/16] Better solution for using python --- .ci/create-changes-html.sh | 7 +++---- .github/workflows/doc-build.yml | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.ci/create-changes-html.sh b/.ci/create-changes-html.sh index ff0ae4cd131..fe112616be5 100755 --- a/.ci/create-changes-html.sh +++ b/.ci/create-changes-html.sh @@ -1,13 +1,12 @@ #!/bin/sh -if [ $# != 3 ]; then - echo >&2 "usage: $0 BASE_DOC_COMMIT DOC_REPO SAGE_ROOT" +if [ $# != 2 ]; then + echo >&2 "usage: $0 BASE_DOC_COMMIT DOC_REPO" echo >&2 "creates CHANGES.html in the current directory" echo >&2 "for the diffs of DOC_REPO against BASE_DOC_COMMIT" exit 1 fi BASE_DOC_COMMIT="$1" DOC_REPOSITORY="$2" -SAGE_ROOT="$3" # Wipe out chronic diffs between old doc and new doc (cd $DOC_REPOSITORY && find . -name "*.html" | xargs sed -i -e '\;; d') @@ -53,7 +52,7 @@ EOF echo '' >> CHANGES.html echo '' >> CHANGES.html (cd $DOC_REPOSITORY && git diff $BASE_DOC_COMMIT -- *.html) > diff.txt -$SAGE_ROOT/sage -python - << EOF +python - << EOF import os, re, html with open('diff.txt', 'r') as f: diff_text = f.read() diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 9ba52f28595..72bf285226a 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -131,10 +131,9 @@ jobs: if: (success() || failure()) && steps.docbuild.outcome == 'success' run: | set -ex - SAGE_ROOT=/sage DOC_DIR=/sage/local/share/doc/sage/html (cd $DOC_DIR && git commit -a -m 'new') - .ci/create-changes-html.sh $(cd $DOC_DIR; git rev-parse HEAD^) $DOC_DIR $SAGE_ROOT + PATH=/sage/venv/bin:$PATH .ci/create-changes-html.sh $(cd $DOC_DIR; git rev-parse HEAD^) $DOC_DIR $SAGE_ROOT (cd $DOC_DIR && rm -rf .git) # We copy everything to a local folder # We also need to replace the symlinks because netlify is not following them From e1388ba683737c99867d08918a3ea568d3d2a00f Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Sun, 26 Nov 2023 15:09:26 +0900 Subject: [PATCH 14/16] Remove --- .github/workflows/doc-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 72bf285226a..c82e94b7790 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -133,7 +133,7 @@ jobs: set -ex DOC_DIR=/sage/local/share/doc/sage/html (cd $DOC_DIR && git commit -a -m 'new') - PATH=/sage/venv/bin:$PATH .ci/create-changes-html.sh $(cd $DOC_DIR; git rev-parse HEAD^) $DOC_DIR $SAGE_ROOT + PATH=/sage/venv/bin:$PATH .ci/create-changes-html.sh $(cd $DOC_DIR; git rev-parse HEAD^) $DOC_DIR (cd $DOC_DIR && rm -rf .git) # We copy everything to a local folder # We also need to replace the symlinks because netlify is not following them From 976c1b3acdc7324796381e0c8511f51d2a0ca163 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Sun, 26 Nov 2023 18:45:56 +0900 Subject: [PATCH 15/16] This seems to make a difference --- .ci/create-changes-html.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/create-changes-html.sh b/.ci/create-changes-html.sh index fe112616be5..a31b38ac663 100755 --- a/.ci/create-changes-html.sh +++ b/.ci/create-changes-html.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/sh if [ $# != 2 ]; then echo >&2 "usage: $0 BASE_DOC_COMMIT DOC_REPO" echo >&2 "creates CHANGES.html in the current directory" From 7b0c6705eeabbc68682747f9986686873a68a99e Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Sun, 26 Nov 2023 19:11:23 +0900 Subject: [PATCH 16/16] Second attempt --- .ci/create-changes-html.sh | 4 ++-- .github/workflows/doc-build.yml | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.ci/create-changes-html.sh b/.ci/create-changes-html.sh index a31b38ac663..1a6fbeef27b 100755 --- a/.ci/create-changes-html.sh +++ b/.ci/create-changes-html.sh @@ -1,4 +1,4 @@ -#!/usr/bin/sh +#!/bin/sh if [ $# != 2 ]; then echo >&2 "usage: $0 BASE_DOC_COMMIT DOC_REPO" echo >&2 "creates CHANGES.html in the current directory" @@ -52,7 +52,7 @@ EOF echo '' >> CHANGES.html echo '' >> CHANGES.html (cd $DOC_REPOSITORY && git diff $BASE_DOC_COMMIT -- *.html) > diff.txt -python - << EOF +python3 - << EOF import os, re, html with open('diff.txt', 'r') as f: diff_text = f.read() diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index c82e94b7790..e4806d4815b 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -133,6 +133,7 @@ jobs: set -ex DOC_DIR=/sage/local/share/doc/sage/html (cd $DOC_DIR && git commit -a -m 'new') + ls -l /sage/venv/bin PATH=/sage/venv/bin:$PATH .ci/create-changes-html.sh $(cd $DOC_DIR; git rev-parse HEAD^) $DOC_DIR (cd $DOC_DIR && rm -rf .git) # We copy everything to a local folder