%D \module
%D   [       file=publ-tra,
%D        version=2013.12.24,
%D          title=\CONTEXT\ Publication Support,
%D       subtitle=Tracing,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

% todo: make this a runtime module
% todo: use the module interface

\writestatus{loading}{ConTeXt Publication Support / Tracing}

\registerctxluafile{publ-tra}{}

\unprotect

\unexpanded\gdef\showbtxdatasetfields      {\dosingleempty\publ_show_dataset_fields}
\unexpanded\gdef\showbtxdatasetcompleteness{\dosingleempty\publ_show_dataset_completeness}
\unexpanded\gdef\showbtxdatasetauthors     {\dosingleempty\publ_show_dataset_authors}
\unexpanded\gdef\showbtxhashedauthors      {\dosingleempty\publ_show_hashed_authors}
\unexpanded\gdef\showbtxfields             {\dosingleempty\publ_show_fields}
\unexpanded\gdef\showbtxtables             {\dosingleempty\publ_show_tables}

\gdef\publ_show_dataset_whatever#1[#2]%
  {\begingroup
   \letdummyparameter\c!specification\currentbtxspecification
   \setdummyparameter\c!dataset      {\currentbtxdataset}%
   \letdummyparameter\c!field        \empty
   \iffirstargument
     \doifelseassignment{#2}
       {\getdummyparameters[#2]}%
       {\setdummyparameter\c!dataset{#2}}%
   \else
     \getdummyparameters[#2]%
   \fi
   \ctxcommand{#1{
      dataset       = "\dummyparameter\c!dataset",
      specification = "\dummyparameter\c!specification",
      field         = "\dummyparameter\c!field",
   }}%
   \endgroup}

\gdef\publ_show_dataset_fields      {\publ_show_dataset_whatever{showbtxdatasetfields}}
\gdef\publ_show_dataset_completeness{\publ_show_dataset_whatever{showbtxdatasetcompleteness}}
\gdef\publ_show_dataset_authors     {\publ_show_dataset_whatever{showbtxdatasetauthors}}

\gdef\publ_show_fields[#1]%
  {\begingroup
   \setdummyparameter\c!rotation{90}%
   \doifelseassignment{#1}%
     {\letdummyparameter\c!specification\currentbtxspecification
      \getdummyparameters[#1]}%
     {\doifelsenothing{#1}%
        {\letdummyparameter\c!specification\currentbtxspecification}%
        {\setdummyparameter\c!specification{#1}}}%
   \ctxcommand{showbtxfields{
      rotation      = "\dummyparameter\c!rotation",
      specification = "\dummyparameter\c!specification"
   }}%
   \endgroup}

\gdef\publ_show_tables[#1]%
  {\begingroup
   \ctxcommand{showbtxtables{}}%
   \endgroup}

\gdef\publ_show_hashed_authors[#1]%
  {\ctxcommand{showbtxhashedauthors{}}}

\protect

\continueifinputfile{publ-tra.mkiv}

\starttext

    \showbtxfields[rotation=85] \page
    \showbtxfields[rotation=90] \page

    \showbtxtables \page

\stoptext
