Debian Codegraph @

texmf-dist/doc/latex/codeanatomy/demo-anatomy-of-a-method-signature.tex

raw
1 \begin{lrbox}{\mycodebox}
2 \lstset{escapeinside={!}{!}}
3 \begin{lstlisting}
4 public class !\iPart{l}{Math}!
5 ....
6 !\cPart{s}{\bgcode{static} \iPart{r}{double} \iPart{n}{sqrt}(\iPart{a}{double} a)}!
7 ....
8 \end{lstlisting}
9 \end{lrbox}
10
11 \begin{tikzpicture}[remember picture]
12 \node(code) [anatomy] at (0,0) {\usebox\mycodebox};
13
14 % Annotation
15 \codeAnnotation{lText} (3,2.5) {library name}
16 \codeAnnotation{sText} (-1,1) {signature}
17 \codeAnnotation{nText} (4.5,1.5) {method name}
18 \codeAnnotation{rText} (2.0,-0.51) {return type}
19 \codeAnnotation{aText} (4.5,-0.51) {argument type}
20 % Arrows
21 \draw[->, annotation] (lText) -- (l);
22 \draw[->, annotation] (nText) -- (n);
23 \draw[->, annotation] (sText) -- (s);
24 \draw[->, annotation] (rText) -- (r);
25 \draw[->, annotation] (aText) -- (a);
26 \end{tikzpicture}