# Help needed: DocStrip with multiple files

I am maintaining a bunch of files, presenting packages and classes for my university corporate design. In order to use literate programming and have better documentation, I am playing around with DocStrip. I was able to build the necessary basic .ins-file and a .dtx-file. I could build an useless sample.sty from the .dtx as well as a readable documentation from the same source.

I plan, to split the code of my packages and classes onto several .dtx-sources, as a lot of code is identical in one or another resulting file.

I especially would love to have a dedicated version.dtx file, which should be included in every package and class, DocStrip shall create. I intend to have a unique version info from the "package release date" in every single derived style and class.

What would be the best way? Is there any tutorial, that shows this trick?

Trying to set a LaTeX-Variable in the .ins-file did not work, as the macro was not expanded.

Here is my sample.ins:

\input docstrip.tex
\keepsilent
\preamble
Project Sample Test -- Versuche mit einer oder mehreren DTX-Dateien
\endpreamble
\usedir{tex/latex/sample}
%%% DOES NOT WORK!
%%% Define a version for all subsequent generated files
\def\TUC@Version{2017/02/05 v0.01a}
\generate{\file{sample.sty}{\from{sample.dtx}{package}}}


And this is the stripped down sample.dtx:

% \iffalse meta-comment
Project Sample Test -- Versuche mit einer oder mehreren DTX-Dateien
% \fi
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
%<package>\ProvidesPackage{sample}
%<package>    [\TUC@Version (Test with DocStrip)]
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{sample}

\EnableCrossrefs
\CodelineIndex
\RecordChanges

\begin{document}
\DocInput{sample.dtx}
\end{document}
%</driver>
% \fi
% \Finale
%
\endinput

• there shouldn't be any problem to include a version.dtx (but your code attempted setting that in an ins file which is also doable but different) see for example format.ins which includes multiple dtx including ltvers.dtx to make latex.ltx – David Carlisle Feb 5 '17 at 17:57
• @DavidCarlisle thank you for the hint. The \def in the .ins-file was just try -- and desaster :-) – Jan Feb 5 '17 at 18:08

smpl.ins

\input docstrip

\generate{
\file{pack1.sty}{
\from{pack1.dtx}{package1}
\from{vers.dtx}{}
\from{pack1.dtx}{package}
}}

\generate{
\file{pack2.sty}{
\from{pack2.dtx}{package1}
\from{vers.dtx}{}
\from{pack2.dtx}{package}
}}

\endbatchfile


vers.dtx

%    \begin{macrocode}
2017/02/05 v1.0
%    \begin{macrocode}


pack1.dtx

% \iffalse
%<package1>\ProvidesPackage{pack1}[%
%<package>pack1 package]
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{pack1}
\GetFileInfo{pack1.sty}
\begin{document}
\title{The \textsf{pack1} package\thanks{This file
has version number \fileversion, last
revised \filedate.}}
\author{me}
\date{\filedate}
\maketitle
\DocInput{pack1.dtx}
\end{document}
%</driver>
% \fi
%
% \StopEventually{}
%
% \begin{macro}{\foo}
%  A really useful command
%    \begin{macrocode}
%<*package>
\def\foo{bar}
%</package>
%    \end{macrocode}
% \end{macro}
%
% \Finale
%


pack2.dtx

% \iffalse
%<package1>\ProvidesPackage{pack2}[%
%<package>pack2 package]
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{pack2}
\GetFileInfo{pack2.sty}
\begin{document}
\title{The \textsf{pack2} package\thanks{This file
has version number \fileversion, last
revised \filedate.}}
\author{me}
\date{\filedate}
\maketitle
\DocInput{pack2.dtx}
\end{document}
%</driver>
% \fi
%
% \StopEventually{}
%
% \begin{macro}{\bar}
%  A really useful command
%    \begin{macrocode}
%<*package>
\def\bar{foo}
%</package>
%    \end{macrocode}
% \end{macro}
%
% \Finale
%


Then a command such as

tex smpl.ins


will generate pack1.sty and pack2.sty, with pack1.sty looking like

%%
%% This is file pack1.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pack1.dtx  (with options: package1')
%% vers.dtx
%% pack1.dtx  (with options: package')
%%
%% IMPORTANT NOTICE:
%%
%% For the copyright see the source file.
%%
%% Any modified versions of this file must be renamed
%% with new filenames distinct from pack1.sty.
%%
%% For distribution of the original source see the terms
%% for copying and modification in the file pack1.dtx vers.dtx pack1.dtx.
%%
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
\ProvidesPackage{pack1}[%
2017/02/05 v1.0
pack1 package]
\def\foo{bar}
\endinput
%%
%% End of file pack1.sty'.


and pack2.sty not looking that different.

pdflatex pack1.dtx will make


• THANK YOU David. I think, I got now the trick. smpl.ins will extract via guard <package1>the string \ProvidesPackage{...}[, than the naked version number is inserted from file vers.dtx and after that, a second run on the package pack1.dtx is run, this time with the guard <package>. Thank you very much! – Jan Feb 6 '17 at 7:20