T-F-S / tcolorbox

A LaTeX package to create highly customizable colored boxes.
http://www.ctan.org/pkg/tcolorbox
LaTeX Project Public License v1.3c
213 stars 15 forks source link

How to document class/package options using `documentation` lib? #260

Closed muzimuzhi closed 6 months ago

muzimuzhi commented 7 months ago

It seems this issue was cleverly sidestepped in tcolorbox manual, probably because each of its package options has a corresponding key /tcb/library/<pkg option> defined which can be used as \tcbuselibrary{<pkg option>, <pkg option>, ...}.

csvsimple.pdf documents its two package options alongside with the introduction to csvsimple-l3 and csvsimple-lagency packages.

I also found that the names \colOpt{<text>}, /tcb/color option=<color>, and color Option which may be considered suitable for options, are already taken by optional texts.

T-F-S commented 7 months ago

Is your own proposal https://github.com/T-F-S/tcolorbox/issues/259 a possible answer? With removing the root \, package options could be documented just like keys without path. Even your /tcb/doclang/key trick may be used to add something like package option, if that may be required.

muzimuzhi commented 7 months ago

Is your own proposal #259 a possible answer?

Sure it is. But as I said in #259, from the partial key name doclang, I felt setting dynamic values to /tcb/docloang/xxx keys is more like a misuse.

T-F-S commented 7 months ago

Sure it is. But as I said in #259, from the partial key name doclang, I felt setting dynamic values to /tcb/docloang/xxx keys is more like a misuse.

Yes, the naming is not inviting for the purpose. When I'm going to see for https://github.com/T-F-S/tcolorbox/issues/259, I try to keep that in mind and provide a solution.

muzimuzhi commented 7 months ago

Another aspect. documentation library provides two kinds of interfaces:

If the decision is to provide a short version \docOption for package options, then my proposal(s) in #259 won't help.

T-F-S commented 7 months ago

I see package options, well, as options like keys. With https://github.com/T-F-S/tcolorbox/issues/259 implemented, one can distinguish between package options and 'normal' keys, if required:

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{documentation}
\hypersetup{colorlinks}

\makeindex

%\newcommand{\myFormatDocOption}[1]{#1 (package option)}
%\newcommand{\myFormatDocOptions}[1]{#1 (package options)}

\newcommand{\myFormatDocOption}[1]{package option}
\newcommand{\myFormatDocOptions}[1]{Package options}

\tcbmakedocSubKey[
    doc key prefix=,
    index key formatter=\myFormatDocOption,
    index keys formatter=\myFormatDocOptions
]{docDocOption}{}

\begin{document}

\begin{docDocOption}{a4paper}{}{}
  content
\end{docDocOption}

\printindex
\end{document}

The commented version of \myFormatDocOption(s) contains 'key' or 'Keys' while the not commented overwrites the language settings.

grafik grafik

muzimuzhi commented 7 months ago

Just one limitation: if index colorize is set to true, then indices for options and keys will always in color /tcb/doc key. More precisely, the value of \kvtcb@col@key at the time \printindex is used.

Writing value of \kvtcb@col@key to .idx will introduce limitation on the color (expression) passed to /tcb/doc key, as characters commonly used in color expressions like ! have special meaning in \index{<index entry>}.

muzimuzhi commented 7 months ago

Typo: /tcb/doc key mentioned in my previous comment should all be /tcb/color key.

T-F-S commented 6 months ago

From my point of view, this is sufficiently solved by https://github.com/T-F-S/tcolorbox/issues/259