diff options
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/codedescribe/codedescribe.sty | 845 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/codedescribe/codelisting.sty | 50 |
2 files changed, 508 insertions, 387 deletions
diff --git a/Master/texmf-dist/tex/latex/codedescribe/codedescribe.sty b/Master/texmf-dist/tex/latex/codedescribe/codedescribe.sty index 370f01ba82c..a260c0d4220 100644 --- a/Master/texmf-dist/tex/latex/codedescribe/codedescribe.sty +++ b/Master/texmf-dist/tex/latex/codedescribe/codedescribe.sty @@ -12,7 +12,7 @@ %% %% The Current Maintainer of this work is Alceu Frigeri %% -%% This is version 1.0.1beta (2023/05/11) +%% This is version 1.1 (2023/05/16) %% %% The list of files that compose this work can be found in the README.md file at %% https://ctan.org/pkg/codedescribe @@ -22,33 +22,37 @@ \RequirePackage{ expl3 } \ProvidesExplPackage {codedescribe} - {2023/05/11} - {1.0} + {2023/05/16} + {1.1} {LaTeX Code Description/Documentation} -\prop_if_exist:NTF \g__codedesc_pkg_prop - {} - { \prop_new:N \g__codedesc_pkg_prop } - -\prop_put_from_keyval:Nn \g__codedesc_pkg_prop +%%%%%%% +%%% +%%% Just an attempt of having my packages info in a regular way +%%% Idea being: { <pck-name> / pkg info } for each and all. +%%% +%%%%%%% +\keys_define:nn { codedescribe / pkg info} { - codedesc . name = codedescribe , - codedesc . prefix = codedesc , - codedesc . date = 2023/05/11 , - codedesc . version = 1.0 , - codedesc . description = LaTeX Code Description/Documentation + name .code:n = codedescribe , + prefix .code:n = codedesc , + date .code:n = 2023/05/16 , + version .code:n = 1.1 , + description .code:n = \LaTeX~Code~Description/Documentation } - -\cs_gset:Npn \__codedesc_pkg_info:nn #1#2 +\cs_if_exist:NF \__codedesc_pkg_info:nn { - \prop_item:Nn \g__codedesc_pkg_prop {#1.#2} + \cs_new_protected:Npn \__codedesc_pkg_info:nn #1#2 + { \keys_set:nn {#1 / pkg info}{#2} } } +\cs_if_exist:NF \PkgInfo + { \NewDocumentCommand \PkgInfo {mm} { \keys_set:nn {#1 / pkg info}{#2} } } +%%%%%%% +%%% End of cut-n-paste +%%%%%%% + + -\cs_if_exist:NTF \PkgInfo - {} - { - \NewDocumentCommand \PkgInfo {mm} { \prop_item:Nn \g__codedesc_pkg_prop {#1.#2} } - } \use:c {@reversemargintrue} @@ -58,20 +62,55 @@ \keys_define:nn { codedescribe } { - nolisting.usage:n = general, + nolisting.usage:n = load, nolisting.bool_set_inverse:N = \l__codedesc_loadlisting_bool, nolisting.default:n = {true}, } \ProcessKeyOptions [codedescribe ] +%% bbding is need for those hollow stars... \RequirePackage{xcolor} +\RequirePackage{pifont} \bool_if:nT {\l__codedesc_loadlisting_bool} { \RequirePackage{codelisting} } + \cs_generate_variant:Nn \tl_set:Nn {Ne} +\cs_generate_variant:Nn \keys_set:nn {ne} +\cs_generate_variant:Nn \keys_define:nn {ne} +\cs_generate_variant:Nn \tl_to_str:n {o , e} + + +\msg_new:nnnn {codedesc} {format-err} + { + (ID:#1)~Format~Key~(#2)~not~defined! + } + { + You~tried~to~use~a~non~defined~format~key:#2. + ~Error~Code~ ID:<#1>. + } + +\msg_new:nnnn {codedesc} {group-err} + { + (ID:#1)~Format~group~(#2)~not~defined! + } + { + You~tried~to~use~a~non~defined~format~group:#2. + ~Error~Code~ ID:<#1>. + } + +\msg_new:nnnn {codedesc} {object-err} + { + (ID:#1)~Objetc~Type~(#2)~not~defined! + } + { + You~tried~to~use~a~non~defined~object~type:#2. + ~Error~Code~ ID:<#1>. + } + @@ -99,7 +138,7 @@ \dim_new:N \l__codedesc_linewidth_dim \dim_new:N \l__codedesc_textcolwidth_dim -\cs_new:Npn \__codedesc_set_textcolwidth: +\cs_new_protected:Npn \__codedesc_set_textcolwidth: { \dim_compare:nNnTF {\linewidth} = {\l__codedesc_linewidth_dim} {} @@ -113,246 +152,309 @@ } -\colorlet{c__codedesc_none_color}{red!70!black} -\bool_new:N \l__codedesc_descnotes_bool -\bool_new:N \l__codedesc_descdate_new_bool -\tl_new:N \l__codedesc_descdate_new_tl -\bool_new:N \l__codedesc_descdate_update_bool -\tl_new:N \l__codedesc_descdate_update_tl -\bool_new:N \l__codedesc_sidenote_bool -\tl_new:N \l__codedesc_sidenote_tl -\cs_new:Npn \__codedesc_keysmetadefaults:nn #1#2 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + +\keys_define:nn { codedesc / scratch_def } +{ + meta.usage:n = general , + meta .value_forbidden:n = true , + meta .code:n ={ \tl_set:Nn \l__codedesc_tmpfmt_tl {meta} } , + + xmeta.usage:n = general , + xmeta .value_forbidden:n = true , + xmeta .code:n ={ \tl_set:Nn \l__codedesc_tmpfmt_tl {xmeta} } , + + code.usage:n = general , + code .value_forbidden:n = true , + code .code:n ={ \tl_set:Nn \l__codedesc_tmpfmt_tl {code} } , + + verb.usage:n = general , + verb .value_forbidden:n = true , + verb .code:n ={ \tl_set:Nn \l__codedesc_tmpfmt_tl {verb} } , + + xverb.usage:n = general , + xverb .value_forbidden:n = true , + xverb .code:n ={ \tl_set:Nn \l__codedesc_tmpfmt_tl {xverb} } , + + nofmt.usage:n = general , + nofmt .value_forbidden:n = true , + nofmt .code:n = {\tl_clear:N \l__codedesc_tmpfmt_tl } , + + slshape.usage:n = general , + slshape .value_forbidden:n = true , + slshape .code:n ={ \tl_set:Nn \l__codedesc_tmpshape_tl { slshape} } , + + itshape.usage:n = general , + itshape .value_forbidden:n = true , + itshape .code:n ={ \tl_set:Nn \l__codedesc_tmpshape_tl { itshape} } , + + noshape.usage:n = general , + noshape .value_forbidden:n = true , + noshape .code:n ={ \tl_clear:N \l__codedesc_tmpshape_tl } , + + color.usage:n = general , + color .value_required:n = true , + color.code:n = { \tl_set:Nn \l__codedesc_tmpcolor_tl { #1 } } , + + lbracket .usage:n = general , + lbracket .value_required:n = true , + lbracket .code:n = { \tl_set:Nn \l__codedesc_tmplbracket_tl { #1 } } , + + rbracket .usage:n = general , + rbracket .value_required:n = true , + rbracket .code:n = { \tl_set:Nn \l__codedesc_tmprbracket_tl { #1 } } , + + unknown.code:n = + { + \msg_error:nnxx { codedesc } {format-err} {format}{\l_keys_key_str} + }, + +} + + +\keys_define:nn { codedesc / grp_scratch } { - \tl_if_blank:nTF {#2} - { \keys_set:nn {codedesc / defaults} { #1 } } - { \keys_set:nn {codedesc / defaults} { #1 = {#2} } } + unknown .code:n = {} } -\keys_define:nn { codedesc / defaults } -{ - meta.usage:n = general, - meta.code:n = { \colorlet{c__codedesc_marg_color}{#1} } , - meta.default:n = { gray!60!black } , - % - marg.usage:n = general, - marg.code:n = { \__codedesc_keysmetadefaults:nn {meta}{#1} } , - % - arg.usage:n = general, - arg.code:n = { \__codedesc_keysmetadefaults:nn {meta}{#1} } , - % +\cs_new_protected:Npn \__codedesc_group_define:nn #1#2 + { + \tl_clear:N \l__codedesc_tmpfmt_tl + \tl_clear:N \l__codedesc_tmpshape_tl + \tl_clear:N \l__codedesc_tmpcolor_tl + \tl_clear:N \l__codedesc_tmplbracket_tl + \tl_clear:N \l__codedesc_tmprbracket_tl + + \keys_set:nn { codedesc / grp_scratch } {#1} + \keys_set:nn { codedesc / scratch_def } {#2} + + \tl_clear:N \l_tmpa_tl + \tl_clear:N \l_tmpb_tl + \tl_if_empty:NF \l__codedesc_tmpfmt_tl + { + \tl_put_right:No \l_tmpa_tl{\l__codedesc_tmpfmt_tl} + \tl_set:Nn \l_tmpb_tl { , } + } + \tl_if_empty:NF \l__codedesc_tmpshape_tl + { + \tl_put_right:No \l_tmpa_tl{ \l_tmpb_tl } + \tl_put_right:No \l_tmpa_tl{\l__codedesc_tmpshape_tl} + \tl_set:Nn \l_tmpb_tl { , } + } + \tl_if_empty:NF \l__codedesc_tmpcolor_tl + { + \tl_put_right:No \l_tmpa_tl{ \l_tmpb_tl } + \tl_put_right:Nn \l_tmpa_tl{ color = } + \tl_put_right:No \l_tmpa_tl{ \l__codedesc_tmpcolor_tl} + \tl_set:Nn \l_tmpb_tl { , } + } + \tl_if_empty:NF \l__codedesc_tmplbracket_tl + { + \tl_put_right:No \l_tmpa_tl{ \l_tmpb_tl } + \tl_put_right:Nn \l_tmpa_tl{ lbracket = } + \tl_put_right:No \l_tmpa_tl{ \l__codedesc_tmplbracket_tl} + \tl_set:Nn \l_tmpb_tl { , } + } + \tl_if_empty:NF \l__codedesc_tmprbracket_tl + { + \tl_put_right:No \l_tmpa_tl{ \l_tmpb_tl } + \tl_put_right:Nn \l_tmpa_tl{ rbracket = } + \tl_put_right:No \l_tmpa_tl{ \l__codedesc_tmprbracket_tl} +% \tl_set:Nn \l_tmpb_tl { , } + } + + \keys_define:ne { codedesc / grp_scratch } { #1 .meta:nn = { codedesc / scratch_def } { \l_tmpa_tl} } + \keys_define:ne { codedesc / grp_fmt } { #1 .meta:nn = { codedesc / base_fmt } { \l_tmpa_tl} } + } - oarg.usage:n = general, - oarg.code:n = { \colorlet{c__codedesc_oarg_color}{#1} } , - oarg.default:n = { gray!90!black } , - % - parg.usage:n = general, - parg.code:n = { \__codedesc_keysmetadefaults:nn {oarg}{#1} } , - % - xarg.usage:n = general, - xarg.code:n = { \__codedesc_keysmetadefaults:nn {oarg}{#1} } , - % - code.usage:n = general, - code.code:n = { \colorlet{c__codedesc_code_color}{#1} } , - code.default:n = { blue!40!black } , - % - macro.usage:n = general, - macro.code:n = { \__codedesc_keysmetadefaults:nn {code}{#1} } , - % - function.usage:n = general, - function.code:n = { \__codedesc_keysmetadefaults:nn {code}{#1} } , - % - syntax.usage:n = general, - syntax.code:n = { \colorlet{c__codedesc_syntax_color}{#1} } , - syntax.default:n = { blue!60!black } , - % - keyval.usage:n = general, - keyval.code:n = { \colorlet{c__codedesc_keyval_color}{#1} } , - keyval.default:n = { teal!40!black } , - % - key.usage:n = general, - key.code:n = { \__codedesc_keysmetadefaults:nn {keyval}{#1} } , - % - keys.usage:n = general, - keys.code:n = { \__codedesc_keysmetadefaults:nn {keyval}{#1} } , - % - value.usage:n = general, - value.code:n = { \__codedesc_keysmetadefaults:nn {keyval}{#1} } , - % +\keys_define:nn { codedesc / grp_fmt } + { + unknown .code:n = \msg_error:nnxx { codedesc } {group-err} {grpfmt}{\l_keys_key_str} + } - option.usage:n = general, - option.code:n = { \colorlet{c__codedesc_options_color}{#1} } , - option.default:n = { green!30!black } , - % - defaultval.usage:n = general, - defaultval.code:n = { \colorlet{c__codedesc_defaultval_color}{#1} } , - defaultval.default:n = { blue!60!black } , - % +\cs_new_protected:Npn \__codedesc_object_define:nnn #1#2#3 + { + \tl_if_blank:nTF {#3} + { + \keys_define:nn { codedesc / format } + { #1 .meta:nn = { codedesc / grp_fmt } { #2 } } + } + { + \__codedesc_group_define:nn { #1_objfmt } {#3} + \keys_define:nn { codedesc / format } + { #1 .meta:nn = { codedesc / grp_fmt } { #2 , #1_objfmt} } + } + } - env.usage:n = general, - env.code:n = { \colorlet{c__codedesc_env_color}{#1} } , - env.default:n = { green!30!black } , - % - pkg.usage:n = general, - pkg.code:n = { \colorlet{c__codedesc_pkg_color}{#1} } , - pkg.default:n = { green!30!black } , - % - pack.usage:n = general, - pack.code:n = { \__codedesc_keysmetadefaults:nn {pkg}{#1} } , - % - - allcolors.usage:n = general, - allcolors.meta:n = - { - meta = {#1} , - oarg = {#1} , - code = {#1} , - syntax = {#1} , - keyval = {#1} , - option = {#1} , - defaultval = {#1} , - env = {#1} , - pkg = {#1} , - } , - allcolors.default:n = { black } , - - font.usage:n = general , - font.code:n = { \tl_set:Nn \__codedesc_metafont_tl: {#1} } , - font.default:n = { \ttfamily } , - - fontsize.usage:n = general , - fontsize.code:n = { \tl_set:Nn \__codedesc_metasize_tl: {#1} } , - fontsize.default:n = { \small } , +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - fontshape.usage:n = general , - fontshape.code:n = { \tl_set:Nn \__codedesc_slshape_tl: {#1} } , - fontshape.default:n = { \slshape } , + - setdefaults.usage:n = general , - setdefaults.meta:n = { meta, oarg, code, syntax, keyval, option, defaultval, env, pkg , font, fontsize, fontshape} , +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - unknown.usage:n = general, - unknown.code:n = - { }, % unknown keys are silently ignored... -} +\tl_set:Nn \__codedesc_metasize_tl: {\small} +\tl_set:Nn \__codedesc_metafont_tl: {\ttfamily} -\keys_set:nn {codedesc / defaults}{setdefaults} -\NewDocumentCommand \setcodefmt {m} { \keys_set:nn {codedesc / defaults}{#1}} + \colorlet{c__codedesc_none_color}{red!70!black} -\keys_define:nn { codedesc / format } -{ - meta.usage:n = general, - meta.code:n = - { - \tl_set:Nn \__codedesc_metacolor_tl: { \color{c__codedesc_marg_color} } - \tl_set:Nn \__codedesc_typeset_tl:n { \__codedesc_meta:n } - \tl_set:Nn \__codedesc_typeset_tl:o { \__codedesc_meta:o } - }, - marg.usage:n = general, - marg.meta:n = { meta } , - % - % - arg.usage:n = general, - arg.meta:n = { meta } , - % + \colorlet{c__codedesc_verb_color}{ black } +\__codedesc_group_define:nn {verb} {color=c__codedesc_verb_color} +\__codedesc_object_define:nnn {verb}{verb}{verb} +\__codedesc_object_define:nnn {xverb}{verb}{xverb} - oarg.usage:n = general, - oarg.code:n = - { - \tl_set:Nn \__codedesc_metacolor_tl: { \color{c__codedesc_oarg_color} } - \tl_set:Nn \__codedesc_typeset_tl:n { \__codedesc_meta:n } - \tl_set:Nn \__codedesc_typeset_tl:o { \__codedesc_meta:o } - }, - % - parg.usage:n = general, - parg.meta:n = { oarg } , - % - xarg.usage:n = general, - xarg.meta:n = { oarg } , - % + \colorlet{c__codedesc_marg_color}{ gray!60!black } +\__codedesc_group_define:nn {meta} {meta,color=c__codedesc_marg_color} +\__codedesc_object_define:nnn {meta}{meta}{} +\__codedesc_object_define:nnn {arg}{meta}{} +\__codedesc_object_define:nnn {marg}{meta}{lbracket={\{},rbracket={\}}} - code.usage:n = general, - code.code:n = - { - \tl_set:Nn \__codedesc_metacolor_tl: { \color{c__codedesc_code_color} } - \tl_set:Nn \__codedesc_typeset_tl:n { \__codedesc_macro_typeset:n } - \tl_set:Nn \__codedesc_typeset_tl:o { \__codedesc_macro_typeset:o } - }, - % - macro.usage:n = general, - macro.meta:n = { code } , - % - function.usage:n = general, - function.meta:n = { code } , - % + \colorlet{c__codedesc_oarg_color}{ gray!90!black } +\__codedesc_group_define:nn {oarg} {meta,color=c__codedesc_oarg_color} +\__codedesc_object_define:nnn {oarg}{oarg}{lbracket={[},rbracket={]}} +\__codedesc_object_define:nnn {parg}{oarg}{lbracket={(},rbracket={)}} +\__codedesc_object_define:nnn {xarg}{oarg}{lbracket={<},rbracket={>}} - syntax.usage:n = general, - syntax.code:n = - { - \tl_set:Nn \__codedesc_metacolor_tl: { \color{c__codedesc_syntax_color} } - }, - % + \colorlet{c__codedesc_code_color}{ blue!40!black } +\__codedesc_group_define:nn {code} {code,color=c__codedesc_code_color} +\__codedesc_object_define:nnn {code}{code}{} +\__codedesc_object_define:nnn {macro}{code}{} +\__codedesc_object_define:nnn {function}{code}{} +%\__codedesc_group_define:nn {code} {xverb,color=red} - keyval.usage:n = general, - keyval.code:n = - { - \tl_set:Nn \__codedesc_metacolor_tl: { \color{c__codedesc_keyval_color} } - \tl_set:Nn \__codedesc_metashape_tl: { \__codedesc_slshape_tl: } - }, - % - key.usage:n = general, - key.meta:n = { keyval } , - % - keys.usage:n = general, - keys.meta:n = { keyval } , - % - value.usage:n = general, - value.meta:n = { keyval } , - % + \colorlet{c__codedesc_syntax_color}{ blue!60!black } +\__codedesc_group_define:nn {syntax} {color=c__codedesc_syntax_color} +\__codedesc_object_define:nnn {syntax}{syntax}{} - option.usage:n = general, - option.code:n = - { - \tl_set:Nn \__codedesc_metacolor_tl: { \color{c__codedesc_options_color} } - }, - % + \colorlet{c__codedesc_keyval_color}{ teal!40!black } +\__codedesc_group_define:nn {keyval} {slshape,color=c__codedesc_keyval_color} +\__codedesc_object_define:nnn {keyval}{keyval}{} +\__codedesc_object_define:nnn {key}{keyval}{} +\__codedesc_object_define:nnn {keys}{keyval}{} +\__codedesc_object_define:nnn {value}{keyval}{} - defaultval.usage:n = general, - defaultval.code:n = - { - \tl_set:Nn \__codedesc_metacolor_tl: { \color{c__codedesc_defaultval_color} } - }, - % + \colorlet{c__codedesc_options_color}{ green!30!black } +\__codedesc_group_define:nn {option} {color=c__codedesc_options_color} +\__codedesc_object_define:nnn {option}{option}{} + + \colorlet{c__codedesc_defaultval_color}{ blue!60!black } +\__codedesc_group_define:nn {defaultval} {color=c__codedesc_defaultval_color} +\__codedesc_object_define:nnn {defaultval}{defaultval}{} - env.usage:n = general, - env.code:n = + \colorlet{c__codedesc_env_color}{ green!30!black } +\__codedesc_group_define:nn {env} {slshape,color=c__codedesc_env_color} +\__codedesc_object_define:nnn {env}{env}{} + + \colorlet{c__codedesc_pkg_color}{ green!30!black } +\__codedesc_group_define:nn {pkg} {slshape,color=c__codedesc_pkg_color} +\__codedesc_object_define:nnn {pkg}{pkg}{} +\__codedesc_object_define:nnn {pack}{pkg}{} + + + + +\keys_define:nn { codedesc / base_fmt } +{ + meta .usage:n = general , + meta .value_forbidden:n = true , + meta .code:n = { + \tl_set:Nn \__codedesc_typeset_tl:n { \__codedesc_meta:n } + \tl_set:Nn \__codedesc_typeset_tl:o { \__codedesc_meta:o } + } , + + xmeta .usage:n = general , + xmeta .value_forbidden:n = true , + xmeta .code:n = { + \tl_set:Nn \__codedesc_typeset_tl:n { \__codedesc_meta*:n } + \tl_set:Nn \__codedesc_typeset_tl:o { \__codedesc_meta*:o } + } , + + verb .usage:n = general , + verb .value_forbidden:n = true , + verb .code:n = { + \tl_set:Nn \__codedesc_typeset_tl:n { \tl_to_str:n } + \tl_set:Nn \__codedesc_typeset_tl:o { \tl_to_str:o } + } , + + xverb .usage:n = general , + xverb .value_forbidden:n = true , + xverb .code:n = { + \tl_set:Nn \__codedesc_typeset_tl:n { \__codedesc_verb_nospc_typeset:n } + \tl_set:Nn \__codedesc_typeset_tl:o { \__codedesc_verb_nospc_typeset:o } + } , + + code .usage:n = general , + code .value_forbidden:n = true , + code .code:n = { + \tl_set:Nn \__codedesc_typeset_tl:n { \__codedesc_macro_typeset:n } + \tl_set:Nn \__codedesc_typeset_tl:o { \__codedesc_macro_typeset:o } + } , + + slshape .usage:n = general , + slshape .value_forbidden:n = true , + slshape .code:n = { + \tl_set:Nn \__codedesc_metashape_tl: { \slshape} + } , + + itshape .usage:n = general , + itshape .value_forbidden:n = true , + itshape .code:n = { + \tl_set:Nn \__codedesc_metashape_tl: { \itshape } + } , + + lbracket .usage:n = general , + lbracket .value_required:n = true , + lbracket .code:n = { \tl_set:Nn \__codedesc_Lbracket_tl { #1 } } , + + rbracket .usage:n = general , + rbracket .value_required:n = true , + rbracket .code:n = { \tl_set:Nn \__codedesc_Rbracket_tl { #1 } } , + + color .usage:n = general , + color .value_required:n = true , + color .code:n = { + \tl_set:Nn \__codedesc_metacolor_tl: { \color{#1} } + } , +} + +\keys_define:nn { codedesc / format } +{ + EXP.usage:n = general, + EXP.code:n = { - \tl_set:Nn \__codedesc_metacolor_tl: { \color{c__codedesc_env_color} } - \tl_set:Nn \__codedesc_metashape_tl: { \__codedesc_slshape_tl: } + \tl_set:Nn \__codedesc_exp_tl { ~\hfill{\scriptsize\ding{72}} } }, % - - pkg.usage:n = general, - pkg.code:n = + rEXP.usage:n = general, + rEXP.code:n = { - \tl_set:Nn \__codedesc_metacolor_tl: { \color{c__codedesc_pkg_color} } - \tl_set:Nn \__codedesc_metashape_tl: { \__codedesc_slshape_tl: } + \tl_set:Nn \__codedesc_exp_tl { ~\hfill{\scriptsize\ding{73}} } }, % - pack.usage:n = general, - pack.meta:n = { pkg } , - % - sep.usage:n = general, - sep.code:n = + sep.code:n = { \tl_set:Nn \__codedesc_lastsep_tl { ~#1~ } }, @@ -396,19 +498,23 @@ unknown.usage:n = general, unknown.code:n = { - \tl_set:Nn \__codedesc_metacolor_tl: { \color{c__codedesc_none_color} } - }, - + \tl_set:Nn \__codedesc_metacolor_tl: { \color{c__codedesc_none_color} } + \msg_error:nnxx { codedesc } {object-err} {format}{\l_keys_key_str} + }, } -\cs_new:Npn \__codedesc_metafmt_set:n #1 +\cs_new_protected:Npn \__codedesc_metafmt_set:n #1 { \tl_set:Nn \__codedesc_rulecolor_tl: { \__codedesc_metacolor_tl: } \tl_set:Nn \__codedesc_metashape_tl: { } \tl_set:Nn \__codedesc_typeset_tl:n { } - \tl_set:Nn \__codedesc_typeset_tl:o { \relax } + \tl_set:Nn \__codedesc_typeset_tl:o { } + \tl_set:Nn \__codedesc_Lbracket_tl { } + \tl_set:Nn \__codedesc_Rbracket_tl { } \tl_set:Nn \__codedesc_sep_tl {,\ } \tl_set:Nn \__codedesc_lastsep_tl {\ and\ } + \tl_set:Nn \__codedesc_exp_tl { } + \bool_set_false:N \l__codedesc_descnotes_bool \bool_set_false:N \l__codedesc_descdate_new_bool @@ -420,29 +526,16 @@ \cs_generate_variant:Nn \__codedesc_metafmt_set:n {o} -\cs_new:Npn \__codedesc_metafmt:n #1 +\cs_new_protected:Npn \__codedesc_metafmt:n #1 { - \tl_set:Nn \__codedesc_rulecolor_tl: { \__codedesc_metacolor_tl: } - \tl_set:Nn \__codedesc_metashape_tl: { } - \tl_set:Nn \__codedesc_typeset_tl:n { } - \tl_set:Nn \__codedesc_typeset_tl:o { } - \tl_set:Nn \__codedesc_sep_tl {,\ } - \tl_set:Nn \__codedesc_lastsep_tl {\ and\ } - - \bool_set_false:N \l__codedesc_descnotes_bool - \bool_set_false:N \l__codedesc_descdate_new_bool - \bool_set_false:N \l__codedesc_descdate_update_bool - \bool_set_false:N \l__codedesc_sidenote_bool - - \keys_set:nn {codedesc / format}{#1} - %\tl_show:N \__codedesc_rulecolor_tl + \__codedesc_metafmt_set:n {#1} \__codedesc_metafmt: } \cs_generate_variant:Nn \__codedesc_metafmt:n {o} -\cs_new:Npn \__codedesc_metafmt: +\cs_new_protected:Npn \__codedesc_metafmt: { \__codedesc_metacolor_tl: \__codedesc_metasize_tl: @@ -451,57 +544,12 @@ } -\keys_define:nn { codedesc / delimiters } -{ - oarg.usage:n = general, - oarg.code:n = - { - \tl_set:Nn \__codedesc_open_delimit_tl {[} - \tl_set:Nn \__codedesc_close_delimit_tl {]} - }, - marg.usage:n = general, - marg.code:n = - { - \tl_set:Nn \__codedesc_open_delimit_tl {\{} - \tl_set:Nn \__codedesc_close_delimit_tl {\}} - }, - parg.usage:n = general, - parg.code:n = - { - \tl_set:Nn \__codedesc_open_delimit_tl {(} - \tl_set:Nn \__codedesc_close_delimit_tl {)} - }, - % - xarg.usage:n = general, - xarg.code:n = - { - \tl_set:Nn \__codedesc_open_delimit_tl {<} - \tl_set:Nn \__codedesc_close_delimit_tl {>} - }, - % - meta.usage:n = general, - meta.code:n = - { - \tl_set:Nn \__codedesc_open_delimit_tl {} - \tl_set:Nn \__codedesc_close_delimit_tl {} - }, - % - unknown.usage:n = general, - unknown.code:n = - { -% \tl_set:Nn \__codedesc_open_delimit_tl {!} -% \tl_set:Nn \__codedesc_close_delimit_tl {!} - }, - % -} - - %%%%%%% %%% %%% < meta > %%% %%%%%%% -\cs_new:Npn \__codedesc_meta:n #1 +\cs_new_protected:Npn \__codedesc_meta:n #1 { \ensuremath\langle #1 \ensuremath\rangle } @@ -513,7 +561,7 @@ %%% < meta > 'detokenized' %%% %%%%%%% -\cs_new:Npn \__codedesc_meta*:n #1 +\cs_new_protected:Npn \__codedesc_meta*:n #1 { \ensuremath\langle \tl_to_str:n {#1} \ensuremath\rangle } @@ -523,7 +571,7 @@ -\cs_new:Npn \__codedesc_macro_typeset:n #1 +\cs_new_protected:Npn \__codedesc_macro_typeset:n #1 { \tl_set:Ne \l_tmpb_tl {\tl_to_str:n{#1}} \regex_replace_all:nnN {\ }{} \l_tmpb_tl @@ -536,11 +584,18 @@ \cs_generate_variant:Nn \__codedesc_macro_typeset:n {o} +\cs_new_protected:Npn \__codedesc_verb_nospc_typeset:n #1 + { + \tl_set:Ne \l_tmpb_tl {\tl_to_str:n{#1}} + \regex_replace_all:nnN {\ }{} \l_tmpb_tl + \l_tmpb_tl + } +\cs_generate_variant:Nn \__codedesc_verb_nospc_typeset:n {o} -\cs_new:Npn \__codedesc_list_typeset:nnn #1#2#3 +\cs_new_protected:Npn \__codedesc_list_typeset:nnn #1#2#3 { \seq_set_from_clist:Nn \l_tmpa_seq {#1} \bool_set:Nn \l__codedesc_bool {\seq_if_empty_p:N \l_tmpa_seq} @@ -578,7 +633,7 @@ -\cs_new:Npn \__codedesc_args_typeset:nnnn #1#2#3#4 +\cs_new_protected:Npn \__codedesc_args_typeset:nnnn #1#2#3#4 { \seq_set_from_clist:Nn \l_tmpa_seq {#3} \group_begin: @@ -586,6 +641,13 @@ \seq_map_inline:Nn \l_tmpa_seq {~\!\!#2 \__codedesc_meta:n {##1} #4 } \group_end: } + + +%%%%%%%%%%%%%%%%%%% +%%%% +%%%% Variables used in the codedescibe environment +%%%% +%%%%%%%%%%%%%%%%%%% \bool_new:N \l__codedesc_longblock_bool @@ -596,6 +658,22 @@ \dim_new:N \l__codedesc_syntax_wd_dim \dim_new:N \l__codedesc_margin_wd_dim +\bool_new:N \l__codedesc_descnotes_bool +\bool_new:N \l__codedesc_descdate_new_bool +\tl_new:N \l__codedesc_descdate_new_tl +\bool_new:N \l__codedesc_descdate_update_bool +\tl_new:N \l__codedesc_descdate_update_tl +\bool_new:N \l__codedesc_sidenote_bool +\tl_new:N \l__codedesc_sidenote_tl + + +\coffin_new:N \__codedesc_describe_coffin +\dim_new:N \__codedesc_describelabel_wd_dim +\dim_new:N \__codedesc_describelist_wd_dim +\tl_new:N \__codedesc_join_tl: +\tl_new:N \__codedesc_ragged_tl: + +\dim_new:N \__codedesc_paradvance_dim %%%%%%%%%%%%%%%%%%% @@ -604,10 +682,26 @@ %%%% %%%%%%%%%%%%%%%%%%% - + +\NewDocumentCommand \defgroupfmt {mm} + { + \__codedesc_group_define:nn {#1} {#2} + } + +\NewDocumentCommand \defobjectfmt {mmm} + { + \__codedesc_object_define:nn {#1} {#2} {#3} + } \NewDocumentEnvironment {codedescribe}{O{code}m} { + \mode_if_horizontal:TF + { + \dim_set:Nn \__codedesc_paradvance_dim {\baselineskip} + } + { + \dim_set:Nn \__codedesc_paradvance_dim {0pt} + } \seq_set_from_clist:Nn \l_tmpa_seq {#2} \__codedesc_set_textcolwidth: \hcoffin_set:Nn \l__codedesc_margin_coffin @@ -616,21 +710,23 @@ \begin{tabular}{@{} l @{} } \__codedesc_hline:nnnn {\__codedesc_rulecolor_tl:}{0.5ex}{2}{0.25ex} - \seq_map_inline:Nn \l_tmpa_seq { \__codedesc_typeset_tl:n {##1} \\ } + \seq_map_inline:Nn \l_tmpa_seq { \__codedesc_typeset_tl:n {##1} \__codedesc_exp_tl \\ } \bool_if:nTF {\l__codedesc_descnotes_bool} { - \\[-2.5ex] - \__codedesc_hline:nnnn {\color{black}}{0.5ex}{0.25}{0.25ex} - - \bool_if:nT {\l__codedesc_descdate_new_bool} - {\scriptsize\color{black}new:~ \l__codedesc_descdate_new_tl\\} - \bool_if:nT {\l__codedesc_descdate_update_bool} - {\scriptsize\color{black}update:~ \l__codedesc_descdate_update_tl\\} - \bool_if:nT {\l__codedesc_sidenote_bool} - {\scriptsize\color{black}NB:~ \l__codedesc_sidenote_tl\\} + \\[-2.5ex] + \__codedesc_hline:nnnn {\color{black}}{0.5ex}{0.25}{0.25ex} + + \bool_if:nT {\l__codedesc_descdate_new_bool} + {\scriptsize\color{black}new:~ \l__codedesc_descdate_new_tl\\[-1ex]} + \bool_if:nT {\l__codedesc_descdate_update_bool} + {\scriptsize\color{black}update:~ \l__codedesc_descdate_update_tl\\[-1ex]} + \bool_if:nT {\l__codedesc_sidenote_bool} + {\scriptsize\color{black}NB:~ \l__codedesc_sidenote_tl\\[-1ex]} + \\[-1.5ex] + } + { + \\[-2.5ex] } - {} - \\[-2.5ex] \__codedesc_hline:nnnn {\__codedesc_rulecolor_tl:}{-0.25ex}{2}{1ex} \end{tabular} } @@ -656,17 +752,18 @@ \bool_if:NTF \l__codedesc_longblock_bool { % __describeblock starting at marginpar \coffin_join:NnnNnnnn \l__codedesc_syntax_coffin {l}{t} \l__codedesc_margin_coffin {r}{t} {-\marginparsep}{0pt} - \coffin_join:NnnNnnnn \l__codedesc_syntax_coffin {l}{b} \l__codedesc_text_coffin {l}{t} {\marginparwidth+\marginparsep}{0pt}%{-0.25\baselineskip} + \coffin_join:NnnNnnnn \l__codedesc_syntax_coffin {l}{b} \l__codedesc_text_coffin {l}{t} {\marginparwidth+\marginparsep}{\baselineskip} \par\noindent - \coffin_typeset:Nnnnn \l__codedesc_syntax_coffin {l}{t} {-\marginparwidth-\marginparsep}{0pt} + \coffin_typeset:Nnnnn \l__codedesc_syntax_coffin {l}{t} {-\marginparwidth-\marginparsep}{\__codedesc_paradvance_dim} } { % __describeblock at marginpar \coffin_attach:NnnNnnnn \l__codedesc_syntax_coffin {l}{t} \l__codedesc_margin_coffin {r}{t} {-\marginparsep}{0pt} - \coffin_join:NnnNnnnn \l__codedesc_syntax_coffin {l}{b} \l__codedesc_text_coffin {l}{t} {0pt}{0pt}%{-0.25\baselineskip} + \coffin_join:NnnNnnnn \l__codedesc_syntax_coffin {l}{b} \l__codedesc_text_coffin {l}{t} {0pt}{\baselineskip} \par\noindent - \coffin_typeset:Nnnnn \l__codedesc_syntax_coffin {l}{t} {0pt}{0pt} + \coffin_typeset:Nnnnn \l__codedesc_syntax_coffin {l}{t} {0pt}{\__codedesc_paradvance_dim} } - \\[0.25\baselineskip] + \\[0.5\baselineskip] + %\\[\__codedesc_paradvance_dim]%[-0.5\baselineskip] } @@ -691,20 +788,13 @@ \vcoffin_gset_end: } - -\coffin_new:N \__codedesc_describe_coffin -\dim_new:N \__codedesc_describelabel_wd_dim -\dim_new:N \__codedesc_describelist_wd_dim -\tl_new:N \__codedesc_join_tl: -\tl_new:N \__codedesc_ragged_tl: - \NewDocumentEnvironment{describelist}{O{20mm}m} { %\vspace*{-1.5ex} \mode_if_horizontal:TF - {\vspace*{-0.75ex}} + {\\[-0.5\baselineskip]} {} \__codedesc_set_textcolwidth: \coffin_clear:N \__codedesc_describe_coffin @@ -722,7 +812,7 @@ { %\vspace*{-1.5ex} \mode_if_horizontal:TF - {\vspace*{-1ex}} + {\\[-0.5\baselineskip]}%{\vspace*{-1ex}} {} \__codedesc_set_textcolwidth: \coffin_clear:N \__codedesc_describe_coffin @@ -737,34 +827,31 @@ } \NewDocumentCommand \describe {mm} - { - + { \hcoffin_set:Nn \l_tmpb_coffin { \__codedesc_metafmt:o { \__codedesc_listkind_tl } \__codedesc_ragged_tl: \__codedesc_typeset_tl:n {#1} - } + } + \dim_compare:nNnTF {\coffin_wd:N \l_tmpb_coffin} > {\__codedesc_describelabel_wd_dim} + { + \vcoffin_set:Nnn \l_tmpa_coffin + { \__codedesc_describelabel_wd_dim } + { ~\ ~ } + \coffin_attach:NnnNnnnn + \l_tmpa_coffin {r}{t} + \l_tmpb_coffin {r}{t} + {0pt}{0pt} - \dim_compare:nNnTF {\coffin_wd:N \l_tmpb_coffin} > {\__codedesc_describelabel_wd_dim} - { - \vcoffin_set:Nnn \l_tmpa_coffin - { \__codedesc_describelabel_wd_dim } - { ~\ ~ } - \coffin_attach:NnnNnnnn - \l_tmpa_coffin {r}{t} - \l_tmpb_coffin {r}{t} - {0pt}{0pt} - - } - { - \vcoffin_set:Nnn \l_tmpa_coffin - { \__codedesc_describelabel_wd_dim } - { - \__codedesc_metafmt:o { \__codedesc_listkind_tl } - \noindent\__codedesc_ragged_tl: \__codedesc_typeset_tl:n {#1} - } - } - + } + { + \vcoffin_set:Nnn \l_tmpa_coffin + { \__codedesc_describelabel_wd_dim } + { + \__codedesc_metafmt:o { \__codedesc_listkind_tl } + \noindent\__codedesc_ragged_tl: \__codedesc_typeset_tl:n {#1} + } + } \vcoffin_set:Nnn \l_tmpb_coffin { \__codedesc_describelist_wd_dim } { @@ -772,26 +859,21 @@ \begin{minipage}[t]{ \__codedesc_describelist_wd_dim } #2 \end{minipage} - } - - + } \__codedesc_join_tl: \l_tmpb_coffin {l}{t} \l_tmpa_coffin {r}{t} {-\marginparsep}{0pt} - \mode_if_horizontal:TF { - \\ -% \tl_set:Nn \l_tmpa_tl {~\ ~} - } - { -% \tl_set:Nn \l_tmpa_tl {~\ ~} + \\[-\baselineskip] } - \noindent%\vspace*{-1ex} + { } + + \noindent \coffin_typeset:Nnnnn \l_tmpb_coffin {l}{t} {0pt}{0pt} - \\[-0.5\baselineskip] + \\ } @@ -804,8 +886,11 @@ \NewDocumentCommand \typesetargs {O{meta}m} { - \keys_set:nn {codedesc / delimiters}{#1} - \__codedesc_args_typeset:nnnn {#1} \__codedesc_open_delimit_tl {#2} \__codedesc_close_delimit_tl +% \keys_set:nn {codedesc / delimiters}{#1} + \group_begin: + \__codedesc_metafmt:n {#1} + \__codedesc_args_typeset:nnnn {#1} {\__codedesc_Lbracket_tl} {#2} {\__codedesc_Rbracket_tl} + \group_end: } \cs_new_eq:NN \tsargs \typesetargs @@ -847,7 +932,6 @@ \NewDocumentEnvironment {tsremark} {O{Note:}} { -% \par\vspace*{0.5\baselineskip} \mode_if_horizontal:TF {\par\vspace*{0.25\baselineskip}}%\vspace*{-1.5ex}} {\vspace*{0.75\baselineskip}} @@ -861,7 +945,7 @@ { \end{minipage} \group_end: - \par + \\[0.5\baselineskip] } @@ -870,20 +954,20 @@ \keys_define:nn { codedesc / title } { title .usage:n = general , + title .value_required:n = true , title .tl_set:N = \l__codedesc_title_tl , author .usage:n = general , + author .value_required:n = true , author .tl_set:N = \l__codedesc_author_tl , date .usage:n = general , + date .value_required:n = true , date .tl_set:N = \l__codedesc_descdate_tl , - - abstract .usage:n = general , - abstract .tl_set:N = \l__codedesc_abstract_tl , } -\cs_new:Npn \__codedesc_make_title: {% +\cs_new_protected:Npn \__codedesc_make_title: {% \newpage \null \vskip 2em% @@ -904,6 +988,29 @@ } + +\NewDocumentCommand \typesetdate {} + { + \int_case:nn {\month} + { + {1}{January} + {2}{February} + {3}{March} + {4}{April} + {5}{May} + {6}{June} + {7}{July} + {8}{August} + {9}{September} + {10}{October} + {11}{November} + {12}{December} + } + \use:n {~} \int_to_arabic:n {\year} + } + +\cs_new_eq:NN \tsdate \typesetdate + %%%ARGH !!!!! %%% 'adapted' from 'abstract.cls' %%% diff --git a/Master/texmf-dist/tex/latex/codedescribe/codelisting.sty b/Master/texmf-dist/tex/latex/codedescribe/codelisting.sty index ede0132e3ea..c02633d9124 100644 --- a/Master/texmf-dist/tex/latex/codedescribe/codelisting.sty +++ b/Master/texmf-dist/tex/latex/codedescribe/codelisting.sty @@ -12,43 +12,51 @@ %% %% The Current Maintainer of this work is Alceu Frigeri %% -%% This is version 1.0 (2023/05/11) +%% This is version 1.1 (2023/05/16) %% %% The list of files that compose this work can be found in the README.md file at %% https://ctan.org/pkg/codedescribe %% %%%============================================================================== \NeedsTeXFormat{LaTeX2e}[2022/06/01] - \RequirePackage{ expl3 } \ProvidesExplPackage {codelisting} - {2023/05/11} - {1.0} + {2023/05/16} + {1.1} {LaTeX Code Listing} -\prop_if_exist:NTF \g__codedesc_pkg_prop - {} - { \prop_new:N \g__codedesc_pkg_prop } - -\prop_put_from_keyval:Nn \g__codedesc_pkg_prop +%%%%%%% +%%% +%%% Just an attempt of having my packages info in a regular way +%%% Idea being: { <pck-name> / pkg info } for each and all. +%%% +%%%%%%% +\keys_define:nn { codelisting / pkg info} { - codelist . name = codelisting , - codelist . prefix = codelist , - codelist . date = 2023/05/11 , - codelist . version = 1.0 , - codelist . description = LaTeX Code Listing + name .code:n = codelisting , + prefix .code:n = codelist , + date .code:n = 2023/05/16 , + version .code:n = 1.1 , + description .code:n = \LaTeX~Code~Listing } - -\cs_gset:Npn \__codedesc_pkg_info:nn #1#2 +\cs_if_exist:NF \__codedesc_pkg_info:nn { - \prop_item:Nn \g__codedesc_pkg_prop {#1.#2} + \cs_new_protected:Npn \__codedesc_pkg_info:nn #1#2 + { \keys_set:nn {#1 / pkg info}{#2} } } +\cs_if_exist:NF \PkgInfo + { \NewDocumentCommand \PkgInfo {mm} { \keys_set:nn {#1 / pkg info}{#2} } } +%%%%%%% +%%% End of cut-n-paste +%%%%%%% + -\RequirePackage{listings,scontents} +\RequirePackage{listings,scontents} + \dim_new:N \l__codelist_demo_parindent_dim \dim_new:N \l__codelist_org_parindent_dim @@ -277,6 +285,9 @@ } +%%%%%% +%%% This one can't be proteced +%%%%%% \cs_new:Npn \__codelist_set_options:n #1 {\keys_set:nn {CodeListingOptions}{#1}} \__codelist_set_options:n{default} @@ -461,6 +472,9 @@ \cs_undefine:c{endverbatimsc} \lstnewenvironment{verbatimsc}{\lstset{style=codestyle}}{} +%%%%%% +%%% This one can't be proteced +%%%%%% \cs_new:Npn \__codelist_set_verbsc:n #1 { \cs_undefine:c{verbatimsc} |