Print

Print


On 17/07/2012 18:38, Joel C. Salomon wrote:
> I've been playing with some expl3 code on TeX.SX, and I'm trying to
> turn some of that code into a package. Since I'm using expl3, I
> figured I'd also experiment with l3doc. (Yes, I know it's labeled
> "experimental"; I want to experiment.)
> 
> I started with Joseph Wright's model dtx file from
> <http://texdev.net/2009/10/06/a-model-dtx-file/>, but I'm having some
> trouble adapting it to l3doc. Does anyone have some boilerplate code I
> can build off of?
> 
> I'm reading expl3 documentation code, but that's rather large. Also,
> there seems to be some magic involved with code like
>     \ProvidesExplClass
>       {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
> that I'm unable to figure out.
> 
> BTW, should I also be using l3docstrip?
> 
> —Joel

There are a few approaches to building a .dtx file, as you can see if
you look at the selection on CTAN. You will find 'traditional' .dtx
files, which need an .ins file to be extracted, and 'all-in-one' .dtx
files, which include their own .ins internally. My model .dtx file is of
the latter type.

In the case of the team's .dtx files which form the core of LaTeX3,
there are other considerations. Version information is included from the
SVN Id stings, which are picked up by \GetIdInfo and then turned into
\ExplFileName, etc. At the same time, the files have to be set up to
extract both in LaTeX2e package and IniTeX 'format' mode, and have
somewhat complex load-order requirements. They also need to build into a
single PDF file. This makes them less than ideal as a model for most
packages.

I've attached a template for creating a 'self extracting' .dtx file
using l3doc, based on the approach I use in notes2bib and siunitx. I've
kept only the basics, and removed some code I use for including demos:
look at "LaTeXdemo" in my .dtx files to see this.

In the demo, I've stuck with hard-coding in the version, so the
\ProvidesExplClass is less complex than the one you've mentioned.
Although this does not pick up data directly from commits to a version
control system, I think it works better over all. (Certainly if you use
Git or Mercurial.)
-- 
Joseph Wright