| 1 |
--- |
| 2 |
title: edtx2dtx |
| 3 |
section: 1 |
| 4 |
header: User Manual |
| 5 |
footer: edtx2dtx 0.2.0 |
| 6 |
date: November 23, 2024 |
| 7 |
hyphenate: false |
| 8 |
--- |
| 9 |
|
| 10 |
# NAME |
| 11 |
edtx2dtx - Convert .edtx into .dtx |
| 12 |
|
| 13 |
|
| 14 |
# SYNOPSIS |
| 15 |
**edtx2dtx** *filename.edtx* > *filename.dtx* |
| 16 |
|
| 17 |
|
| 18 |
# DESCRIPTION |
| 19 |
|
| 20 |
This utility wraps code chunks by a (commented and properly indented) |
| 21 |
`\begin{macrocode}` and `\end{macrocode}` pair. A code chunk is any sequence of |
| 22 |
lines not introduced by a single (possibly indented) comment character (`%`); |
| 23 |
i.e. both non-commented lines and lines introduced by multiple comment |
| 24 |
characters count as code, and documentation lines may be indented. |
| 25 |
|
| 26 |
The part of the file which should be processed should be marked by a |
| 27 |
`\begin{macrocode}` and `\end{macrocode}` pair. In other words, everything |
| 28 |
preceding `\begin{macrocode}` is considered a header and not changed, and |
| 29 |
everything following `\end{macrocode}` is considered a trailer and not changed. |
| 30 |
In fact, any number of `\begin{macrocode}` — `\end{macrocode}` pairs is |
| 31 |
allowed. (The system allows for the driver to remain as is, and also makes it |
| 32 |
easy to paste a `.dtx` file into an `.edtx`, as using this utility on a `.dtx` |
| 33 |
does not change the file.) |
| 34 |
|
| 35 |
The utility furthermore replaces the first occurrence of `<filename>.edtx` in |
| 36 |
the header, followed by an optional parenthesized note, with `<filename>.dtx`, |
| 37 |
plus the note on how the file was generated. |
| 38 |
|
| 39 |
|
| 40 |
# OPTIONS |
| 41 |
|
| 42 |
**-c, \--comment** |
| 43 |
: The input comment character; the default is `%`. (Any input comment |
| 44 |
characters in the header and the trailer will be replaced by the output |
| 45 |
comment character, which is always `%`.) |
| 46 |
|
| 47 |
**-b, \--begin-macrocode** *regex*\ |
| 48 |
|
| 49 |
**-e, \--end-macrocode** *regex* |
| 50 |
: Use these options to change the default *input* `\begin{macrocode}` and |
| 51 |
`\end{macrocode}` markers. (The *output* markers are always |
| 52 |
`\begin{macrocode}` and `\end{macrocode}`.) The markers should be given as |
| 53 |
regular expressions matching the entire line. The input markers are not kept |
| 54 |
in the file, i.e. they are replaced by the output markers. |
| 55 |
|
| 56 |
**-B, \--Begin-macrocode** *regex*\ |
| 57 |
|
| 58 |
**-E, \--End-macrocode** *regex* |
| 59 |
: As `-b` and `-e`, but the input markers are kept in the output. |
| 60 |
|
| 61 |
**-s, \--strip-empty** |
| 62 |
: If this option is given, empty lines are not included in the output. |
| 63 |
|
| 64 |
**-h, \--help** |
| 65 |
: Show help and exit. |
| 66 |
|
| 67 |
**-V, \--version** |
| 68 |
: Show the version number and exit. |
| 69 |
|
| 70 |
|
| 71 |
# EXAMPLES |
| 72 |
|
| 73 |
If `input.edtx` is just like a `dtx` file, just without `\begin{macrocode}` and |
| 74 |
`\end{macrocode}` around every chunk of code: |
| 75 |
|
| 76 |
edtx2dtx input.edtx > output.dtx |
| 77 |
|
| 78 |
Memoize uses the invocation below to produce a `.dtx` from documented Python |
| 79 |
code of `memoize-extract.py`. The value of `-c` adapts the `edtx2dtx` to |
| 80 |
Python comments. `-B` marks everything preceding the version number statement |
| 81 |
as a header, and keeps the version number statement in the output. Similarly, |
| 82 |
`-E` says that the processing should stop when encountering Emacs' local |
| 83 |
variables (which are kept, unchanged, in the output). |
| 84 |
|
| 85 |
edtx2dtx -s -c '#' -B '^__version__' -E '^# Local Variables:' $< \ |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
# SEE ALSO |
| 90 |
|
| 91 |
[easydoctex.el](????) |