summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/makedtx/manual.html
blob: 208bda39512081c9da900be284cd045d84916dca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<!--Converted with LaTeX2HTML 2K.1beta (1.47)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>makedtx : a Perl script to help create a DTX file from source code</TITLE>
<META NAME="description" CONTENT="makedtx : a Perl script to help create a DTX file from source code">
<META NAME="keywords" CONTENT="manual">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="LaTeX2HTML v2K.1beta">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">



</HEAD>

<BODY >
<A NAME="tex2html1"
  HREF="http://theoval.cmp.uea.ac.uk/~nlct/">Dr Nicola Talbot</A>
|
<A NAME="tex2html2"
  HREF="http://www.cmp.uea.ac.uk/">School of Computing Sciences</A>
|
<A NAME="tex2html3"
  HREF="http://www.uea.ac.uk/">University of East Anglia</A>

<P>

<H1 ALIGN="CENTER">makedtx : a Perl script to help create a DTX file from source code</H1>
<P ALIGN="CENTER"><STRONG>Nicola Talbot</STRONG></P>
<P ALIGN="CENTER"><STRONG>11th February 2005</STRONG></P>

<P>
<BR>

<H2><A NAME="SECTION00010000000000000000">
Contents</A>
</H2>
<!--Table of Contents-->

<UL>
<LI><A NAME="tex2html21"
  HREF="#SECTION00020000000000000000">1 Introduction</A>
<LI><A NAME="tex2html22"
  HREF="#SECTION00030000000000000000">2 Installation</A>
<LI><A NAME="tex2html23"
  HREF="#SECTION00040000000000000000">3 makedtx.pl</A>
<UL>
<LI><A NAME="tex2html24"
  HREF="#SECTION00041000000000000000">3.1 Compulsory Arguments</A>
<LI><A NAME="tex2html25"
  HREF="#SECTION00042000000000000000">3.2 Options</A>
</UL><BR>
<LI><A NAME="tex2html26"
  HREF="#SECTION00050000000000000000">4 The creatdtx Package</A>
<LI><A NAME="tex2html27"
  HREF="#SECTION00060000000000000000">5 Examples</A>
<LI><A NAME="tex2html28"
  HREF="#SECTION00070000000000000000">6 Troubleshooting</A>
<UL>
<LI><A NAME="tex2html29"
  HREF="#SECTION00071000000000000000">6.1 Known Bugs</A>
<LI><A NAME="tex2html30"
  HREF="#SECTION00072000000000000000">6.2 Possible errors encountered using <TT>makedtx.pl</TT></A>
</UL><BR>
<LI><A NAME="tex2html31"
  HREF="#SECTION00080000000000000000">A. Perl Regular Expressions</A>
<LI><A NAME="tex2html32"
  HREF="#SECTION00090000000000000000">Bibliography</A>
<LI><A NAME="tex2html33"
  HREF="#SECTION000100000000000000000">Contact Details</A>
</UL>
<!--End of Table of Contents-->
<P>

<H3>Abstract:</H3>
<DIV>
The <TT>makedtx</TT> bundle is provided to help developers to write the code and
documentation in separate files, and then combine them into a single DTX
file for distribution.  It automatically generates the character table, and also
writes the associated installation (.ins) script.
</DIV>
<P>

<P>

<H1><A NAME="SECTION00020000000000000000">
1 Introduction</A>
</H1>

<P>
Authors of LaTeX2e class files or packages are encouraged to bundle their
source and documentation together into a single DTX file.  This makes 
distribution much easier, as users need only download the DTX file
and possibly a corresponding installation script (INS file) instead of
a multitude of <TT>.sty</TT>, <TT>.cls</TT>, <TT>.def</TT> etc files.
However, having the documentation and code bundled together can cause
problems if a developer wants to, say, use <TT>ispell</TT> to spell check
the documentation, or convert the documentation to a format other than DVI, 
PostScript or PDF (such as HTML).

<P>
Why should I want to convert my documentation to HTML when I can just use PDFLaTeX?
The more general purpose packages that I write (such as <TT>datetime</TT> and <TT>glossary</TT>) 
I upload to CTAN, however most of the packages I write are specific to the School
of Computing Sciences at the University of East Anglia, so these I keep on my web site,
and as some of the faculty either don't have a PDF plug in or prefer to view HTML rather
the PDF documents, I have taken to writing both PDF and HTML versions of my package documentation.
However, LaTeX2HTML doesn't work on a <TT>.dtx</TT> file so I used to convert them manually
which is fine for one or two small documents, but becomes rather cumbersome as soon as I have large
documents or a lot of packages.  Therefore I decided to write the documentation separately, and
use a Perl script to bundle everything together.  It also has the added convenience in that I don't
have to keep copying and pasting the character table every time I write a new package, and it saves
the laborious task of writing the installation script<A NAME="tex2html4"
  HREF="#foot48"><SUP>1</SUP></A>.

<P>
This document is structured as follows: Section&nbsp;<A HREF="manual.html#sec:install">2</A> describes how to install the
<TT>makedtx</TT> bundle, Section&nbsp;<A HREF="manual.html#sec:makedtx">3</A> gives an overview of the <TT>makedtx.pl</TT>
Perl script, Section&nbsp;<A HREF="manual.html#sec:creatdtx">4</A> describes the <TT>creatdtx</TT> package, Section&nbsp;<A HREF="manual.html#sec:examples">5</A>
illustrates the use of the <TT>makedtx</TT> bundle with examples and Section&nbsp;<A HREF="manual.html#sec:problems">6</A>
gives a list of possible errors and their solutions.

<P>

<H1><A NAME="SECTION00030000000000000000"></A><A NAME="sec:install"></A><BR>
2 Installation
</H1>

<P>
You need to download both <TT>makedtx.dtx</TT> and <TT>makedtx.ins</TT>, and
run the installation script through LaTeX:
<P>
<TT>latex makedtx.ins</TT>

<P>
The following files will be created:
<DL>
<DT><STRONG><TT>makedtx.pl</TT></STRONG></DT>
<DD>Perl script
</DD>
<DT><STRONG><TT>creatdtx.sty</TT></STRONG></DT>
<DD>LaTeX package for use with <TT>makedtx.pl</TT>
</DD>
<DT><STRONG><TT>creatdtx.perl</TT></STRONG></DT>
<DD>Corresponding Perl script for use with LaTeX2HTML
</DD>
</DL>

<P>
If you are using UNIX/Linux etc you will need to make <TT>makedtx.pl</TT> executable using
<TT>chmod</TT>:
<P>

<TT>chmod a+x makedtx.pl</TT>
<P>

and place it somewhere on your path.  If <TT>perl</TT> is located somewhere other than <TT>/usr/bin/</TT>
you will need to edit the first line of <TT>makedtx.pl</TT>.  (If you don't know where <TT>perl</TT> is
located, you can use the command: <TT>which perl</TT>.)  The package <TT>creatdtx.sty</TT> needs to be placed somewhere
on the LaTeX path and <TT>creatdtx.perl</TT> should be placed in a directory searched by LaTeX2HTML.
(See the LaTeX2HTML documentation for details.)

<P>

<H1><A NAME="SECTION00040000000000000000"></A><A NAME="sec:makedtx"></A><BR>
3 makedtx.pl
</H1>

<P>
The Perl script <TT>makedtx.pl</TT> has the following syntax:
<P>
<TT>makedtx.pl [<I>options</I>] -src "<I>expr1</I>=&gt;<I>expr2</I>" -doc <I>filename</I> <I>basename</I></TT>

<P>

<H2><A NAME="SECTION00041000000000000000">
3.1 Compulsory Arguments</A>
</H2>

<P>
The very last argument <I>basename</I> is the basename of the <TT>.dtx</TT> and <TT>.ins</TT> files you want
to create.  The <TT>-doc</TT> <I>filename</I> switch indicates the file containing the documentation and
<TT>-src</TT> <code>"</code><I>expr1</I><code>=&gt;</code><I>expr2</I><code>"</code> indicates the original source file(s),
given by <I>expr1</I>, and the corresponding file name when it has been extracted from the <TT>.dtx</TT> file,
given by <I>expr2</I>.  This switch is a little complicated, so
it's best described using examples.

<P>
Suppose you have your documentation in the file <TT>foodoc.tex</TT>, and the original source code is in the
file <TT>foosrc.sty</TT>.  You want to create the files <TT>foo.dtx</TT> and <TT>foo.ins</TT>.  When you 
LaTeX <TT>foo.dtx</TT> you want the documentation as specified in <TT>foodoc.tex</TT> and when
you LaTeX <TT>foo.ins</TT> you want the file <TT>foo.sty</TT> to be created, using the code specified
in <TT>foosrc.sty</TT>.  You will need to do:
<PRE>
makedtx.pl -src "foosrc\.sty=&gt;foo.sty" -doc foodoc.tex foo
</PRE>

<P>
You may have multiple invocations of the <TT>-src</TT> switch.  For example, suppose you also have the
file <TT>barsrc.sty</TT> which you want to be extracted from the <TT>.dtx</TT> file as <TT>bar.sty</TT>,
you can do:
<PRE>
makedtx.pl -src "foosrc\.sty=&gt;foo.sty" -src "barsrc\.sty=&gt;bar.sty" -doc foodoc.tex foo
</PRE>
Alternatively, you can use Perl-type regular expressions:
<PRE>
makedtx.pl -src "(.*)src\.sty=&gt;\1.sty" -doc foodoc.tex foo
</PRE>
(Note the use of double quotes to prevent shell expansion.)  Appendix&nbsp;<A HREF="manual.html#sec:prex">A</A> gives a brief
overview of Perl regular expressions for the uninitiated.

<P>

<H2><A NAME="SECTION00042000000000000000">
3.2 Options</A>
</H2>

<P>
<DL>
<DT><STRONG><TT>-h</TT> or <TT>-help</TT></STRONG></DT>
<DD>Prints on-line help, and exits.

<P>
</DD>
<DT><STRONG><TT>-v</TT></STRONG></DT>
<DD>Uses verbose mode.

<P>
</DD>
<DT><STRONG><TT>-dir</TT> <I>name</I></STRONG></DT>
<DD>Specifies directory containing source files, as specified by the <TT>-src</TT> switch.  
For example, suppose you have source files
<TT>foo.sty</TT>, <TT>bar.sty</TT> in the subdirectory <TT>sourcefiles</TT>
you can do:
<PRE>
makedtx.pl -dir sourcefiles -src "(.*)\.sty=&gt;\1.sty" -doc foodoc.tex foo
</PRE>

<P>
</DD>
<DT><STRONG><TT>-op</TT> <I>character</I></STRONG></DT>
<DD>sets the Perl pattern matching operator (the default is set to <TT>=</TT> symbol since the
<TT>/</TT> character is used as the directory divider).

<P>
</DD>
<DT><STRONG><TT>-askforoverwrite</TT></STRONG></DT>
<DD>uses <TT>&#92;askforoverwritetrue</TT> in the installation script.

<P>
</DD>
<DT><STRONG><TT>-noaskforoverwrite</TT></STRONG></DT>
<DD>uses <TT>&#92;askforoverwritefalse</TT> in the installation script (default).

<P>
</DD>
<DT><STRONG><TT>-noins</TT></STRONG></DT>
<DD>Don't create the installation script (<TT>.ins</TT> file).  This is useful if you want to tweak the 
file manually and you don't want your modifications overwritten.

<P>
</DD>
<DT><STRONG><TT>-preamble</TT> <I>text</I></STRONG></DT>
<DD>Set the preamble to <TT>text</TT>.  The default preamble is:
<P>
<TT>Copyright (C) <I>date</I> <I>author</I>, all rights reserved.
If you modify this file, you must change its name first.
You are NOT ALLOWED to distribute this file alone. You are NOT
ALLOWED to take money for the distribution or use of either this
file or a changed version, except for a nominal charge for copying
etc.
</TT>

<P>
where <I>date</I> is the copyright date, and <I>author</I> is the author's name (see below).

<P>
</DD>
<DT><STRONG><TT>-postamble</TT> <I>text</I></STRONG></DT>
<DD>Set the postamble to <TT>text</TT>.  If this is omitted the <TT>&#92;postamble</TT>
command is omitted from the installation script.

<P>
</DD>
<DT><STRONG><TT>-author</TT> <I>name</I></STRONG></DT>
<DD>The author's name (as used in the default preamble).  If omitted the user's name is used.

<P>
</DD>
<DT><STRONG><TT>-date</TT> <I>text</I></STRONG></DT>
<DD>The copyright date (as used in the default preamble).  If omitted the current
year is used.

<P>
</DD>
<DT><STRONG><TT>-stopeventually</TT> <I>text</I></STRONG></DT>
<DD>Insert <I>text</I> into the argument of <TT>&#92;StopEventually</TT>.
For example: <code>-stopeventually "\\PrintIndex"</code> will result in the 
line: <TT>&#92;StopEventually</TT><code>{\PrintIndex}</code>.
If <TT>makedtx.pl</TT> encounters a <TT>&#92;StopEventually</TT> command within the document, this will be used instead.
If there is no <TT>&#92;StopEventually</TT> command in the document and the <TT>-stopeventually</TT> switch is absent
<TT>&#92;StopEventually</TT><code>{}</code> will be inserted in the DTX file.

<P>
</DD>
<DT><STRONG><TT>-setambles</TT> <TT>"</TT><I>expr</I><TT>=&#62;</TT><I>text</I><TT>"</TT></STRONG></DT>
<DD>Sets the pre- and postambles for files matching <I>expr</I> within
the <TT>&#92;file</TT> command in the installation script.  To illustrate this, let's suppose you have source files
<TT>foo.sty</TT>, <TT>bar.sty</TT> and <TT>foobar.pl</TT> in the subdirectory <TT>sourcefiles</TT>.  Since
<TT>foo.sty</TT> and <TT>bar.sty</TT> are LaTeX files, they should have pre- and postambles, but <TT>foobar.pl</TT>
is a Perl file, and since the percent symbol (%) is not a comment character in Perl, there should be no pre- and
postambles for this file.  Therefore you would need to do something like:
<PRE>
makedtx.pl -dir sourcefiles -src "(.*)\.sty=&gt;\1.sty" -src "foobar.pl=&gt;foobar.pl" 
-setambles "foobar\.pl=&gt;\\nopreamble\\nopostamble" -doc foodoc.tex foo
</PRE>
(Note that the line is only broken to fit it onto the page, and there should be no line break when entering
at the command prompt.)

<P>
If the argument to <TT>-setambles</TT> contains the string <code>\\nopreamble</code>, the character table will be
excluded from the corresponding files.  So, in the above example, when you do: <code>latex foo.ins</code> the
resulting files <TT>foo.sty</TT> and <TT>bar.sty</TT> will contain the character table, but <TT>foobar.pl</TT>
won't. (If for some reason you don't want a preamble but you do want the character table included
use <code>\\usepreamble\\empty</code> instead of <code>\\nopreamble</code>. Conversely, if you want a preamble but don't
want the character table do something like <code>\\nopreamble\\usepreamble\\defaultpreamble</code>, although I can't think
of a good reason for wanting either of these situations.)

<P>
Note that the <code>=&gt;</code><I>text</I> part is optional.  If it is omitted, <I>text</I> is assumed to be empty.

<P>
</DD>
<DT><STRONG><TT>-macrocode</TT> <TT>"</TT><I>expr</I><TT>"</TT></STRONG></DT>
<DD>If source file matches the Perl regular expression given by <I>expr</I>, 
the source code is inserted into a <TT>macrocode</TT> environment in the DTX file.
</DD>
</DL>

<P>

<H1><A NAME="SECTION00050000000000000000"></A>
<A NAME="sec:creatdtx"></A><BR>
4 The creatdtx Package
</H1>

<P>
The documentation source code, as specified using the <TT>-doc</TT> switch will typically be a standard
LaTeX document using the <TT>ltxdoc</TT> class file.  Unlike the DTX file, there is no <TT>&#92;DocInput</TT> command,
and the lines do not begin with a percent symbol, which means that the document can be, say, passed to the
LaTeX2HTML converter, or some other application that would otherwise be confused by a DTX file.  The <TT>creatdtx</TT>
package can be used in this document using
<PRE>
\usepackage{creatdtx}
</PRE>
although this package will be not be included in the DTX file by <TT>makedtx.pl</TT>.
There is only one command defined in this package: 
<TT>&#92;ifmakedtx{<I>dtx text</I>}{<I>non dtx text</I>}</TT>.
The first argument <I>dtx text</I> will be copied to the DTX file by <TT>makedtx.pl</TT>, but the second argument
<I>non dtx text</I> won't.  
However, if you LaTeX the document, the first argument will be ignored, and the second argument will be used.

<P>
For example, if your code (in <TT>foodoc.tex</TT>) contains the line:
<P>

<TT><TT>&#92;ifmakedtx</TT>{}{<TT>&#92;usepackage</TT>{html}}</TT>

<P>

the <TT>html</TT> package will only be loaded if you LaTeX <TT>foodoc.tex</TT>, but not when you LaTeX 
<TT>foo.dtx</TT>.

<P>
The Perl script <TT>creatdtx.perl</TT> ignores the following commands (and any associated arguments): 
<TT>&#92;OnlyDescription</TT>, <TT>&#92;RecordChanges</TT>, <TT>&#92;MakeShortVerb</TT>, <TT>&#92;DeleteShortVerb</TT>, <TT>&#92;DoNotIndex</TT>,
<TT>&#92;EnableCrossrefs</TT>, <TT>&#92;CodelineIndex</TT>, <TT>&#92;GetFileInfo</TT>,
<TT>&#92;PrintChanges</TT>, <TT>&#92;changes</TT>, <TT>&#92;CheckSum</TT>, <TT>&#92;DescribeMacro</TT> and <TT>&#92;DescribeEnvironment</TT>.
So even if you don't use the <TT>&#92;ifmakedtx</TT> command, using the <TT>creatdtx</TT> package will help ensure that 
extraneous text does not appear in the HTML document when using LaTeX2HTML.

<P>

<H1><A NAME="SECTION00060000000000000000"></A>
<A NAME="sec:examples"></A><BR>
5 Examples
</H1>

<P>
Let's first consider a very simple example.  Suppose you want to create a package that redefines <TT>&#92;today</TT>
so that the date is displayed in the form: yyyy-m-d.  Let's call this package <TT>dashdate</TT>.  The file
<TT>dashdate.sty</TT> should look something like:
<PRE>
 % First define package:
 %    \begin{macrocode}
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{dashdate}
 %    \end{macrocode}
 % Redefine |\today| command:
 %    \begin{macrocode}
 \renewcommand{\today}{\the\year-\the\month-\the\day}
 %    \end{macrocode}
</PRE>
Now let's make some (very brief) documentation.  Let's call the file, say <TT>manual.tex</TT><A NAME="tex2html5"
  HREF="#foot401"><SUP>2</SUP></A>:
<PRE>
\documentclass{ltxdoc}
\usepackage{creatdtx}

\begin{document}
\title{A Sample Package}
\author{AN Other}
\maketitle

The \texttt{dashdate} package redefines |\today|
to produce the current date in the form: yyyy-m-d.
\end{document}
</PRE>
Suppose you have saved <TT>dashdate.sty</TT> and <TT>manual.tex</TT> in the subdirectory <TT>source</TT>.  You
can now create the <TT>.dtx</TT> and <TT>.ins</TT> file using the command:
<PRE>
makedtx.pl -author "AN Other" -dir source -src "dashdate\.sty=&gt;dashdate.sty" 
-doc source/manual.tex dashdate
</PRE>
The file <TT>dashdate.dtx</TT> is created, and contains the following code:
<PRE>
 %\iffalse
 % dashdate.dtx generated using makedtx.pl version 0.9b (c) Nicola Talbot
 % Command line args:
 %   -dir "source"
 %   -src "dashdate\.sty=&gt;dashdate.sty"
 %   -author "AN Other"
 %   -doc "source/manual.tex"
 %   dashdate
 % Created on 2005/2/10 22:22
 %\fi
 %\iffalse
 %&lt;*package&gt;
 %% \CharacterTable
 %%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
 %%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
 %%   Digits        \0\1\2\3\4\5\6\7\8\9
 %%   Exclamation   \!     Double quote  \"     Hash (number) \#
 %%   Dollar        \$     Percent       \%     Ampersand     \&
 %%   Acute accent  \'     Left paren    \(     Right paren   \)
 %%   Asterisk      \*     Plus          \+     Comma         \,
 %%   Minus         \-     Point         \.     Solidus       \/
 %%   Colon         \:     Semicolon     \;     Less than     \<
 %%   Equals        \=     Greater than  \>     Question mark \?
 %%   Commercial at \@     Left bracket  \[     Backslash     \\
 %%   Right bracket \]     Circumflex    \^     Underscore    \_
 %%   Grave accent  \`     Left brace    \{     Vertical bar  \|
 %%   Right brace   \}     Tilde         \~}
 %&lt;/package&gt;
 %\fi
 % \iffalse
 % Doc-Source file to use with LaTeX2e
 % Copyright (C) 2005 AN Other, all rights reserved.
 % \fi
 % \iffalse
 %&lt;*driver&gt;
 \documentclass{ltxdoc}

 \begin{document}
 \DocInput{dashdate.dtx}
 \end{document}
 %&lt;/driver&gt;
 %\fi
 %\title{A Sample Package}
 %\author{AN Other}
 %\maketitle
 %
 %The \texttt{dashdate} package redefines "\today"
 %to produce the current date in the form: yyyy-m-d.
 %\end{document}
 %
 %\StopEventually{}
 %\section{The Code}
 %    \begin{macrocode}
 %&lt;*dashdate.sty&gt;
 %    \end{macrocode}
 % First define package:
 %    \begin{macrocode}
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{dashdate}
 %    \end{macrocode}
 % Redefine |\today| command:
 %    \begin{macrocode}
 \renewcommand{\today}{\the\year-\the\month-\the\day}
 %    \end{macrocode}
 %    \begin{macrocode}
 %&lt;/dashdate.sty&gt;
 %    \end{macrocode}
 %\Finale
 \endinput
</PRE>
The installation file <TT>dashdate.ins</TT> looks like:
<PRE>
 % dashdate.ins generated using makedtx.pl version 0.9b 2005/2/10 22:22
 \input docstrip

 \preamble
 Copyright (C) 2005 AN Other, all rights reserved.
 If you modify this file, you must change its name first.
 You are NOT ALLOWED to distribute this file alone. You are NOT
 ALLOWED to take money for the distribution or use of either this
 file or a changed version, except for a nominal charge for copying
 etc.
 \endpreamble

 \askforoverwritefalse

 \generate{\file{dashdate.sty}{\usepreamble\defaultpreamble
 \usepostamble\defaultpostamble\from{dashdate.dtx}{dashdate.sty,package}}
 }

 \endbatchfile
</PRE>
Note that the command <code>\usepackage{creatdtx}</code> has not been transcribed to <TT>dashdate.dtx</TT>
(although in this simple example it's not really needed).

<P>
Now let's extend the example:
suppose you want to create an analogous Perl script for use with LaTeX2HTML.
This will need to be called <TT>dashdate.perl</TT> and will look something like:
<PRE>
package main;

sub do_cmd_today{
   local($today) = &amp;get_date();
   $today =~ s|(\d+)/(\d+)/(\d+)|$3-$1-$2|;
   $_ = $today;
}

1;
</PRE>
You will now need to call <TT>makedtx.pl</TT> as follows:
<PRE>
makedtx.pl -author "AN Other" -dir source -src "dashdate\.sty=&gt;dashdate.sty" 
-src "dashdate\.perl=&gt;dashdate.perl" 
-setambles "dashdate\.perl=&gt;\\nopreamble\\nopostamble" 
-macrocode "dashdate\.perl" -doc source/manual.tex dashdate
</PRE>
(Note that the line is only broken to allow it to fit onto the page, there should be no line break
when you enter it on the command line.) Alternatively, you could save typing and do:
<PRE>
makedtx.pl -author "AN Other" -dir source -src "dashdate\.(.*)=&gt;dashdate.\1"
-setambles "dashdate\.perl=&gt;\\nopreamble\\nopostamble" -macrocode "dashdate\.perl"
-doc source/manual.tex dashdate
</PRE>
Note the use of the <TT>-setambles</TT> switch which suppresses the insertion of text at the start and
end of the Perl script which would only confuse Perl.  Note also the use of the <TT>-macrocode</TT>
switch.  This is not needed for <TT>dashdate.sty</TT> since it has already been included in the source
code, but since % is not a comment character in Perl, the <TT>macrocode</TT> environment
is not included in the source code, and needs to be added.
(If you are unfamiliar with DocStrip and the use of the <TT>macrocode</TT> environment, 
I suggest you read either <I>A guide to LaTeX</I>&nbsp;[<A
 HREF="manual.html#Kopka98">2</A>, Appendix&nbsp;D]
or <I>The LaTeX companion</I>&nbsp;[<A
 HREF="manual.html#Goossens93">1</A>, Chapter&nbsp;14])

<P>
As another example, consider the <TT>datetime</TT> package.  Version 2.42 of this package has 2 <TT>.sty</TT> files
and 42 <TT>.def</TT> files.  The documentation is written in the file <TT>manual.tex</TT>, and the <TT>.sty</TT>
and <TT>.def</TT> files are saved in a subdirectory called <TT>source</TT>.  Since these are the only files in this
directory, they can easily be merged into one <TT>.dtx</TT> file using:
<PRE>
makedtx.pl -author "Nicola Talbot" -dir source -src "(.+)\.(.+)=&gt;\1.\2" 
-doc manual.tex datetime
</PRE>
This creates the files <TT>datetime.dtx</TT> and <TT>datetime.ins</TT> which can then be distributed.  The PDF version
of the documentation is obtained by doing:
<PRE>
pdflatex datetime.dtx
</PRE>
and the HTML version (<TT>manual.html</TT>) is obtained by doing:
<PRE>
latex2html -split 0 -nonavigation -nofootnode -numbered_footnotes -noinfo manual
</PRE>
Any minor differences between the HTML and PDF versions are dealt by using <TT>&#92;ifmakedtx</TT> in 
the original file <TT>manual.tex</TT>.

<P>

<H1><A NAME="SECTION00070000000000000000"></A>
<A NAME="sec:problems"></A><BR>
6 Troubleshooting
</H1>

<P>
The <TT>makedtx</TT> bundle has only been tested under Linux using Perl v5.6.0.  There are no guarantees whether
or not it will work on other operating systems or on different versions (in fact, there are no guarantees or
warranties at all). 

<P>

<H2><A NAME="SECTION00071000000000000000">
6.1 Known Bugs</A>
</H2>

<P>
It's possible to confuse <TT>makedtx.pl</TT> by placing either the command <TT>&#92;end</TT><code>{document}</code> 
or the command <TT>&#92;ifmakedtx</TT> in a <TT>&#92;verb</TT> command, or by having the <TT>&#92;ifmakedtx</TT> command
on the same line as <TT>&#92;begin</TT><code>{document}</code>.  You will also need to take care about lines beginning
with a percent symbol (%) in the documentation, as this will get converted into a line beginning with <code>%%</code>
in the <TT>.dtx</TT> file, which has a special meaning.  Either place a space immediately prior the percent symbol,
or do <code>\relax%</code> if you really don't want the extra space (or place your comment in an <TT>&#92;iffalse</TT> ... <TT>&#92;fi</TT>
conditional).

<P>

<H2><A NAME="SECTION00072000000000000000">
6.2 Possible errors encountered using <TT>makedtx.pl</TT></A>
</H2>

<P>
Note: be careful to use double quotes around arguments that contain characters that the shell might
try interpreting, e.g. <code>*</code> or <code>&gt;</code>.

<P>
Syntax error messages:

<OL>
<LI><TT>No document source specified (missing -doc)</TT>

<P>
You must use the <TT>-doc</TT> switch.

<P>
</LI>
<LI><TT>No source code specified (missing -src)</TT>

<P>
You must specify at least one <TT>-src</TT> switch.

<P>
</LI>
<LI><TT>No basename specified</TT>

<P>
You must specify the basename of the <TT>.dtx</TT> and <TT>.ins</TT> files.  This should
be the last argument passed to <TT>makedtx.pl</TT>.

<P>
</LI>
<LI><TT>-src ... argument invalid (no output file specified)</TT>

<P>
You have omitted the <code>=&gt;</code> separator in the argument of the <TT>-src</TT> switch.

<P>
</LI>
<LI><TT>-src argument ... invalid (too many =&gt; specified)</TT>

<P>
You have used too many <code>=&gt;</code> separators in the argument of the <TT>-src</TT> switch.
(Similarly for the <TT>-setambles</TT> switch.)
</LI>
</OL>

<P>

<P>

<H1><A NAME="SECTION00080000000000000000"></A>
<A NAME="sec:prex"></A><BR>
A. Perl Regular Expressions
</H1>

<P>
This section gives a very brief overview of Perl regular expressions.  For more detail, look at the Perl
documentation (use <code>man perlre</code> for the man page.)

<P>
<TABLE CELLPADDING=3>
<TR><TD ALIGN="LEFT"><code>\</code></TD>
<TD ALIGN="LEFT">Quote the next character</TD>
</TR>
<TR><TD ALIGN="LEFT"><code>.</code></TD>
<TD ALIGN="LEFT">Match any character</TD>
</TR>
<TR><TD ALIGN="LEFT"><code>|</code></TD>
<TD ALIGN="LEFT">Alternation</TD>
</TR>
<TR><TD ALIGN="LEFT"><code>()</code></TD>
<TD ALIGN="LEFT">Grouping</TD>
</TR>
<TR><TD ALIGN="LEFT"><code>[]</code></TD>
<TD ALIGN="LEFT">Character class</TD>
</TR>
<TR><TD ALIGN="LEFT"><code>*</code></TD>
<TD ALIGN="LEFT">Match 0 or more times</TD>
</TR>
<TR><TD ALIGN="LEFT"><code>+</code></TD>
<TD ALIGN="LEFT">Match 1 or more times</TD>
</TR>
<TR><TD ALIGN="LEFT"><code>?</code></TD>
<TD ALIGN="LEFT">Match 1 or 0 times</TD>
</TR>
<TR><TD ALIGN="LEFT"><code>{n}</code></TD>
<TD ALIGN="LEFT">Match exactly <TT>n</TT> times</TD>
</TR>
<TR><TD ALIGN="LEFT"><code>{n,}</code></TD>
<TD ALIGN="LEFT">Match at least <TT>n</TT> times</TD>
</TR>
<TR><TD ALIGN="LEFT"><code>{n,m}</code></TD>
<TD ALIGN="LEFT">Match at least <TT>n</TT> but no more than <TT>m</TT> times.</TD>
</TR>
</TABLE>

<P>
In the replacement text, a backslash followed by a number <I>n</I> indicates the text from the <I>n</I>th group.

<P>
For example, suppose you have the following files:
<PRE>
abcsrc.sty
abcsrc.bst
abcsrc.perl
foosrc.sty
foobarsrc.sty
</PRE>
then if you pass the following switch to <TT>makedtx.pl</TT>:

<UL>
<LI><code>-src "abcsrc\.([styb]+)=&gt;abc.\1"</code> 
will be equivalent to:
<PRE>
-src "abcsrc.sty=&gt;abc.sty" -src "abcsrc.bst=&gt;abc.bst"
</PRE>
since <code>[styb]+</code> will match one or more of the letters <TT>styb</TT> (so it will match <TT>sty</TT> and <TT>bst</TT>).
<code>\1</code> indicates the text found in the first group, which in this example will either be <TT>sty</TT> or <TT>bst</TT>.

<P>
</LI>
<LI><code>-src "abcsrc\.(.+)=&gt;abc.\1"</code>
will be equivalent to:
<PRE>
-src "abcsrc.sty=&gt;abc.sty" -src "abcsrc.bst=&gt;abc.bst" -src "abcsrc.perl=&gt;abc.perl"
</PRE>
Note that a full stop represents any character so <TT>.+</TT> means any string of length 1 or more, whereas
<code>\.</code> means an actual full stop character.

<P>
</LI>
<LI><code>-src "foo(.*)src\.sty=&gt;foo\1.sty"</code>
will be equivalent to:
<PRE>
-src "foosrc.sty=&gt;foo.sty" -src "foobarsrc.sty=&gt;foobar.sty"
</PRE>

<P>
</LI>
<LI><code>-src "(.+)src\.(.+)=&gt;\1.\2"</code>
will be equivalent to
<PRE>
-src "abcsrc.sty=&gt;abc.sty"
-src "abcsrc.bst=&gt;abc.bst"
-src "abcsrc.perl=&gt;abc.perl"
-src "foosrc.sty=&gt;foo.sty"
-src "foobarsrc.sty=&gt;foobar.sty"
</PRE>

<P>
</LI>
</UL>

<P>
 
<H2><A NAME="SECTION00090000000000000000">
Bibliography</A>
</H2><DL COMPACT><DD><P></P><DT><A NAME="Goossens93">1</A>
<DD> The LaTeX companion. Michel&nbsp;Goossens, Frank&nbsp;Mittelbach and Alexander&nbsp;Samarin.
Addison-Wesley 1993.

<P>
<P></P><DT><A NAME="Kopka98">2</A>
<DD> A guide to LaTeX.  Helmut&nbsp;Kopka and Patrick&nbsp;W.&nbsp;Daly. Addison-Wesley 1998.
</DL>

<P>

<H1><A NAME="SECTION000100000000000000000">
Contact Details</A>
</H1>

<P>
<TABLE CELLPADDING=3>
<TR><TD ALIGN="LEFT">Dr Nicola Talbot</TD>
</TR>
<TR><TD ALIGN="LEFT">School of Computing Sciences</TD>
</TR>
<TR><TD ALIGN="LEFT">University of East Anglia</TD>
</TR>
<TR><TD ALIGN="LEFT">Norwich. NR4 7TJ</TD>
</TR>
<TR><TD ALIGN="LEFT">United Kingdom</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT><A NAME="tex2html6"
  HREF="http://theoval.cmp.uea.ac.uk/~nlct/">http://theoval.cmp.uea.ac.uk/~nlct/</A></TT></TD>
</TR>
</TABLE>

<P>
<BR><HR><H4>Footnotes</H4>
<DL>
<DT><A NAME="foot48">... script</A><A NAME="foot48"
 HREF="manual.html#tex2html4"><SUP>1</SUP></A>
<DD>or at least, it's laborious if there
are rather a lot of files associated with a package

<DT><A NAME="foot401">...manual.tex</A><A NAME="foot401"
 HREF="manual.html#tex2html5"><SUP>2</SUP></A>
<DD>Note: if you
want to use LaTeX2HTML on this document, you will need to use, e.g., <TT>&#92;verb!<TT>&#92;today</TT>!</TT> instead of 
<TT>&#124;<TT>&#92;today</TT>&#124;</TT> since it doesn't recognise <TT>&#92;MakeShortVerb</TT>.

</DL><BR><HR>
<ADDRESS>
<h5>N.L.C. Talbot. School of Computing Sciences. University of East Anglia. Last Modified: 2005-02-13</h5>
</ADDRESS>
</BODY>
</HTML>