% Copyright 2019 by Till Tantau and Christian Feuersänger
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.

\input{pgfmanual.prettyprinter.code.tex}
\input{pgfmanual.pdflinks.code.tex}

% TODO for auto xrefs:
% 1. check the already identified labels, preferably using
%      /pdflinks/show labels=true
% and the image externalization debug mode (see pgfmanual-en-main.tex)
% (to strip almost all images away)
%
% 2. Insert '\declareandlabel' in the document whenever something has been
% defined in the text, so it should get a pdf anchor (see
% pgfmanual.pdflinks.code.tex )
%
% 2.1 perhaps insert \pgfmanualpdflabel{<label>}{} where needed.
%
% 3. Verify that the |...| commands occurring in situations where catcodes can't
% be changed (footnotes or macro arguments) work as expected.
%
% 4. Consider telling the pretty printer that several control sequences
% have arguments which are options (see below for the predefined list).
% This may apply to \pgfpageslogicalpageoptions or so.
%
% 5. @Christian: consider extensions of the parser such that it identifies path commands (at least partially)
%
%

\def\pgfmanual@warning#1{\pgf@typeout{! Package pgfmanual Warning: #1}}%


\pgfkeys{
    % set this to 'false' to disable auto reference generation.
    % However, a little bit runtime overhead will still remain
    % (and the \pgfmanualpdflabel commands will still be used)
    /pdflinks/codeexample links=true,
    %
    /codeexample/prettyprint/cs arguments/tikzset/.initial=1,
    /codeexample/prettyprint/cs/tikzset/.code 2 args={\pgfmanualpdfref{#1}{#1}\{\pgfmanualprettyprintpgfkeys{#2}\pgfmanualclosebrace},
    /codeexample/prettyprint/cs arguments/usetikzlibrary/.initial=1,
    /codeexample/prettyprint/cs/usetikzlibrary/.code 2 args={\pgfmanualpdfref{#1}{#1}\{\pgfmanualpdfref{#2}{#2}\pgfmanualclosebrace},
    /codeexample/prettyprint/cs arguments/usepgflibrary/.initial=1,
    /codeexample/prettyprint/cs/usepgflibrary/.code 2 args={\pgfmanualpdfref{#1}{#1}\{\pgfmanualpdfref{#2}{#2}\pgfmanualclosebrace},
    %
    %
    %
    % whenever an unqualified key is found, the following key prefix
    % list is tried to find a match.
    /pdflinks/search key prefixes in={/tikz/,/pgf/},
    %
    % the link prefix written to the pdf file:
    /pdflinks/internal link prefix=pgf,
    %
    /pdflinks/warnings=false,
    % for debugging:
    /pdflinks/show labels=false,
}%
