Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8015a0a
.github/workflows/doc-build.yml: Repair display of changed output fil…
mkoeppe Oct 17, 2023
d2e3297
Merge branch 'ci_docbuild_really_incremental' into doc_html_changes
mkoeppe Oct 17, 2023
7e5a6d8
.github/workflows/doc-build.yml: Do not duplicate the URL configured …
mkoeppe Oct 19, 2023
410d9a4
Merge branch 'ci_refactor_build' into doc_html_changes
mkoeppe Oct 19, 2023
6d7bcf9
.github/workflows/doc-build.yml: Do not duplicate the URL configured …
mkoeppe Oct 19, 2023
76c8549
.github/workflows/doc-build.yml: Use make sagemath_doc_html-build-dep…
mkoeppe Oct 19, 2023
cd1a3ec
Remove lambdas from arguments
kwankyu Oct 19, 2023
304d1e2
Merge branch 'p/36475/doc_html_changes' into remove-spurious-doc-diffs
kwankyu Oct 19, 2023
0baa6de
Improve doc-build.yml
kwankyu Oct 19, 2023
c1d6704
Add back comma
kwankyu Oct 19, 2023
db5613a
Minor error
kwankyu Oct 19, 2023
07b17c6
Compare with the old doc
kwankyu Oct 19, 2023
5a7d593
Put on cosmetics
kwankyu Oct 19, 2023
5be55e8
diff.html not html.diff
kwankyu Oct 19, 2023
46b8692
Sanitize text for html
kwankyu Oct 19, 2023
b3df3d6
Reformat CHANGES.html
kwankyu Oct 20, 2023
ce5595b
Use sage python
kwankyu Oct 20, 2023
5de3957
Use here document for python script
kwankyu Oct 20, 2023
2c04ca0
Fix an error
kwankyu Oct 20, 2023
b5b49e2
Use diffsite
kwankyu Oct 20, 2023
6522884
Fix urls
kwankyu Oct 20, 2023
15381f7
Minor tweak
kwankyu Oct 20, 2023
228cb67
Change delimiters
kwankyu Oct 20, 2023
3013bd5
Remove another spurious diff
kwankyu Oct 20, 2023
c81d50f
Remove preview
kwankyu Oct 21, 2023
67e7f95
Merge branch 'develop' into remove-spurious-doc-diffs
kwankyu Oct 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 71 additions & 11 deletions .github/workflows/doc-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,23 @@ jobs:
git config --global --add safe.directory $(pwd)
git config --global user.email "[email protected]"
git config --global user.name "Build & Test workflow"
# mathjax path in old doc
mathjax_path_from=$(SAGE_USE_CDNS=no /sage/sage -python -c "from sage_docbuild.conf import mathjax_path; print(mathjax_path)")
.ci/retrofit-worktree.sh worktree-image /sage
# Keep track of changes to built HTML
new_version=$(cat src/VERSION.txt); (cd /sage/local/share/doc/sage/html/en && find . -name "*.html" | xargs sed -i '/class="sidebar-brand-text"/s/Sage [0-9a-z.]* /Sage '$new_version' /'; 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")
# mathjax path in new doc
mathjax_path_to=$(SAGE_USE_CDNS=yes /sage/sage -python -c "from sage_docbuild.conf import mathjax_path; print(mathjax_path)")
new_version=$(cat src/VERSION.txt)
# Wipe out chronic diffs between old doc and new doc
(cd /sage/local/share/doc/sage/html/en && \
find . -name "*.html" | xargs sed -i -e '/class="sidebar-brand-text"/ s/Sage [0-9a-z.]* /Sage '"$new_version"' /' \
-e 's;'"$mathjax_path_from"';'"$mathjax_path_to"';' \
-e '\;<script type="application/vnd\.jupyter\.widget-state+json">;,\;</script>; d')
# Create git repo from old doc
(cd /sage/local/share/doc/sage/html/en && \
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")

- name: Download upstream artifact
uses: actions/download-artifact@v3
Expand All @@ -77,7 +91,7 @@ jobs:
id: incremental
run: |
# Now re-bootstrap and build. The build is incremental because we were careful with the timestamps.
./bootstrap && make build
./bootstrap && make sagemath_doc_html-build-deps
working-directory: ./worktree-image
env:
MAKE: make -j2 --output-sync=recurse
Expand All @@ -88,7 +102,7 @@ jobs:
if: always() && steps.worktree.outcome == 'success' && steps.incremental.outcome != 'success'
run: |
set -ex
make sagelib-clean && git clean -fx src/sage && ./config.status && make build
make sagelib-clean && git clean -fx src/sage && ./config.status && make sagemath_doc_html-build-deps
working-directory: ./worktree-image
env:
MAKE: make -j2 --output-sync=recurse
Expand All @@ -105,7 +119,7 @@ jobs:
mv /sage/local/share/doc/sage/html/en/.git /sage/.git-doc
make doc-clean doc-uninstall
mkdir -p /sage/local/share/doc/sage/html/en/ && mv /sage/.git-doc /sage/local/share/doc/sage/html/en/.git
./config.status && make doc-html
./config.status && make sagemath_doc_html-no-deps
working-directory: ./worktree-image
env:
MAKE: make -j2 --output-sync=recurse
Expand All @@ -117,12 +131,58 @@ jobs:
run: |
set -ex
mkdir -p ./docs
# Create changelog
echo '## Preview of CHANGES.html'
(cd /sage/local/share/doc/sage/html/en && git diff --name-only) | tee ./docs/CHANGES.txt
(cd /sage/local/share/doc/sage/html/en && git diff; rm -rf .git) > ./docs/html.diff
echo '## Preview of html.diff'; head -n 400 ./docs/html.diff
(echo '<p><a href="html.diff">HTML diff</a>'; sed -E 's,(.*),<p><a href="\1">\1</a>,' ./docs/CHANGES.txt) > ./docs/CHANGES.html
(cd /sage/local/share/doc/sage/html/en && git commit -a -m 'new')
# Wipe out chronic diffs between old doc and new doc
(cd /sage/local/share/doc/sage/html/en && \
find . -name "*.html" | xargs sed -i -e '\;<script type="application/vnd\.jupyter\.widget-state+json">;,\;</script>; d')
# Create CHANGES.html
echo '<html>' > ./docs/CHANGES.html
echo '<head>' >> ./docs/CHANGES.html
echo '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">' >> ./docs/CHANGES.html
echo '<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>' >> ./docs/CHANGES.html
echo '<script>hljs.highlightAll();</script>' >> ./docs/CHANGES.html
cat >> ./docs/CHANGES.html << EOF
<script>
document.addEventListener('DOMContentLoaded', () => {
const diffSite = 'https://pianomister.github.io/diffsite/'
const baseDocURL = 'https://sagemath-tobias.netlify.app/'
const diffParagraphs = document.querySelectorAll('p.diff');
diffParagraphs.forEach(paragraph => {
const rootURL = window.location.origin + '/';
const docAnchor = paragraph.querySelector('a');
const path = docAnchor.textContent; // .href doesn't work
const anchor = document.createElement('a');
anchor.href = diffSite + '?url1=' + rootURL + path + '&url2=' + baseDocURL + path;
anchor.textContent = 'compare with the base';
anchor.setAttribute('target', '_blank');
paragraph.appendChild(anchor);
});
});
</script>
EOF
echo '</head>' >> ./docs/CHANGES.html
echo '<body>' >> ./docs/CHANGES.html
(cd /sage/local/share/doc/sage/html/en && git diff HEAD^; rm -rf .git) > ./docs/diff.txt
/sage/sage -python - << EOF
import 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 = match.group(1)
out_blocks.append(f'<p class="diff"><a href="{path}">{path}</a>&emsp;</p>\n<pre><code class="language-diff">' + html.escape(block).strip() + '</code></pre>')
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 '</body>' >> ./docs/CHANGES.html
echo '</html>' >>./docs/CHANGES.html
rm ./docs/diff.txt ./docs/diff.html
(cd /sage/local/share/doc/sage/html/en && git reset --hard HEAD)
# 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
Expand Down
4 changes: 3 additions & 1 deletion src/sage/calculus/transforms/dft.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def plot(self):
S = self.list()
return line([[RR(I[i]), RR(S[i])] for i in range(len(I) - 1)])

def dft(self, chi=lambda x: x):
def dft(self, chi=None):
r"""
A discrete Fourier transform "over `\QQ`" using exact
`N`-th roots of unity.
Expand Down Expand Up @@ -340,6 +340,8 @@ def dft(self, chi=lambda x: x):
implemented Group (permutation, matrix), call .characters()
and test if the index list is the set of conjugacy classes.
"""
if chi is None:
chi = lambda x: x
J = self.index_object() # index set of length N
N = len(J)
S = self.list()
Expand Down
4 changes: 3 additions & 1 deletion src/sage/combinat/finite_state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@
from sage.structure.sage_object import SageObject


def full_group_by(l, key=lambda x: x):
def full_group_by(l, key=None):
"""
Group iterable ``l`` by values of ``key``.

Expand Down Expand Up @@ -1003,6 +1003,8 @@ def full_group_by(l, key=lambda x: x):
Here, the result ``r`` has been sorted in order to guarantee a
consistent order for the doctest suite.
"""
if key is None:
key = lambda x: x
elements = defaultdict(list)
original_keys = {}
for item in l:
Expand Down
8 changes: 6 additions & 2 deletions src/sage/combinat/root_system/type_A.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def dynkin_diagram(self):
g.add_edge(i, i+1)
return g

def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2):
r"""
Return a latex representation of the Dynkin diagram.

Expand All @@ -297,6 +297,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
\draw[fill=white] (0 cm, 0 cm) circle (.25cm) node[below=4pt]{$1$};
<BLANKLINE>
"""
if label is None:
label = lambda i: i
if node is None:
node = self._latex_draw_node
if self.n > 1:
Expand All @@ -306,7 +308,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
return ret + "".join(node((i-1)*node_dist, 0, label(i))
for i in self.index_set())

def ascii_art(self, label=lambda i: i, node=None):
def ascii_art(self, label=None, node=None):
"""
Return an ascii art representation of the Dynkin diagram.

Expand All @@ -332,6 +334,8 @@ def ascii_art(self, label=lambda i: i, node=None):
n = self.n
if n == 0:
return ""
if label is None:
label = lambda i: i
if node is None:
node = self._ascii_art_node
ret = "---".join(node(label(i)) for i in range(1,n+1)) + "\n"
Expand Down
8 changes: 6 additions & 2 deletions src/sage/combinat/root_system/type_A_affine.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def dynkin_diagram(self):
g.add_edge(0, n)
return g

def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2):
r"""
Return a latex representation of the Dynkin diagram.

Expand All @@ -128,6 +128,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
\draw[fill=white] (3.0 cm, 1.2 cm) circle (.25cm) node[anchor=south east]{$0$};
<BLANKLINE>
"""
if label is None:
label = lambda i: i
if node is None:
node = self._latex_draw_node
if self.n == 1:
Expand All @@ -148,7 +150,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
ret += node(mid, 1.2, label(0), 'anchor=south east')
return ret

def ascii_art(self, label=lambda i: i, node=None):
def ascii_art(self, label=None, node=None):
"""
Return an ascii art representation of the extended Dynkin diagram.

Expand Down Expand Up @@ -178,6 +180,8 @@ def ascii_art(self, label=lambda i: i, node=None):
O<=>O
2 3
"""
if label is None:
label = lambda i: i
if node is None:
node = self._ascii_art_node
n = self.n
Expand Down
4 changes: 3 additions & 1 deletion src/sage/combinat/root_system/type_A_infinity.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _latex_(self):
"""
return 'A_{{{}}}'.format(self.n._latex_())

def ascii_art(self, label=lambda i: i, node=None):
def ascii_art(self, label=None, node=None):
"""
Return an ascii art representation of the extended Dynkin diagram.

Expand All @@ -100,6 +100,8 @@ def ascii_art(self, label=lambda i: i, node=None):
0 1 2 3 4 5 6

"""
if label is None:
label = lambda i: i
if node is None:
node = self._ascii_art_node

Expand Down
8 changes: 6 additions & 2 deletions src/sage/combinat/root_system/type_B.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def dynkin_diagram(self):
g.set_edge_label(n-1, n, 2)
return g

def ascii_art(self, label=lambda i: i, node=None):
def ascii_art(self, label=None, node=None):
"""
Return an ascii art representation of the Dynkin diagram.

Expand All @@ -261,6 +261,8 @@ def ascii_art(self, label=lambda i: i, node=None):
O---O---O---O=>=O
3 4 5 6 7
"""
if label is None:
label = lambda i: i
if node is None:
node = self._ascii_art_node
n = self.n
Expand All @@ -271,7 +273,7 @@ def ascii_art(self, label=lambda i: i, node=None):
ret += "".join("{!s:4}".format(label(i)) for i in range(1, n + 1))
return ret

def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=False):
def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False):
r"""
Return a latex representation of the Dynkin diagram.

Expand Down Expand Up @@ -307,6 +309,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=
- :meth:`sage.combinat.root_system.type_C.CartanType._latex_dynkin_diagram`
- :meth:`sage.combinat.root_system.type_BC_affine.CartanType._latex_dynkin_diagram`
"""
if label is None:
label = lambda i: i
if node is None:
node = self._latex_draw_node
if self.n == 1:
Expand Down
8 changes: 6 additions & 2 deletions src/sage/combinat/root_system/type_BC_affine.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def _latex_(self):
else:
return "BC_{%s}^{(2)}" % self.n

def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=False):
def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False):
r"""
Return a latex representation of the Dynkin diagram.

Expand Down Expand Up @@ -180,6 +180,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=
\draw[fill=white] (0 cm, 0 cm) circle (.25cm) node[below=4pt]{$0$};
<BLANKLINE>
"""
if label is None:
label = lambda i: i
if node is None:
node = self._latex_draw_node
if self.n == 1:
Expand All @@ -206,7 +208,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=
ret += "}\n" + node(0, 0, label(0))
return ret

def ascii_art(self, label=lambda i: i, node=None):
def ascii_art(self, label=None, node=None):
"""
Return a ascii art representation of the extended Dynkin diagram.

Expand All @@ -227,6 +229,8 @@ def ascii_art(self, label=lambda i: i, node=None):
O=<=O
2 3
"""
if label is None:
label = lambda i: i
if node is None:
node = self._ascii_art_node
n = self.n
Expand Down
8 changes: 6 additions & 2 deletions src/sage/combinat/root_system/type_B_affine.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def dynkin_diagram(self):
g.add_edge(0,2)
return g

def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=False):
def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False):
r"""
Return a latex representation of the Dynkin diagram.

Expand Down Expand Up @@ -130,6 +130,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=
\draw[fill=white] (6 cm, 0 cm) circle (.25cm) node[below=4pt]{$4$};
<BLANKLINE>
"""
if label is None:
label = lambda i: i
if node is None:
node = self._latex_draw_node
if self.n == 1:
Expand All @@ -155,7 +157,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=
ret += node(i*node_dist, 0, label(i+1))
return ret

def ascii_art(self, label=lambda i: i, node=None):
def ascii_art(self, label=None, node=None):
"""
Return an ascii art representation of the extended Dynkin diagram.

Expand Down Expand Up @@ -184,6 +186,8 @@ def ascii_art(self, label=lambda i: i, node=None):
"""
n = self.n
from .cartan_type import CartanType
if label is None:
label = lambda i: i
if node is None:
node = self._ascii_art_node
if n == 1:
Expand Down
8 changes: 6 additions & 2 deletions src/sage/combinat/root_system/type_C.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def dynkin_diagram(self):
"""
return self.dual().dynkin_diagram().dual()

def _latex_dynkin_diagram(self, label=lambda x: x, node=None, node_dist=2, dual=False):
def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False):
r"""
Return a latex representation of the Dynkin diagram.

Expand Down Expand Up @@ -268,9 +268,11 @@ def _latex_dynkin_diagram(self, label=lambda x: x, node=None, node_dist=2, dual=
- :meth:`sage.combinat.root_system.type_C.CartanType._latex_dynkin_diagram`
- :meth:`sage.combinat.root_system.type_BC_affine.CartanType._latex_dynkin_diagram`
"""
if label is None:
label = lambda i: i
return self.dual()._latex_dynkin_diagram(label=label, node=node, node_dist=node_dist, dual=not dual)

def ascii_art(self, label=lambda i: i, node=None):
def ascii_art(self, label=None, node=None):
"""
Return a ascii art representation of the extended Dynkin diagram.

Expand All @@ -289,6 +291,8 @@ def ascii_art(self, label=lambda i: i, node=None):
O---O---O---O=<=O
3 4 5 6 7
"""
if label is None:
label = lambda i: i
return self.dual().ascii_art(label=label, node=node).replace("=>=", "=<=")

def _default_folded_cartan_type(self):
Expand Down
Loading