7

I use Joseph Wright's model dtx file. Unfortunately, when using it, the generated README.txt file contains parts of the package code, which is of course unwanted.

The rather long minimal example is appended at the end. The important part regarding my question is quite on the top, where only "Text" should end up in the README.txt to my understanding:

%<*readme>
Text
%</readme>

Instead, the README.txt looks like

Text
\endbatchfile
\def\shouldNotBeInReadme{really}

Why is that? What did I do wrong?

% \iffalse meta-comment
%<*internal>
\iffalse
%</internal>
%<*readme>
Text
%</readme>
%<readme>\endbatchfile
%<*internal>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
\expandafter\begingroup
\fi
%</internal>
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble
Preamble
\endpreamble
\postamble
Postamble
\endpostamble
\usedir{tex/latex/tikzscale}
\generate{
\file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
%</install>
%<install>\endbatchfile
%<*internal>
\usedir{source/latex/tikzscale}
\generate{
\file{\jobname.ins}{\from{\jobname.dtx}{install}}
}
\nopreamble\nopostamble
\usedir{doc/latex/tikzscale}
\generate{
\file{README.txt}{\from{\jobname.dtx}{readme}}
}
\ifx\fmtname\nameofplainTeX
\expandafter\endbatchfile
\else
\expandafter\endgroup
\fi
%</internal>
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tikzscale}[2012/09/10 v0.1 tikzscale LaTeX package]
%</package>
%<*driver>
\documentclass{ltxdoc}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
%\GetFileInfo{\jobname.sty}
%
%\title{Title}
%\author{Author}
%\date{Released \filedate}
%
%\maketitle
%
%\changes{v0.1}{2012/09/10}{First public release}
%
% Text
\def\shouldNotBeInReadme{really}
%
%
%\StopEventually{^^A
%  \PrintChanges
%^^A  \PrintIndex
%}
%
%\Finale

1 Answers1

6

You have an 'unguarded' code line. If you have a line in the .dtx which does not start % and is 'outside' of the guards, it appears in every extracted file. You can see that if you look in the .sty or .ins files. So you want

%    \begin{macrocode}
%<*package>
\def\shouldNotBeInReadme{really}
%</package>
%    \end{macrocode}

or

% \iffalse
%<*package>
% \fi
%    \begin{macrocode}
\def\shouldNotBeInReadme{really}
%    \end{macrocode}
% \iffalse
%</package>
% \fi

or similar.

Not linked to the issue, but the line

%<readme>\endbatchfile

is also spurious.

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
  • if you're thinking of distributing via ctan, please note that ctan needs README, not README.txt -- renaming it slows us down, so please try to remember that the .txt bit is a mistake. (my apologies if you weren't intending that the package be submitted to ctan.) – wasteofspace Sep 11 '12 at 09:42
  • @wasteofspace It's not possible to get DocStrip to create a file with no extension: TeX will not do this. So the best that can be done in the .dtx is to use a sensible extension. (In the build scripts I've also discussed on my blog, I think I've mentioned something similar and include a rename part.) – Joseph Wright Sep 11 '12 at 10:15
  • @JosephWright Thanks for the great answer, for the additional information and for the original code. I added a hardlink to README.txt with name README. The latter one is now used in my ctanify script. That might be a good compromise, given the constraints you mentioned here and on your blog. – Patrick Häcker Sep 11 '12 at 20:19
  • @wasteofspace Thanks a lot for mentioning, I'd had overseen this issue otherwise, as the plan is to distribute this package via ctan one day. – Patrick Häcker Sep 11 '12 at 20:21
  • @JosephWright If I use the command \generate{\file{README.}{\from{\jobname.dtx}{readme}}} with a period after README I get the file without an extension. Is this a change from your comment above? – Bill N Aug 28 '15 at 22:42
  • @BillN No, you'll get a file called README. with a full stop in it: that's not the same as README with no extention at all. Notably, CTAN now accept files called README.md (MarkDown) which would probably be the easiest approach to take. – Joseph Wright Aug 29 '15 at 09:10
  • @JosephWright Thanks, but there's something odd here. When I ls from Linux or dir from Windows in the directory with that file I get README, not README. I generated the file from a TeXLive setup on a Windows machine. At the bottom line, I guess I'll use the .md extension just to be sure. – Bill N Aug 29 '15 at 14:55
  • Before I push an update to CTAN, I use a shell script to (in addition to several other things) rename my README.txt file to README and that works just fine. I may begin using README.md with my next update. – LaTeXereXeTaL Nov 26 '20 at 21:24