Commits

Anonymous committed 597559d

Fix up Python preambles in .ins file.

  • Participants
  • Parent commits 608bdd6

Comments (0)

Files changed (1)

File sagetexpackage.ins

 %% General Public License for more details.
 %%
 %% You should have received a copy of the GNU General Public License
-%% along with this program.  If not, see <http://www.gnu.org/licenses/>
+%% along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 \input docstrip.tex
 \keepsilent
 
 This program is distributed in the hope that it will be useful, but
 WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+Public License for more details.
 
 You should have received a copy of the GNU General Public License along
-with this program.  If not, see <http://www.gnu.org/licenses/>
+with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 \endpreamble
 
 \generate{\file{sagetex.sty}{\from{sagetexpackage.dtx}{latex}
                              \from{py-and-sty.dtx}{latex}}}
 
+% Define a new preamble with #'s as comment characters for the Python
+% files. I hate copying the same text, but defining a "\boilerplate"
+% macro requires me to manually do \MetaPrefix\space and ^^J everywhere
+% and it's more annoying than this.
 
-% Some trickery to get triple quotes around the {pre,post}amble. This is
-% a modification of what the Docstrip manual suggests; their method
-% resulted in some bits being printed twice because, I think, of a
-% problem in \declare{pre,post}amble. At any rate, this gives us a
-% properly commented Python file with the same preamble as the .sty
-% file.
+\catcode`\#=12
+\def\hash{#}
+\catcode`\#=6
 
-\edef\defaultpreamble{"""^^J%
-  \defaultpreamble^^J%
-  """}
-\edef\defaultpostamble{"""^^J%
-  \defaultpostamble^^J%
-  """}
+\def\MetaPrefix{\hash\hash}
+\declarepreamble\pypreamble
+
+This is a generated file. It is part of the SageTeX package.
+
+Copyright (C) 2009 by Dan Drake <ddrake@member.ams.org>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation, either version 2 of the License, or (at your
+option) any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+\endpreamble
+\usepreamble\pypreamble
+\nopostamble
 
 \generate{\file{sagetex.py}{\from{sagetexpackage.dtx}{python}
                             \from{py-and-sty.dtx}{python}}}
-
 \generate{\file{sagetexparse.py}{\from{scripts.dtx}{parsermod}}}
 
-% Now we modify the preamble again to get the shebang line at the top.
+% Now define a new preamble with the shebang line at the top.
 
-\catcode`\#=12
-\newcommand{\shebang}{#!}
-\catcode`\#=6
-\edef\defaultpreamble{\shebang/usr/bin/env python^^J\defaultpreamble}
+\def\envpypreamble{\hash!/usr/bin/env python^^J\pypreamble}
+\usepreamble\envpypreamble
 
 \generate{\file{makestatic.py}{\from{scripts.dtx}{staticscript}}}
 \generate{\file{extractsagecode.py}{\from{scripts.dtx}{extractscript}}}
 
+% ...and, for remote-sagetex, define yet another preamble with some
+% variables at the top, so it's easy for users to find them and alter
+% them.
+
+\def\rspypreamble{\hash!/usr/bin/env python^^J^^J%
+\hash\space You can fill in your information here, or you can set^^J%
+\hash\space any of these to None and the script will ask you to^^J%
+\hash\space provide them if you don't specify them as command-line^^J%
+\hash\space arguments.
+server = None \hash\space 'http://foo.com:8000', https works too^^J%
+username = None \hash\space 'my_name'^^J%
+password = None \hash\space 's33krit'^^J^^J%
+\pypreamble}
+\usepreamble\rspypreamble
+
 \generate{\file{remote-sagetex.py}{\from{remote-sagetex.dtx}{remotesagetex}}}
 
 \obeyspaces