summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/nicetext/docsrc/makedoc.tex
blob: 65beb83f9f189d51a1d140890a246b4adf80b6ff (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
\ProvidesPackage{makedoc.tex}[2009/02/21 (UL)]
%% make packagecode environments and remove percents starting lines

\makeatletter \catcode`\_=11

\openin\@inputcheck=niceverb.sty %% JUST HERE
\newwrite\result_file
  \immediate\openout \result_file=niceverb.doc %% JUST HERE

\newif\if_package_code_     \_package_code_false
% \newif\if_empty_code_lines_ \_empty_code_lines_false
  %% <- FAILED SO FAR
% \let\maybe_result_empty_line\empty
% \def\result_empty_line{^^J}

\def\write_result{\immediate\write\result_file}

\def\process_file{%
  %% This macro here to avoid category changes 
  %% affecting the present code
  \begingroup 
    \let\do\@makeother \dospecials
    %% from docstrip.tex: 
    \@makeother\^^A\@makeother\^^K\endlinechar\m@ne
    %% <- cf. TeXbook "extended keyboards" up-/downarrow
    %%    -> "math specials", cf. "space specials"
    \@makeother\^^I% ASCII horizontal tab -- guessed!? ^^L!?
%    \tracingmacros=1
    \loop \ifeof\@inputcheck \else 
      \read\@inputcheck to \InputLine
      \expandafter \process_line \InputLine ======&%% primitive version
    \repeat 
  \endgroup} 

\def\process_line#1===#2===#3&{%% may be preferable to wiki.sty
  \ifx$#2$%
    \ifx$#1$%
%      \show\InputLine
      \if_package_code_
%         \if_empty_code_lines_ 
%           \write_result{}\_empty_code_lines_false
%         \fi
      \else 
          \write_result{}%
%         \let\maybe_result_empty_line\result_empty_line
      \fi
    \else 
%      \show\InputLine
      \if_package_code_
%         \_empty_code_lines_true
      \else
        \write_result{\string\begin{packagecode}}%
        \_package_code_true
      \fi
      \write_result{#1}%
%       \write_result{\maybe_result_empty_line #1}%
%       \let\maybe_result_empty_line\empty
    \fi
  \else
    \write_result{%
      \string\end{packagecode}^^J^^J%
      \string\subsection{\ignorespaces#2\unskip}^^J}%
    \_package_code_false 
%     \_empty_code_lines_false
  \fi}

\process_file

\write_result{\string\end{packagecode}}
\closein\@inputcheck \immediate\closeout\result_file

\endinput

\stop
  %% TODO or \ThankYou; which NICEVERB.TEX may redefine into \endinput 
  %%      or \ThankYou issues \endinput if jobname ... 
  %%      the whole file may be enclosed in \begingroup ... \endgroup 
  %%      ... this is a "driver file"!?

TODO make own listing environment like this -- own linewise processing,
     without verbatim.sty