doku skeleton is standing

This commit is contained in:
nobody 2024-12-07 23:05:49 +01:00
parent 78170e6bcc
commit c97298ed18
6 changed files with 94 additions and 3361 deletions

1
.gitignore vendored
View file

@ -5,5 +5,6 @@
*.toc
*.pdf
_minted-*
cccbform-examples
*.fdb_latexmk
*.fls

View file

@ -8,6 +8,7 @@ all: $(ALLPDF)
clean:
latexmk -c
rm -r _minted-doku cccbform-examples
distclean:
latexmk -C

View file

@ -23,11 +23,11 @@
\@Exampletrue
}
\DeclareOption{shortexample}{
\geometry{paperwidth=105mm, paperheight=74mm, margin=1ex}
\geometry{paperwidth=105mm, paperheight=74mm, margin=2ex}
\@Exampletrue
\AtEndDocument{%
\pageheight=\pagetotal
\advance\pageheight by 2ex
\advance\pageheight by 4ex
}
}
\ProcessOptions\relax

119
doku.tex
View file

@ -1,5 +1,5 @@
\documentclass{ltxdoc}
\usepackage{tikz,fancyvrb,geometry,minted,fontspec}
\usepackage{tikz,geometry,minted,fontspec,luacode}
\usepackage[ngerman]{babel}
\usetikzlibrary{positioning}
\geometry{a4paper,margin=2cm}
@ -50,40 +50,93 @@
\directlua{ os.execute "cp cccbform.cls cccbform-examples/" }
\directlua{ os.execute "cp logo.pdf cccbform-examples/" }
\NewDocumentCommand{\LineCount}{m}{\directlua{
local n, f = 0, io.open("cccbform-examples/#1.tex")
for l in f:lines() do n = n + 1 end
tex.print( n - 1 )
}}
\begin{luacode*}
HEADER = [[
\documentclass[shortexample]{cccbform}
\begin{document}
]]
FOOTER = [[
\end{document}
]]
\end{luacode*}
\NewDocumentEnvironment{ShortExample}{m}{
\VerbatimEnvironment
\begin{VerbatimOut}{cccbform-examples/#1.tex}[]
\documentclass[shortexample]{cccbform}
\begin{document}}{
\end{document}
\end{VerbatimOut}
\directlua{ os.execute "cd cccbform-examples ; latexmk -pdflua #1.tex" }
\edef\lc{\LineCount{#1}}
\begin{tikzpicture}
\node[anchor=north west, inner sep=1ex, draw] (code) {
\begin{minipage}[t]{0.45\textwidth}
\inputminted[firstline=3,lastline=\lc]{tex}{cccbform-examples/#1.tex}
\end{minipage}
};
\node[anchor=north west, right=2mm of code, draw] (output) {
\begin{minipage}[t]{0.45\textwidth}
\includegraphics[width=\linewidth]{cccbform-examples/#1.pdf}
\end{minipage}
};
\end{tikzpicture}
\begin{luacode*}
function makeVerb( envname )
local buf
local function bufread( chunk )
if chunk:find( "\\end{"..envname.."}" ) then return nil end
buf[#buf+1] = chunk
return ""
end
local function luaverbstart( )
buf = { }
luatexbase.add_to_callback( "process_input_buffer", bufread, "bufread" )
end
local function luaverbend( )
luatexbase.remove_from_callback( "process_input_buffer", "bufread" )
buf[#buf+1] = ""
buf = table.concat( buf, "\n" )
return buf
end
return luaverbstart, luaverbend
end
function CMD(name) return "\\"..name end
\end{luacode*}
\directlua{ ShortExampleStart, ShortExampleEnd = makeVerb "ShortExample" }
\NewDocumentEnvironment{ShortExample}{m m}{
\directlua{ShortExampleStart()}}{\directlua{
CONTENT = ShortExampleEnd( )
local f = io.open( "cccbform-examples/#1.tex", "w" )
f:write( HEADER, CONTENT, FOOTER )
f:close( )
os.execute( "cd cccbform-examples ; latexmk -pdflua #1.tex" )
local n, f = 0, io.open( "cccbform-examples/#1.tex" )
for l in f:lines( ) do n = n + 1 end
tex.print( CMD"def"..CMD"lc".."{" .. (n-1) .. "}" )
}
\begin{tikzpicture}[example frame/.style={draw=gray!50, thick, inner sep=1ex}]
\node[draw=gray!30, fill=gray!5, inner sep=1ex, rounded corners, minimum width=\textwidth] (example container) {};
\node[example frame, anchor=north west, minimum height=7cm] (code) at (example container.north west) {
\begin{minipage}[t]{0.45\textwidth}
\inputminted[firstline=3,lastline=\lc]{tex}{cccbform-examples/#1.tex}
\end{minipage}
};
\node[example frame, anchor=north west, right=2mm of code, minimum height=7cm] (output) {
\begin{minipage}[t]{0.45\textwidth}
\includegraphics[width=\linewidth]{cccbform-examples/#1.pdf}
\end{minipage}
};
\node[anchor=north west, font=\small\itshape] at (example container.north west |- code.north west) {Example: #2};
\end{tikzpicture}
% \begin{tikzpicture}
% \node[anchor=north west, inner sep=1ex, draw] (code) {
% \begin{minipage}[t]{0.45\textwidth}
% \inputminted[firstline=3,lastline=\lc]{tex}{cccbform-examples/#1.tex}
% \end{minipage}
% };
% \node[anchor=north west, right=2mm of code, draw] (output) {
% \begin{minipage}[t]{0.45\textwidth}
% \includegraphics[width=\linewidth]{cccbform-examples/#1.pdf}
% \end{minipage}
% };
% \end{tikzpicture}
}
\NewDocumentEnvironment{StandaloneExample}{m}{
\VerbatimEnvironment%
\begin{VerbatimOut}{cccbform-examples/#1.tex}}%
{\end{VerbatimOut}%
\directlua{ os.execute "cd cccbform-examples ; latexmk -pdflua #1.tex" }
\edef\lc{\LineCount{#1}}
\directlua{
local n, f = 0, io.open( "cccbform-examples/#1.tex" )
for l in f:lines( ) do n = n + 1 end
tex.print( CMD"def"..CMD"lc".."{" .. (n-1) .. "}" )
}
\begin{tikzpicture}
\node[anchor=north west, inner sep=1ex, draw] (code) {
\begin{minipage}[t]{0.45\textwidth}
@ -106,8 +159,16 @@
\section{Übersicht}
\begin{ShortExample}{test}
\begin{ShortExample}{text}{Text}
\Text{Test}
\end{ShortExample}
\begin{ShortExample}{textfield}{normales Textfeld}
\TextField{abc}
\end{ShortExample}
\begin{ShortExample}{shorttextfield}{kurzes Textfeld}
\ShortTextField{abc}
\end{ShortExample}
\end{document}

File diff suppressed because it is too large Load diff

49
mwe.tex
View file

@ -1,49 +0,0 @@
\documentclass{standalone}
\usepackage{tikz,fvextra,minted,luacode}
\usetikzlibrary{positioning}
\directlua{ os.execute "mkdir -p examples" }
\NewDocumentCommand{\LineCount}{m}{\directlua{
local n, f = 0, io.open("examples/#1.tex")
for l in f:lines() do n = n + 1 end
tex.print( n - 1 )
}}
\newwrite\examplefile
\NewDocumentEnvironment{ShortExample}{m}{
\VerbatimEnvironment
\immediate\openout\examplefile=examples/#1.tex\relax
\begin{VerbatimWrite}[writefilehandle=\examplefile]
\documentclass{standalone}
\begin{document}
\end{VerbatimWrite}
\begin{VerbatimWrite}[writefilehandle=\examplefile]}%
{\end{VerbatimWrite}
\begin{VerbatimWrite}[writefilehandle=\examplefile]
\end{document}
\end{VerbatimWrite}
\immediate\closeout\examplefile
\directlua{ os.execute( "cd examples ; latexmk -pdflua ".."#1"..".tex" ) }
\edef\lc{\LineCount{#1}}
\begin{tikzpicture}
\node[anchor=north west, inner sep=1ex, draw] (code) {
\begin{minipage}[t]{0.45\textwidth}
\inputminted[autogobble=true,firstline=3,lastline=\lc]{tex}{examples/#1.tex}
\end{minipage}
};
\node[anchor=north west, right=2mm of code, draw] (output) {
\begin{minipage}[t]{0.45\textwidth}
\includegraphics[width=\linewidth]{examples/#1.pdf}
\end{minipage}
};
\end{tikzpicture}
}
\begin{document}
\begin{ShortExample}{test}
Test
\end{ShortExample}
\end{document}