diff options
author | Karl Berry <karl@freefriends.org> | 2022-01-06 21:07:47 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-01-06 21:07:47 +0000 |
commit | 2847c629f1a7b0032ace17d02dea127721d967a4 (patch) | |
tree | a0e043808361f7f2f4edbc9a8be3dcad817b38df /Master/texmf-dist/doc/latex/dbshow/dbshow-doc.tex | |
parent | e7f43a7dce3e1260163ed2a5f83289a656435264 (diff) |
dbshow (6jan22)
git-svn-id: svn://tug.org/texlive/trunk@61513 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/dbshow/dbshow-doc.tex')
-rw-r--r-- | Master/texmf-dist/doc/latex/dbshow/dbshow-doc.tex | 386 |
1 files changed, 293 insertions, 93 deletions
diff --git a/Master/texmf-dist/doc/latex/dbshow/dbshow-doc.tex b/Master/texmf-dist/doc/latex/dbshow/dbshow-doc.tex index 7799f42dc62..02332a12575 100644 --- a/Master/texmf-dist/doc/latex/dbshow/dbshow-doc.tex +++ b/Master/texmf-dist/doc/latex/dbshow/dbshow-doc.tex @@ -7,6 +7,9 @@ \usepackage{geometry} \usepackage{tabularray} \usepackage{xcolor} +\usepackage{tcolorbox} +\tcbuselibrary{listings, skins, raster, breakable} +\usepackage{tabularray} \IndexPrologue { @@ -56,6 +59,10 @@ } \ExplSyntaxOn +\NewDocumentCommand { \strcs } { m } { + \texttt{\tl_to_str:n { #1 }} +} + \dim_new:N \l__my_syntax_dim \box_new:N \g__my_syntax_box \NewDocumentEnvironment { Syntax } { s } @@ -128,14 +135,11 @@ \protect\hypertarget{zh}{} }} } -\author{\textit{李昌锴} \texttt{<lichangkai225\@qq.com>}} -\date{2022年1月3日} +\author{\textit{李昌锴} \texttt{<lichangkai225@qq.com>}} +\date{2022年1月7日} \maketitle -{\small \tableofcontents -} -\newpage \begin{documentation} @@ -235,6 +239,26 @@ 为当前样式设置由 \cs{dbCombineFilters} 所定义的过滤器 \end{option} +\begin{option}{opt=raw-filter, desc={= \meta{cond combination}}} + 用已定义的条件为当前样式设置匿名过滤器。下面两个例子的作用是等同的。 +\end{option} + +\begin{verbatim} + % method 1 + \begin{dbFilters}{db} + \dbNewConditional{cond1}{int-attr}{\rval > 1} + \dbNewConditional*{cond2}{str-attr}{\d+} + \end{dbFilters} + \dbNewStyle{style}{db}{raw-filter={cond1 && cond2}} + % method 2 + \begin{dbFilters}{db} + \dbNewConditional{cond1}{int-attr}{\rval > 1} + \dbNewConditional*{cond2}{str-attr}{\d+} + \dbCombineFilters{filter}{cond1 && cond2} + \end{dbFilters} + \dbNewStyle{style}{db}{filter=filter} +\end{verbatim} + \begin{option}{ opt = sort, desc = {= \{ \meta{attr spec1}, \meta{attr spec2}, \ldots{} \}}, @@ -528,12 +552,29 @@ } \end{verbatim} -\subsection{常量} +\subsection{特殊命令} -\begin{function}{\dbDatabase, \dbFilterName, \dbFilterInfo, \dbIndex} - \cs{dbDatabase} 指代数据库名,\cs{dbFilterName} 指代过滤器名称, - \cs{dbFilterInfo} 指代过滤器额外信息,\cs{dbIndex} 指代当前索引。 -\end{function} +\pkg{dbshow} 定义了一些特殊的命令,会根据语境展开为不同的内容。 + +\DescribeMacro{\dbval}当前属性的值,只能在 \cs{dbNewConditional} 中使用 + +\DescribeMacro{\dbDatabase}数据库名称 + +\DescribeMacro{\dbFilterName}过滤器名称 + +\DescribeMacro{\dbFilterInfo}过滤器信息 + +\DescribeMacro{\dbIndex}原始数据索引,等同于 |\dbuse{id}| 但是 \cs{dbuse} 是不可展开的 + +\DescribeMacro{\dbarabic}用数字表示的查询集数据计数 + +\DescribeMacro{\dbalph}用小写字母表示的查询集数据计数 + +\DescribeMacro{\dbAlph}用小写字母表示的查询集数据计数 + +\DescribeMacro{\dbroman}用小写罗马数字表示的查询集数据计数 + +\DescribeMacro{\dbRoman}用大写罗马数字表示的查询集数据计数 \section{错题本示例} 见第 \ref{sec:example} 节。 @@ -547,8 +588,8 @@ \protect\hypertarget{en}{} }} } -\author{Li Changkai \texttt{<lichangkai225\@qq.com>}} -\date{2022/01/03} +\author{Li Changkai \texttt{<lichangkai225@qq.com>}} +\date{2022/01/07} \maketitle \section{Introduction} @@ -647,6 +688,27 @@ from a list of \meta{base styles} such as Set the \meta{filter} defined by \cs{dbCombineFilters}. \end{option} +\begin{option}{opt=raw-filter, desc={= \meta{cond combination}}} + Set anonymous with defined conditionals. Two examples below perform the same + function. +\end{option} + +\begin{verbatim} + % method 1 + \begin{dbFilters}{db} + \dbNewConditional{cond1}{int-attr}{\rval > 1} + \dbNewConditional*{cond2}{str-attr}{\d+} + \end{dbFilters} + \dbNewStyle{style}{db}{raw-filter={cond1 && cond2}} + % method 2 + \begin{dbFilters}{db} + \dbNewConditional{cond1}{int-attr}{\rval > 1} + \dbNewConditional*{cond2}{str-attr}{\d+} + \dbCombineFilters{filter}{cond1 && cond2} + \end{dbFilters} + \dbNewStyle{style}{db}{filter=filter} +\end{verbatim} + \begin{option}{ opt = sort, desc = {= \{ \meta{attr spec1}, \meta{attr spec2}, \ldots{} \}}, @@ -956,102 +1018,240 @@ code is showned below. } \end{verbatim} -\subsection{Constants} +\subsection{Special Macros} -\begin{function}{\dbDatabase, \dbFilterName, \dbFilterInfo, \dbIndex} - \cs{dbDatabase} represents for the database name, \cs{dbFilterName} represents for - the filter name, \cs{dbFilterInfo} represents for the extra info of the - filter and \cs{dbIndex} represents for the item index. -\end{function} +Some special macros are defined to expand to different contents according to context. + +\DescribeMacro{\dbval} Attribute value, only accessible in \cs{dbNewConditional}. + +\DescribeMacro{\dbDatabase} Database name. + +\DescribeMacro{\dbFilterName} Filter name. + +\DescribeMacro{\dbFilterInfo} Filter information. + +\DescribeMacro{\dbIndex} Index of original records, which is equal to |\rvuse{id}| but \cs{rvuse} is nonexpandable. + + +\DescribeMacro{\dbarabic} Show the counter of query set as digits. + +\DescribeMacro{\dbalph} Show the counter of query set as lowercase letters. + +\DescribeMacro{\dbAlph} Show the counter of query set as uppercase letters. + +\DescribeMacro{\dbroman} Show the counter of query set as roman numerals. + +\DescribeMacro{\dbRoman} Show the counter of query set as Roman numerals. \section{Example of Flaw Sweeper Template} \label{sec:example} -\begin{verbatim} - \documentclass{article} - \usepackage{dbshow} - \usepackage{hyperref} +\begin{tcblisting}{enhanced jigsaw,lower separated=false, +leftlower=0pt,rightlower=0pt, +colframe=red!50!black,colback=yellow!10!white, +listing options={style=tcblatex,texcsstyle=*\color{red!70!black}}, +listing and comment, +pdf comment,freeze pdf, +compilable listing, +breakable, +run pdflatex +} +\documentclass{article} +\usepackage{amsmath, physics} +\usepackage{geometry} +\usepackage{dbshow} +\usepackage{tikz} +\usepackage{tcolorbox} +\tcbuselibrary{skins} +\usetikzlibrary{shadings} +\usepackage[hidelinks]{hyperref} - \NewDocumentCommand { \hyperlinktarget } { m m m } {% - \hyperlink{#1}{#3}\hypertarget{#2}{} - } +\geometry{ + margin=2cm +} - \dbNewDatabase{ques}{ - question=tl, - answer=tl, - date=date, - count=int, - labels=clist - } - \dbNewReviewPoints{review}{1, 3, 7, 15, 30, 60} - - \begin{dbFilters}{ques} - % which need reviewed today? - \dbNewConditional{date}{date}{review|2021-12-25} - \dbNewConditional{easy}{labels}{easy} - \dbNewConditional{not-easy}{labels}{mid, hard} - % questions you haven't answered correctly for more than 3 times! - \dbNewConditional{bad}{count}{\dbval > 3} - \dbCombineConditionals{date}{date}[to be review today] - \dbCombineConditionals{easy}{easy}[easy questions] - \dbCombineConditionals{not-easy}{not-easy}[hard questions] - \dbCombineConditionals{bad}{bad}[bad questions] - \dbCombineConditionals{bad-easy}{bad && easy}[bad but easy questions] - \end{dbFilters} +% #1 link node #2 target node #3 text to show +\NewDocumentCommand \linktarget { m m m } {% + \hyperlink{#1}{#3}% + \raisebox{1em}{\hypertarget{#2}{}}% +} - \newcounter{ques} - - \dbNewStyle{test}{ques} { - before-code = {\setcounter{ques}{0}\section{Test}}, - item-code = { - \refstepcounter{ques} - \par\noindent\arabic{ques}. \dbuse{labels} \dbuse{date}\hfill \dbuse{count} - \par\noindent ques: \dbuse{question} - \par\noindent\hyperlinktarget - {answer_\dbIndex}{ques_\dbIndex}{go to answer} - }, - } - \dbNewStyle{check}{ques} { - before-code = {\setcounter{ques}{0}\section{Answer}}, - item-code = { - \refstepcounter{ques} - \par\noindent\arabic{ques}. \dbuse{labels} \dbuse{date}\hfill \dbuse{count} - \par\noindent ques: \dbuse{question} - \par\noindent\hyperlinktarget - {ques_\dbIndex}{answer_\dbIndex}{back to question} - \par\noindent answer: \dbuse{answer} - }, - } - \dbNewStyle[test]{test-bad}{ques}{ - filter=bad, - before-code = {\setcounter{ques}{0}\section{Bad Question}} +% question box +\tcbset{ + base/.style={ + empty, + frame engine=path, + colframe=yellow!10, + coltitle=red!70, + fonttitle=\bfseries\sffamily, + sharp corners, + left=4pt, + right=4pt, + drop fuzzy shadow, + drop fuzzy shadow, + borderline west={3pt}{-3pt}{red!80}, } +} - \AtEndDocument{ - \dbshow{test}{ques} - \dbshow{test-bad}{ques} - \dbshow{check}{ques} - } +\newtcolorbox{mybox}[1]{% + base, title = {#1} +} - \begin{document} +\dbNewReviewPoints{review}{1, 3, 7, 15, 30, 60} - \begin{dbitem}{ques}[date=2021-12-21, count=1, labels=easy] - \dbsave{question}{This is test question 1.} - \dbsave{answer}{This is test question 1.} - \end{dbitem} +\dbNewDatabase{ques-book}{ + ques = tl, + answer = tl, + count = int|1, + labels = clist, + date = date, +} - \begin{dbitem}{ques}[date=2021-12-22, count=4, labels=easy] - \dbsave{question}{This is test question 2.} - \dbsave{answer}{This is test question 2.} - \end{dbitem} +\begin{dbFilters}{ques-book} + \dbNewConditional{hard}{labels}{hard} + \dbNewConditional{bad}{count}{\dbval > 1} + \dbNewConditional{review}{date}{review|2022-01-07} +\end{dbFilters} + +% show all questions with hyperlink to answers +\dbNewStyle{ques}{ques-book}{ + before-code = {\section{Questions}}, + item-code = { + \begin{mybox}{% + \linktarget{answer_\dbIndex}{ques_\dbIndex}{% + Question \dbarabic% + \hspace{2em}\dbuse{date}% + \hspace{2em}\dbuse{labels}% + \hfill\dbuse{count}% + }% + } + \dbuse{ques}% + \end{mybox} + }, + labels/sep = /, +} - \begin{dbitem}{ques}[date=2021-12-23, count=3, labels=hard] - \dbsave{question}{This is test question 3.} - \dbsave{answer}{This is test question 3.} - \end{dbitem} +% show all questions and answers with hyperlink to questions +\dbNewStyle{answer}{ques-book}{ + before-code = {\section{Questions and Answers}}, + item-code = { + \begin{mybox}{% + \linktarget{ques_\dbIndex}{answer_\dbIndex}{% + Question \dbarabic% + \hspace{2em}\dbuse{date}% + \hspace{2em}\dbuse{labels}% + \hfill\dbuse{count}% + }% + } + \dbuse{ques}\tcbsubtitle{Answer}\dbuse{answer}% + \end{mybox} + }, + labels/sep = /, +} - \end{document} -\end{verbatim} +% show all hard questions with hyperlink to answers +\dbNewStyle{hard}{ques-book}{ + before-code = {\section{Hard Questions}}, + item-code = { + \begin{mybox}{% + \hyperlink{answer_\dbIndex}{% + Question \dbarabic% + \hspace{2em}\dbuse{date}% + \hspace{2em}\dbuse{labels}% + \hfill\dbuse{count}% + }% + } + \dbuse{ques}% + \end{mybox} + }, + raw-filter = hard, + labels/sep = /, +} + +% show all hard questions that have answered incorrectly for more than one +% time with hyperlink to answers +\dbNewStyle[hard]{bad}{ques-book}{ + before-code = {\section{Bad Questions}}, + raw-filter = {bad && hard}, +} +% show all questions that plan to be reviewed on 2022-01-07 with hyperlink to +% answers +\dbNewStyle[hard]{review}{ques-book}{ + before-code = {\section{Questions to be Reviewed}}, + raw-filter = {review}, +} + +\AtEndDocument{ + \dbshow{review}{ques-book} + \dbshow{hard}{ques-book} + \dbshow{bad}{ques-book} + \dbshow{ques}{ques-book} + \dbshow{answer}{ques-book} +} + +\begin{document} + +\begin{dbitem}{ques-book}[ + date=2022-01-01, + labels={math, equation, easy}, + count=2 + ] + \dbsave{ques}{% + Solve the linear equation: $x + 16 = 31$. + } + \dbsave{answer}{% + $x = 31 - 16 = 15$ + } +\end{dbitem} + +\begin{dbitem}{ques-book}[ + date=2022-01-01, + labels={math, equation, hard}, + count=3 + ] + \dbsave{ques}{% + Solve the linear equation: $2y = 16$. + } + \dbsave{answer}{% + $y = 16 / 2 = 8$ + } +\end{dbitem} + +\begin{dbitem}{ques-book}[ + date=2022-01-04, + labels={math, integral, hard}, + count=1 + ] + \dbsave{ques}{% + Find the indefinite integral: $\int 2x \dd x$. + } + \dbsave{answer}{% + $\int 2x \dd x = x^2$ + } +\end{dbitem} + +\end{document} +\end{tcblisting} + +\section*{Change History} +\markboth{Change History}{Change History} +\addcontentsline{toc}{section}{Change History} +\noindent +\begin{tblr}{ + colspec = {lll}, + row{1} = {font=\bfseries}, +} + Date & Ver. & Describe \\ + 2022-01-05 & 1.0 & { + First version \\ + Add macro: \cmd{\dbarabic}, \cmd{\dbalph}, \cmd{\dbAlph}, \cmd{\dbroman}, \cmd{\dbRoman} + } \\ + 2022-01-06 & & { + Fix bug: \cmd{\dbIndex} undefined \\ + Add style option: \opt{raw-filter} + } \\ + 2022-01-07 & 1.1 & Improve example \\ +\end{tblr} \end{documentation} |