From 18d32f8aa801923758ac1cb47edd7e3f368cbdba Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 26 Jan 2026 14:46:01 -0500 Subject: [PATCH] GNUmakefile: strip comments from sage listings This is helpful if you want to put a comment at the beginning explaining What the listing does. --- GNUmakefile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 8f7e820..4d21cd4 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -185,9 +185,15 @@ $(BUILDDIR)/$(PN).log: $(SRCS) # How do we convert a raw listing into something testable by sage? We # append/prepend triple quotes to make the whole thing into a doctest, -# and then we replace any blank lines by "". +# strip all comment lines (only outside of a sage: prompt), and then +# we replace any blank lines by "". sage_listings/%.py: sage_listings/%.listing - echo '"""' > $@ && cat $< >> $@ && echo '"""' >> $@ && sed -i 's/^[[:space:]]*$$//' $@ + echo '"""' > $@ + cat $< >> $@ + echo '"""' >> $@ + sed -e '/^[[:space:]]*#/d' \ + -e 's/^[[:space:]]*$$//' \ + -i $@ # Ensure that there are no overfull or underfull boxes in the output # document by parsing the log for said warnings. -- 2.51.0