summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-01-27 22:00:15 +0000
committerKarl Berry <karl@freefriends.org>2023-01-27 22:00:15 +0000
commitd5425523a3a381c8bd16a0a1da0fc5ac4685b32f (patch)
tree85441da4ec969da1722edc2daa203ee6551be79f
parentf38adb3bc282f60dbb321e661fa59c7244854282 (diff)
codeanatomy (26jan23)
git-svn-id: svn://tug.org/texlive/trunk@65648 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/codeanatomy/README.md22
-rw-r--r--Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.lstlisting.pdfbin123921 -> 120024 bytes
-rw-r--r--Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.lstlisting.tex139
-rw-r--r--Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.pdfbin97601 -> 110750 bytes
-rw-r--r--Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.usage.pdfbin82738 -> 102008 bytes
-rw-r--r--Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.usage.tex119
-rw-r--r--Master/texmf-dist/doc/latex/codeanatomy/release-note-v0.4-Alpha.txt1
-rw-r--r--Master/texmf-dist/source/latex/codeanatomy/codeanatomy.dtx50
-rw-r--r--Master/texmf-dist/tex/latex/codeanatomy/codeanatomy.sty18
9 files changed, 264 insertions, 85 deletions
diff --git a/Master/texmf-dist/doc/latex/codeanatomy/README.md b/Master/texmf-dist/doc/latex/codeanatomy/README.md
index 32d85cfa5ba..1a3a55f2c3b 100644
--- a/Master/texmf-dist/doc/latex/codeanatomy/README.md
+++ b/Master/texmf-dist/doc/latex/codeanatomy/README.md
@@ -1,5 +1,5 @@
-`codeanatomy` -- Draw Code Anatomy
-==================================
+# `codeanatomy` -- Draw Code Anatomy #
+
(C) 2019 Hồng-Phúc Bùi
@@ -11,23 +11,23 @@ from Robert Sedgewick and Kevin Wayne.
This package just provides tools to draw those figures.
Some illustrations can be found here:
-
<a href="https://introcs.cs.princeton.edu/java/home/">https://introcs.cs.princeton.edu/java/home/</a>
+For example: Anatomy of a static method:
+
-for example the origin illustation of static method in java:
-<img src="https://introcs.cs.princeton.edu/java/11cheatsheet/images/function.png">
+_![Anatomy of a static method](https://introcs.cs.princeton.edu/java/11cheatsheet/images/function.png)_
-Licence
--------
+## Licence ##
+
This package may be distributed and/or modified under the conditions of the
LaTeX Project Public License (LPPL), either version 1.3c of this
License or any later version. The latest version
of this license is in the file https://www.latex-project.org/lppl.txt
-Build and Install (for Distributor)
------------------------------------
+## Build and Install (for Distributor) ##
+
* To build the style file `codeanatomy.sty` just run **one** of
@@ -50,8 +50,8 @@ lualatex codeanatomy.lstlisting.tex
(`lualatex` because of my name, really ego right! It needs unicode to be typeset correctly.)
-Development
------------
+## Development ##
+
I try to use latex3 as much as posible. You can use
diff --git a/Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.lstlisting.pdf b/Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.lstlisting.pdf
index 4279660c8c3..eabe1d61bdf 100644
--- a/Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.lstlisting.pdf
+++ b/Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.lstlisting.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.lstlisting.tex b/Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.lstlisting.tex
index b8956cea221..1e676f58e1d 100644
--- a/Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.lstlisting.tex
+++ b/Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.lstlisting.tex
@@ -1,11 +1,12 @@
-\documentclass[full]{l3doc}
+\documentclass{article}
\usepackage{fontspec}
+
\usepackage[backend=biber]{biblatex}
\addbibresource{literatur.bib}
-\usepackage{codeanatomy}
+\usepackage{codeanatomy}
\usepackage{listings}
\lstset {
basicstyle=\small\ttfamily%
@@ -17,18 +18,17 @@
,keepspaces=true
}
-\def\thinmargin{\list{}{\rightmargin-30pt\leftmargin-70pt}\item[]}
-\let\endthinmargin=\endlist
-
-\usepackage{filecontents}
+%\usepackage{filecontents}
+% command from ltxdoc
+\newcommand{\pkg}[1]{\textsf{#1}}
% others shortcuts
\newcommand{\slsh}{\textbackslash{}}
\newcommand{\TikZ}{Ti\textit{k}Z}
\newcommand{\inputlisting}[1]{%
\lstinputlisting[%
basicstyle=\footnotesize\ttfamily%
- ,xleftmargin=-70pt%
+ ,xleftmargin=-40pt%
,resetmargins=true%
,firstline=5%
,language=%
@@ -36,11 +36,12 @@
,escapeinside={}{}%
]{#1}%
}
+\def\thinmargin{\list{}{\rightmargin-30pt\leftmargin-40pt}\item[]}
+\let\endthinmargin=\endlist
-\usepackage{hyperref}
-\GetFileInfo{codeanatomy.sty}
-\DoNotIndex{}
+\usepackage{readprov} % need for \GetFileInfo{}
+\usepackage{hyperref}
\title{
\pkg{codeanatomy} -- Draw Code Anatomy%
@@ -50,7 +51,7 @@
}
\author{
- Hồng-Phúc Bùi
+ Hồng-Phúc Bùi%
\thanks{
E-mail:
\href{mailto:Hồng-Phúc Bùi}
@@ -60,20 +61,21 @@
\date{Released \filedate}
-\AtEndDocument{
- \printbibliography
-}
+
\begin{document}
+\GetFileInfo{codeanatomy.sty}
+
\maketitle
\tableofcontents
-\section{General Usage in Conjuntion with Package \pkg{listings}}
+
+\section{General Usage with Package \pkg{listings}}
\subsection{Setup Package \pkg{listings}}
The most important setup for the package \pkg{listings} is the delimiter to escape \LaTeX{}
-commands in Listing. With this escape delimiter we can mark a piece of code as with |\cPart|.
-In this example we use |!| and |!| as delimiter. Code between |!| and |!| is evaluated as
+commands in Listing. With this escape delimiter we can mark a piece of code as with \verb|\cPart|.
+In this example we use \verb|!| and \verb|!| as delimiter. Code between \verb|!| and \verb|!| is evaluated as
\LaTeX{}-code.
\lstset {
@@ -99,13 +101,17 @@ In this example we use |!| and |!| as delimiter. Code between |!| and |!| is eva
\end{thinmargin}
-Delimiter can also be reset in |document|-Environment, typical just before a new \verb:\begin{lstlisting}:
-environment so each anatomy can have different delimiter. The fact is, in this document I use |+| and |+| for
-the above listing, so that I can typeset |!| in this listing.
+Delimiter can also be reset in \verb|document|-Environment, typical just before a new \verb:\begin{lstlisting}:
+environment so each anatomy can have different delimiter. The fact is, in this document I use \verb|+| and \verb|+| for
+the above listing, so that I can typeset \verb|!| in this listing.
+
+You may also want to set option \verb|keepspaces| to \verb|true|, sothat your reader can easy copy past
+your example code.
\subsection{Typeset Code}
-The command |\codeBlock| does not work if the environment |lstlisting| is passed to its argument. So instead of
-|\codeBlock| we must use the \TikZ{} command |\node|:
+% -----------------------
+The command \verb|\codeBlock| does not work if the environment \verb|lstlisting| is passed to its argument. So instead of
+\verb|\codeBlock| we must use the \TikZ{} command \verb|\node|:
\begin{thinmargin}
\begin{tikzpicture}[remember picture]
@@ -169,10 +175,10 @@ function gcd(p,q) {
\subsection{Mark Code}
% --------------------
-The command |\cPart| can be used to mark single-line code parts. For
-multiple-line code parts once can use |\extremPoint| to mark the outer most
-points of code parts and |\fitExtrem| to cover exterm points of a code part.
-These commmands must be put in delimiter, here |!| and |!|.
+The command \verb|\cPart| can be used to mark single-line code parts. For
+multiple-line code parts once can use \verb|\xxxPoint| family to mark the outer most
+points of code parts and \verb|\fitExtrem| to cover exterm points of a code part.
+These commmands must be put between escape delimiter, here \verb|!| and \verb|!|.
\begin{thinmargin}
\begin{tikzpicture}[remember picture]
@@ -181,7 +187,7 @@ These commmands must be put in delimiter, here |!| and |!|.
\begin{tikzpicture}[remember picture]
\node(code) [anatomy] at (0,0) {
+\texttt{\slsh{}begin\{lstlisting\}}+
-!\cPart{fnHead}{function \cPart{fnName}{gcd}\cPart{paramList}{(p,q)}}! {
+!\cPart{fnHead}{function \cPart{fnName}{gcd} \cPart{paramList}{(p,q)}}! {
+\cPart{ep1}{!\slsh{}mtPoint\{mostLeft\}!}+if (q === 0) {
return q;
}else{
@@ -196,7 +202,7 @@ These commmands must be put in delimiter, here |!| and |!|.
\end{lstlisting}
};
% Annotations
-\codeAnnotation{epText} (11,2.5) {\texttt{extremPoint}-s mark\\outer most\\of the function body}
+\codeAnnotation{epText} (12,2.75) {xxx\texttt{Point}-s mark\\outer most\\of the function body}
\codeAnnotation{cpText} (-2,3) {\texttt{cPart} marks a\\single line\\code part}
% Arrows
\draw[->,annotation] (epText) -- (ep1.south east);
@@ -229,19 +235,55 @@ Figure~\ref{fig:listing-code-parts} shows the result of the above code.
\caption{Code Listing with mark of code parts\label{fig:listing-code-parts}}
\end{figure}
+
+\subsection{Highlight some tokens}
+
+\begin{filecontents}{recursive-with-bug.tex}
+\lstset{escapeinside={!}{!},basicstyle=\linespread{1.8}}
+\begin{tikzpicture}[remember picture]
+\tikzstyle{token} = [code part, fill=yellow]
+\tikzstyle{bug} = [code part, fill=red!50]
+\node(code) [anatomy] at (0,0) {
+\begin{lstlisting}
+function !\cPart[token]{fnName}{gcd}! (p,q) {
+ if (q === 0) {
+ return !\cPart[bug]{bug}{q}!;
+ } else {
+ let r = p % q;
+ return !\cPart[token]{recursive}{gcd}!(q, r);
+ }
+}
+\end{lstlisting}
+};
+\codeAnnotation{recursiveText} (-1,2) {Function can\\call itself.}
+\codeAnnotation{bugText} ( 5,2.25) {This is\\the bug.}
+
+\draw[->, annotation] (recursiveText) to[out=50, in=190] (fnName);
+\draw[->, annotation] (recursiveText) to[out=-20, in=175] (recursive.north west);
+\draw[->, annotation] (bugText) to[out=190,in=-20] (bug.south east);
+\end{tikzpicture}
+\end{filecontents}
+
+%\begin{thinmargin}
+\inputlisting{recursive-with-bug.tex}
+%\end{thinmargin}
+
+\input{recursive-with-bug.tex}
+
+
+
+
+
\subsection{Add Annotations to Listing}
% -------------------------------------
-This step is the same as the description in the main document of package \pkg{codeanatomy}.
+This step is the same as the description in the usage document of package \pkg{codeanatomy}.
Readers can typeset annotations to the above listing like an exercise.
-
-
\section{Some examples}
% ====================
-% Reset to standard
Most of examples in this section are redrawn from the textbook~\autocite{sedgewick-wayne-2016}.
@@ -260,7 +302,7 @@ public !\iPart{class}{class}! !\cPart{className}{HelloWorld}!
!\hmtPoint{left}\iPart{assign}{
\bgcode{// Prints "Hello World" in the terminal window}}
\extremPoint{fnR} \extremPoint{mR}!
- !\iPart{fnCall}{System.out.print( "Hello World");}\dmbPoint{mostBottom}!
+ !\iPart{fnCall}{System.out.print("Hello World");}\dmbPoint{mostBottom}!
}!\mbPoint{mainBottom}!
}
\end{lstlisting}
@@ -276,18 +318,20 @@ public !\iPart{class}{class}! !\cPart{className}{HelloWorld}!
\codeAnnotation{functionBodyText} (2.5,-0.5) {body}
\codeAnnotation{statement} (8,0) {statements}
+{[on background layer]
\draw[->,annotation] (fileNameText) -- (class);
\draw[->,annotation] (classNameText) -- (className);
\draw[->,annotation] (classBodyText.south west) -- (classBody);
\draw[->,annotation] (functionBodyText) -- (functionBody);
\draw[->,annotation] (statement) -- (assign.353);
\draw[->,annotation] (statement) -- (fnCall.350);
+}
\end{tikzpicture}
\end{filecontents}
-\begin{thinmargin}
+%\begin{thinmargin}
\inputlisting{java-program.tex}
-\end{thinmargin}
+%\end{thinmargin}
\input{java-program.tex}
@@ -486,7 +530,6 @@ while ( !\cPart{c}{power <= n/2}! )
\inputlisting{anatomy-of-a-while-loop.tex}
\end{thinmargin}
-{\sffamily test font if while do}
\input{anatomy-of-a-while-loop.tex}
@@ -517,7 +560,7 @@ for ( !\cPart{i}{int i = 0}!; !\cPart{c}{i <= n}!; !\cPart{u}{i++}! )
\codeAnnotation{initText} (-1.5,2.7) {initialize another\\
variable in a \extremPoint{initPoint}[0.75ex]\\
separate\\statement}
-\codeAnnotation{iText} (1,3.5) {declare and initialize\\
+\codeAnnotation{iText} (1.2,3.5) {declare and initialize\\
a loop control variable}
\codeAnnotation{cText} (3.5,3) {loop-\\continuation\\condition}
\codeAnnotation{uText} (6,3) {increment}
@@ -562,15 +605,15 @@ for ( !\cPart{i}{int i = 0}!; !\cPart{c}{i <= n}!; !\cPart{u}{i++}! )
\fitExtrem{b}{(left) (right) (bottom)}
% Annotation
-\codeAnnotation{sText} (-0.7,5) {signature}
-\codeAnnotation{rtText} (2,5) {return\\type}
-\codeAnnotation{fnText} ( 4,5) {method\\name}
-\codeAnnotation{alText} ( 6,5) {argument\\list}
-\codeAnnotation{atText} (6.5,1.75) {argument\\type}
-\codeAnnotation{pvText} (7.5,2.70) {parameter\\variable}
-\codeAnnotation{lvText} (-0.7,2.5) {local\\variable}
-\codeAnnotation{bText} (-0.7,1.5) {method\\body}
-\codeAnnotation{rsText} (3,-0.4) {return statement}
+\codeAnnotation{sText} (-0.7,5.25) {signature}
+\codeAnnotation{rtText} (2,5.25) {return\\type}
+\codeAnnotation{fnText} ( 4,5.25) {method\\name}
+\codeAnnotation{alText} ( 6,5.25) {argument\\list}
+\codeAnnotation{atText} (6.75,1.75) {argument\\type}
+\codeAnnotation{pvText} (7.5,2.70) {parameter\\variable}
+\codeAnnotation{lvText} (-0.7,3) {local\\variable}
+\codeAnnotation{bText} (-0.7,1.5) {method\\body}
+\codeAnnotation{rsText} (3,-0.4) {return statement}
% Arrows
\draw[->,annotation] (sText) -- (s.north west);
\draw[->,annotation] (rtText) -- (rt);
@@ -590,5 +633,7 @@ for ( !\cPart{i}{int i = 0}!; !\cPart{c}{i <= n}!; !\cPart{u}{i++}! )
\input{anatomy-of-a-static-method.tex}
-\end{document}
+\printbibliography
+
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.pdf b/Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.pdf
index 3348439ed5a..fbda22f622c 100644
--- a/Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.pdf
+++ b/Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.usage.pdf b/Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.usage.pdf
index 5057ad4a547..66f2e744956 100644
--- a/Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.usage.pdf
+++ b/Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.usage.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.usage.tex b/Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.usage.tex
index 5136905babb..0ebe274d272 100644
--- a/Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.usage.tex
+++ b/Master/texmf-dist/doc/latex/codeanatomy/codeanatomy.usage.tex
@@ -237,6 +237,7 @@ we can use |\\[<length>]| to add a little amount of vertical space, sothat the b
each others.
\begin{thinmargin}
+{\footnotesize
\begin{tikzpicture}[remember picture]
{[on background layer]\draw[code grid debug] (-0.5,-0.5) grid (10.5,4.5);}\\
\codeBlock{
@@ -258,16 +259,17 @@ each others.
\slsh{}end\{tikzpicture\}
}
-\codeAnnotation{nestedCodePartText}(11,6){\texttt{cPart} can be nested}
-\codeAnnotation{exText} (15,3){\texttt{extremPoint}s\\are used to mark\\outer most points of\\a multiline code part}
+\codeAnnotation{nestedCodePartText}(11,5){\texttt{cPart} can be nested}
+\codeAnnotation{exText} (15,2){\texttt{extremPoint}s\\are used to mark\\outer most points of\\a multiline code part}
\codeAnnotation{fitExtemCmdText} (6,-1){\texttt{fitExtrem} draws a rectangle\\which covers all passed extrem points}
-\draw[->, annotation] (nestedCodePartText) to[out=270,in=90] (nestedCodePart);
-\draw[->, annotation] (exText) to[out=145,in=320] (ep1.south east);
-\draw[->, annotation] (exText) to[out=190,in=300] (ep2.320);
-\draw[->, annotation] (exText) to[out=220,in=350] (ep3.340);
+\draw[->, annotation] (nestedCodePartText) to[out=200,in=40] (nestedCodePart);
+\draw[->, annotation] (exText) to[out=160,in=350] (ep1.south east);
+\draw[->, annotation] (exText) to[out=190,in=340] (ep2.320);
+\draw[->, annotation] (exText) to[out=195,in=350] (ep3.south east);
\draw[->, annotation] (fitExtemCmdText) -- (fitExtemCmd);
\end{tikzpicture}
+}
\end{thinmargin}
@@ -305,12 +307,12 @@ Whereas \parg{annotation label}s are the first argument of |\codeAnnotation|s an
\{[on background layer]\textbackslash{}draw[code grid debug]\\
\ptab\ptab (-0.5,-0.5) grid (6.5,4.5);\}\\
\textbackslash{}codeBlock\{\%\\
-\slsh{}cPart\{functionHead\} \{function \slsh{}cPart\{functionName\}\{gcd\} \slsh{}cPart\{paramList\}\{(p, q)\}\} \slsh\{\\
+\slsh{}cPart\{functionHead\} \{function \slsh{}cPart\{functionName\}\{gcd\} \slsh{}cPart\{paramList\}\{(p, q)\}\} \slsh\{\\
\slsh\slsh[2.5pt]\\
-\slsh{}ptab\{\}\slsh{}mtPoint\{mostLeft\} if (q === 0) \slsh\{ \slsh\slsh\\
-\slsh{}ptab\slsh{}ptab\{\} return p; \slsh\slsh\\
-\slsh{}ptab\slsh \} else \slsh\{ \slsh\slsh\\
-\slsh{}ptab\slsh{}ptab\{\} return gcd(q, p\slsh\%q); \slsh{}extremPoint\{mostRight\} \slsh\slsh\\
+\slsh{}ptab\{\}\slsh{}mtPoint\{mostLeft\} if (q === 0) \slsh\{ \slsh\slsh\\
+\slsh{}ptab\slsh{}ptab\{\} return p; \slsh\slsh\\
+\slsh{}ptab\slsh \} else \slsh\{ \slsh\slsh\\
+\slsh{}ptab\slsh{}ptab\{\} return gcd(q, p\slsh\%q); \slsh{}extremPoint\{mostRight\} \slsh\slsh\\
\slsh{}ptab\slsh{}mbPoint\{mostBottom\}\slsh\} \slsh\slsh\\
\slsh\} \\
\} \\
@@ -373,11 +375,102 @@ as figure~\ref{fig:tut1-function}.
As we see in the previous section, the command |\codeBlock| cannot typeset whitespaces correctly as we
expect. A way to typeset code listing is using the package \pkg{listings}. See \texttt{codeanatomy.lstlisting.pdf}
-
+for more information.
\section{Customize style}
-TODO
+\changes{v0.4-Beta}
+ {2023/01/24}
+ {Add Option \oarg{style} to \texttt{cPart} and \texttt{iPart}}
+
+Maybe we want to highlight the function name \texttt{gcd} with some background color like
+figure~\ref{fig:function-with-highlight}. The best way to do this task is to assign this
+highlight format to a \TikZ{} style --e.g. \texttt{jsid}-- and apply the style to the highlighted nodes. So they
+have the same format.
+
+
+% output the anatomy
+\begin{figure}[htpb]
+\centering
+\begin{tikzpicture}[remember picture]
+\tikzstyle{jsid} = [code part, fill=red!10]
+%{[on background layer]\draw[code grid debug](-0.5,-0.5) grid (9.5,4.5);}
+\codeBlock{
+\cPart{functionHead}{function \cPart[jsid]{functionName}{gcd} \cPart{parameterList}{(p, q)}}\{ \\[2.5pt] %
+\ptab{}\mtPoint{mostLeft} if (q === 0) \{\\
+\ptab\ptab{} return p; \\
+\ptab{}\} else \{\\
+\ptab\ptab{} return \cPart[jsid]{recursive}{gcd}(q, p \% q);\extremPoint{mostRight}\\
+\ptab{}\}\mbPoint{mostBottom}\\
+\}
+}
+
+\fitExtrem{functionBody}{ (mostLeft) (mostRight) (mostBottom) };
+
+% Anotation labels
+\codeAnnotation{functionHeadText}(-1,3) {Function\\Head}
+\codeAnnotation{functionBodyText}(-1,1.5){Function\\Body}
+\codeAnnotation{functionNameText} (1,4) {Function Name}
+\codeAnnotation{parameterListText}(4,4) {Paramter List}
+
+\codeAnnotation{recursiveText} (7.5,2) {Function can\\call itselft.}
+
+% Annotation labels to Code
+\draw[->, annotation] (functionBodyText) -- (functionBody);
+\draw[->, annotation] (functionHeadText) -- (functionHead);
+\draw[->, annotation] (functionNameText) -- (functionName);
+\draw[->, annotation] (parameterListText) -- (parameterList);
+
+\draw[->, annotation] (recursiveText) to[out=175,in=-15] (functionName);
+\draw[->, annotation] (recursiveText) to[out=180,in=45] (recursive.north east);
+
+\end{tikzpicture}
+\caption{Highlighted name of the function\label{fig:function-with-highlight}}
+\end{figure}
+
+
+%out the Source code
+
+\begin{thinmargin}
+{\footnotesize
+\begin{tikzpicture}[remember picture]
+\tikzstyle{smark} = [code part, fill=yellow]
+\codeBlock{
+\textbackslash{}begin\{tikzpicture\}[remember picture]\\
+\slsh{}tikzstyle\{\cPart[smark]{defstyle}{jsid}\} = [code part, fill=red!10]\\
+\slsh{}codeBlock\{\\
+\slsh{}cPart\{functionHead\} \{function \slsh{}cPart[\cPart[smark]{u1}{jsid}]\{functionName\}\{gcd\} \slsh{}cPart\{parameterList\}\{(p, q)\}\} \slsh\{ \slsh\slsh[2.5pt]\\
+\slsh{}ptab\{\}\slsh{}mtPoint\{mostLeft\} if (q === 0) \slsh\{ \slsh\slsh\\
+\slsh{}ptab\slsh{}ptab\{\} return p; \slsh\slsh\\
+\slsh{}ptab\{\}\slsh \} else \slsh\{ \slsh\slsh\\
+\slsh{}ptab\slsh{}ptab\{\} return \slsh{}cPart[\cPart[smark]{u2}{jsid}]\{recursive\}\{gcd\}(q, p\slsh\%q); \slsh{}extremPoint\{mostRight\}\slsh\slsh\\
+\slsh{}ptab\{\}\slsh{}mbPoint\{mostBottom\}\slsh\} \slsh\slsh\\
+\slsh\} \\
+\} \\
+ \\
+\slsh{}fitExtrem\{functionBody\}\{(mostLeft) (mostRight) (mostBottom)\}\\
+\\
+\% Annotations \\
+\slsh{}codeAnnotation\{functionHeadText\} (-1,3) \{Function\slsh\slsh{}Head\} \\
+\slsh{}codeAnnotation\{functionBodyText\} (-1,1.5) \{Function\slsh\slsh{}Body\} \\
+\slsh{}codeAnnotation\{functionNameText\} ( 1,4) \{Function Name\} \\
+\slsh{}codeAnnotation\{parameterListText\}( 4,4) \{Parameter List\} \\
+\\
+\% Annotation labels to code parts\\
+\slsh{}draw[->,annotation] (functionBodyText) -- (functionBody);\\
+\slsh{}draw[->,annotation] (functionHeadText) -- (functionHead);\\
+\slsh{}draw[->,annotation] (functionNameText) -- (functionName);\\
+\slsh{}draw[->,annotation] (parameterListText) -- (paramList);\\
+\\
+\slsh{}draw[->, annotation] (recursiveText) to[out=175,in=-15] (functionName);\\
+\slsh{}draw[->, annotation] (recursiveText) to[out=180,in=45] (recursive.north east);\\
+\slsh{}end\{tikzpicture\}
+}
+\end{tikzpicture}
+}
+\end{thinmargin}
+
+\PrintChanges
\end{documentation}
\end{document}
diff --git a/Master/texmf-dist/doc/latex/codeanatomy/release-note-v0.4-Alpha.txt b/Master/texmf-dist/doc/latex/codeanatomy/release-note-v0.4-Alpha.txt
new file mode 100644
index 00000000000..709bc257d51
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/codeanatomy/release-note-v0.4-Alpha.txt
@@ -0,0 +1 @@
+Fix bug about fill color in arrow if its start point is placed in an anotation text
diff --git a/Master/texmf-dist/source/latex/codeanatomy/codeanatomy.dtx b/Master/texmf-dist/source/latex/codeanatomy/codeanatomy.dtx
index 4651dadeaaf..8e4361b8970 100644
--- a/Master/texmf-dist/source/latex/codeanatomy/codeanatomy.dtx
+++ b/Master/texmf-dist/source/latex/codeanatomy/codeanatomy.dtx
@@ -23,7 +23,7 @@
%
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[2018/12/01]
-%<package>\ProvidesPackage{codeanatomy}[2019/07/12 v0.4-Alpha draw Code Anatomy]
+%<package>\ProvidesPackage{codeanatomy}[2023/01/24 v0.4-Beta draw Code Anatomy]
% \fi
%
% \iffalse
@@ -169,7 +169,7 @@
%
%
% \DescribeMacro{code part}
-% \TikZ{} style to marce a piece of code in an anatomy: \\
+% \TikZ{} style to mark a piece of code in an anatomy: \\
% |\tikz{\node(code) [code part] at (0,0) {let a = 12;};}|\\
% yields \tikz{\node(code) [code part] at (0,0) {let a = 12;};}
% \begin{macrocode}
@@ -186,6 +186,26 @@
% \end{macrocode}
%
%
+% \DescribeMacro{ignored code part}
+% \TikZ{} style to make a pice of code in an anatomy as not important in currently talking context
+% |\tikz{\node(ignore code) [ignored code part] at (0,0) {/*some comment*/} }|
+% yields \tikz{\node(ignore code) [ignored code part] at (0,0) {/*some comment*/} }
+%
+% \changes{v0.4-Beta}
+% {2023/01/24}
+% {Add new \TikZ{} Style \texttt{ignored code part}}%
+%
+% \begin{macrocode}
+\tikzset{ignored code part/.style={%
+ code part,%
+ draw=none,color=bgcmdcolor,%
+ inner sep=0.75pt
+ }
+}
+% \end{macrocode}
+%
+%
+%
%
% \DescribeMacro{fit extrem}
% \TikZ{} style to mark a piece of multiple line code in an anatomy:\\
@@ -278,22 +298,29 @@
% This command can be used if there are no other packages to typeset code listing in use.
% \begin{macrocode}
\NewDocumentCommand{\codeBlock}{m}%
- {\node(code) [anatomy] at (0,0) {#1};}
+ {\node(code) [anatomy] at (0,0) {#1};}%
% \end{macrocode}
%
%
%
-% \DescribeMacro{\cPart} \marg{node name}\marg{piece of code}
+% \DescribeMacro{\cPart} \oarg{style} \marg{node name}\marg{piece of code}
%
% Assign a piece of typeset code --typical in one line-- to a \TikZ{} Node, so that it can
% be annotated.
% \begin{itemize}
+% \item \oarg{style} a defined \TikZ{} style to be applied to this node, the style |code part|
+% is applied to the node per default.
% \item \marg{node name} is a unique \TikZ{} node name in the |tikzpicture|
% \item \marg{piece of code} is a single code part to be marked.
% \end{itemize}
+%
+% \changes{v0.4-Beta}
+% {2023/01/24}
+% {Add option \oarg{style} to \texttt{cPart}}%
+%
% \begin{macrocode}
-\NewDocumentCommand{\cPart}{mm} %
- {\tikzmarknode[code part]{#1}{#2}}
+\NewDocumentCommand\cPart{O{code part}mm}
+ {\tikzmarknode[#1]{#2}{#3}}
% \end{macrocode}
%
%
@@ -303,12 +330,19 @@
% Assign a piece of typeset code --typical in one line-- to a \TikZ{} Node, so that it can
% be annotated. It does not plot border around the pice of code as |\cPart| does.
% \begin{itemize}
+% \item \oarg{style} a defined \TikZ{} style to be applied to this node, the style |ignored code part|
+% is applied to the node per default.
% \item \marg{node name} is a unique \TikZ{} node name in the |tikzpicture|
% \item \marg{piece of code} is a single code part to be marked.
% \end{itemize}
+%
+% \changes{v0.4-Beta}
+% {2023/01/24}
+% {Add option \oarg{style} to \texttt{iPart}}
+%
% \begin{macrocode}
-\NewDocumentCommand{\iPart}{mm} %
- {\tikzmarknode[code part,draw=none,inner sep=0.75pt]{#1}{#2}}
+\NewDocumentCommand{\iPart}{O{ignored code part}mm} %
+ {\tikzmarknode[#1]{#2}{#3}}
% \end{macrocode}
%
%
diff --git a/Master/texmf-dist/tex/latex/codeanatomy/codeanatomy.sty b/Master/texmf-dist/tex/latex/codeanatomy/codeanatomy.sty
index 8c4903fc38e..9d950f7621e 100644
--- a/Master/texmf-dist/tex/latex/codeanatomy/codeanatomy.sty
+++ b/Master/texmf-dist/tex/latex/codeanatomy/codeanatomy.sty
@@ -7,7 +7,7 @@
%% codeanatomy.dtx (with options: `package')
%%
\NeedsTeXFormat{LaTeX2e}[2018/12/01]
-\ProvidesPackage{codeanatomy}[2019/07/12 v0.4-Alpha draw Code Anatomy]
+\ProvidesPackage{codeanatomy}[2023/01/24 v0.4-Beta draw Code Anatomy]
\RequirePackage{expl3}
\RequirePackage{xparse}
@@ -45,6 +45,12 @@
font=\ttfamily
}
}
+\tikzset{ignored code part/.style={%
+ code part,%
+ draw=none,color=bgcmdcolor,%
+ inner sep=0.75pt
+ }
+}
\tikzset{fit extrem/.style={%
rectangle,%
draw=annotationcolor,%
@@ -86,11 +92,11 @@
}
}
\NewDocumentCommand{\codeBlock}{m}%
- {\node(code) [anatomy] at (0,0) {#1};}
-\NewDocumentCommand{\cPart}{mm} %
- {\tikzmarknode[code part]{#1}{#2}}
-\NewDocumentCommand{\iPart}{mm} %
- {\tikzmarknode[code part,draw=none,inner sep=0.75pt]{#1}{#2}}
+ {\node(code) [anatomy] at (0,0) {#1};}%
+\NewDocumentCommand\cPart{O{code part}mm}
+ {\tikzmarknode[#1]{#2}{#3}}
+\NewDocumentCommand{\iPart}{O{ignored code part}mm} %
+ {\tikzmarknode[#1]{#2}{#3}}
\NewDocumentCommand{\mtPoint}{m}
{\tikzmarknode{#1}{\phantom{\rule[1.8ex]{0.1ex}{0.1ex}}}}
\NewDocumentCommand{\hmtPoint}{m}