Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement and document pgfkeys tracing. #1286

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/generic/pgf/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Added

- `pgfkeys` tracing.

### Fixed

- Typo in animations `end on` key #1273
Expand All @@ -25,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Qrrbrbirlbel
- quark67
- Yukai Chou (muzimuzhi)
- Sašo Živanović

## [3.1.10] - 2023-01-13 Henri Menke

Expand Down
78 changes: 78 additions & 0 deletions doc/generic/pgf/pgfmanual-en-pgfkeys.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1740,3 +1740,81 @@ \subsection{Error Keys}


\input{pgfmanual-en-pgfkeysfiltered.tex}


\subsection{Tracing}

\begin{command}{\tracepgfkeys\opt{\oarg{options}}}
This command loads the tracing code and starts tracing the execution of
|pgfkeys| (if not yet active due to a previous invocation of the command),
and applies the given tracing \meta{options}. Both effects are local to the
\TeX\ group.

The \meta{options} are executed with the key path set to |/trace pgfkeys|.
They can be used to change the trace level and the output format.

The following keys select the trace level; they are listed in order of
increasing verbosity:
\begin{key}{/trace pgfkeys/silent}
This trace level produces no tracing output. Note that the tracing
routines are still executed; once tracing is loaded, key processing will be
slower even when the output is silent.
\end{key}
\begin{key}{/trace pgfkeys/stack}
This trace level shows which keys and handlers are executed, and what value
they receive. This is the initial trace level.
\end{key}
\begin{key}{/trace pgfkeys/trace}
In addition to the information shown on the previous trace level, this
trace level shows information on key path (de)construction, handlers like
|.try|, etc.
\end{key}
\begin{key}{/trace pgfkeys/verbose}
In addition to the information shown on the previous trace level, this
trace level shows the code of executed keys and handlers, and provides a
running commentary on decisions made during key processing.
\end{key}

The following keys select the output format:
\begin{key}{/trace pgfkeys/long}
In this format, the tracing info is indented according to the stack call
depth. This is the initial output format.
\end{key}
\begin{key}{/trace pgfkeys/compact}
In this format, the tracing info displays the stack call depth numerically.
Use it if the initial long format gets too deep and the lines wrap
unpleasantly.
\end{key}

\begin{codeexample}[code only]
\begingroup
% The first invocation of the macro loads the tracing code, making pgfkeys slow.
\tracepgfkeys % Implicitly selects stack and long.
% When the group closes, the non-tracing pgfkeys code is restored, making pgfkeys fast again.
\endgroup
\tracepgfkeys[verbose, compact] % Load the tracing code again, and switch to verbose and compact.
\tracepgfkeys[silent] % Switch to silent; compact remains in effect. Nothing needs to be loaded.
\end{codeexample}

Once the tracing code is loaded, keys residing in |/trace pgfkeys| may be
called from any |pgfkeys| processing command, e.g.\ |\tikzset|. When the
tracing code is not loaded, these keys are available but no-ops.

\end{command}

Furthermore, the tracing options may be changed via the following register and
commands. When the tracing code is not loaded, these are available but no-ops
as well.

\begin{command}{\tracingpgfkeys=\meta{trace level}}
Select the trace level numerically: 0 = silent, 1 = stack, 2 = trace, 3 =
verbose.
\end{command}

\begin{command}{\tracingpgfkeyslong}
Select the long output format.
\end{command}

\begin{command}{\tracingpgfkeyscompact}
Select the compact output format.
\end{command}
Loading