From 3e5689b6ed2be14caa070207912451fadd1d3e99 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 4 Dec 2020 22:24:18 +0000 Subject: rest-api (4dec20) git-svn-id: svn://tug.org/texlive/trunk@57068 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/rest-api/README.md | 2 +- Master/texmf-dist/doc/latex/rest-api/rest-api.pdf | Bin 142219 -> 154481 bytes .../texmf-dist/source/latex/rest-api/rest-api.dtx | 210 +++++++++++++++++++-- .../texmf-dist/source/latex/rest-api/rest-api.ins | 4 +- Master/texmf-dist/tex/latex/rest-api/rest-api.sty | 138 ++++++++++++-- 5 files changed, 319 insertions(+), 35 deletions(-) diff --git a/Master/texmf-dist/doc/latex/rest-api/README.md b/Master/texmf-dist/doc/latex/rest-api/README.md index a092c4b8ddb..92a058bdd6c 100644 --- a/Master/texmf-dist/doc/latex/rest-api/README.md +++ b/Master/texmf-dist/doc/latex/rest-api/README.md @@ -3,4 +3,4 @@ LaTeX package for describing rest apis Developed by Dennis Klein -This material is subject to the LATEX Project Public License 1.3c. \ No newline at end of file +This material is subject to the LATEX Project Public License 1.3c. diff --git a/Master/texmf-dist/doc/latex/rest-api/rest-api.pdf b/Master/texmf-dist/doc/latex/rest-api/rest-api.pdf index 90ddffa7911..0d3fb391f73 100644 Binary files a/Master/texmf-dist/doc/latex/rest-api/rest-api.pdf and b/Master/texmf-dist/doc/latex/rest-api/rest-api.pdf differ diff --git a/Master/texmf-dist/source/latex/rest-api/rest-api.dtx b/Master/texmf-dist/source/latex/rest-api/rest-api.dtx index db450b183ba..955f744c7e1 100644 --- a/Master/texmf-dist/source/latex/rest-api/rest-api.dtx +++ b/Master/texmf-dist/source/latex/rest-api/rest-api.dtx @@ -22,7 +22,7 @@ %\NeedsTeXFormat{LaTeX2e}[1999/12/01] %\ProvidesPackage{rest-api} %<*package> - [2020/06/23 v1.3 rest-api package] + [2020/12/04 v1.4 rest-api package] % % %<*driver> @@ -40,7 +40,7 @@ % % \fi % -% \CheckSum{424} +% \CheckSum{514} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -59,6 +59,7 @@ % Right brace \} Tilde \~} % % +% \changes{v1.4}{2020/12/04}{Add xml syntax highlighting support for request and response body} % \changes{v1.3}{2020/06/23}{Fix typo and table coloring after apiRoute block} % \changes{v1.2}{2020/03/22}{Corrections for CTAN, rename to rest-api} % \changes{v1.1}{2020/03/21}{Add documentation and usage} @@ -270,6 +271,34 @@ % % \fi +% \paragraph{DELETE Request xml} \ +% \iffalse +%<*example> +% \fi +\begin{lstlisting}[frame=single,breaklines=true] + \begin{apiRoute}{delete}{/api/storage/\{id\}}{remove a storage with id} + \begin{routeParameter} + \routeParamItem{id}{id of storage} + \end{routeParameter} + \begin{routeResponse}{application/xml} + \begin{routeResponseItem}{200}{ok} + + \end{routeResponseItem} + \begin{routeResponseItem}{404}{error: storage not found} + \begin{routeResponseItemBody} + + storage with id '11' not found! + + \end{routeResponseItemBody} + \end{routeResponseItem} + \end{routeResponse} + \end{apiRoute} +\end{lstlisting} +% \iffalse +% +% \fi + + % % % @@ -363,7 +392,10 @@ % Return the border color of the current route. % % \DescribeMacro{\methodJson} -% Set the with \\lstset color scheme for the listings of the current route. +% Set the color scheme and language with \\lstset for the listings of the current route to json. +% +% \DescribeMacro{\methodXml} +% Set the color scheme and language with \\lstset for the listings of the current route to xml. % % @@ -504,6 +536,7 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{color definitions for json} % \begin{macrocode} \colorlet{punct}{black} \definecolor{background}{HTML}{EEEEEE} @@ -515,6 +548,11 @@ \colorlet{numbPut}{delimPut} \colorlet{delimDelete}{\getDeleteColor} \colorlet{numbDelete}{delimDelete} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{json language defintions} +% \begin{macrocode} \lstdefinelanguage{jsonGet}{ basicstyle=\small\ttfamily\color{black}, numberstyle=\small\color{black}, @@ -655,6 +693,105 @@ {[}{{{\color{delimDelete}{[}}}}{1} {]}{{{\color{delimDelete}{]}}}}{1}, } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{xml language defintions} +% \begin{macrocode} +\lstdefinelanguage{xmlGet}{ + basicstyle=\small\ttfamily\color{black}, + numberstyle=\small\color{numbGet}, + keywordstyle=\color{black}, + commentstyle=\color{black}, + stringstyle=\color{black}, + frame=L, + framesep=8pt, + framerule=2pt, + xleftmargin=50pt, + xrightmargin=0pt, + rulesep=0pt, + backgroundcolor=\color{white}, + numbersep=8pt, + tabsize=4, + showstringspaces=false, + breaklines=false, + morestring=[b]", + morestring=[s]{>}{<}, + morecomment=[s]{}, + identifierstyle=\color{numbGet}, +} +\lstdefinelanguage{xmlPost}{ + basicstyle=\small\ttfamily\color{black}, + numberstyle=\small\color{numbPost}, + keywordstyle=\color{black}, + commentstyle=\color{black}, + stringstyle=\color{black}, + frame=L, + framesep=8pt, + framerule=2pt, + xleftmargin=50pt, + xrightmargin=0pt, + rulesep=0pt, + backgroundcolor=\color{white}, + numbersep=8pt, + tabsize=4, + showstringspaces=false, + breaklines=false, + morestring=[b]", + morestring=[s]{>}{<}, + morecomment=[s]{}, + identifierstyle=\color{numbPost}, +} +\lstdefinelanguage{xmlPut}{ + basicstyle=\small\ttfamily\color{black}, + numberstyle=\small\color{numbPut}, + keywordstyle=\color{black}, + commentstyle=\color{black}, + stringstyle=\color{black}, + frame=L, + framesep=8pt, + framerule=2pt, + xleftmargin=50pt, + xrightmargin=0pt, + rulesep=0pt, + backgroundcolor=\color{white}, + numbersep=8pt, + tabsize=4, + showstringspaces=false, + breaklines=false, + morestring=[b]", + morestring=[s]{>}{<}, + morecomment=[s]{}, + stringstyle=\color{black}, + identifierstyle=\color{numbPut}, +} +\lstdefinelanguage{xmlDelete}{ + basicstyle=\small\ttfamily\color{black}, + numberstyle=\small\color{numbDelete}, + keywordstyle=\color{black}, + commentstyle=\color{black}, + stringstyle=\color{black}, + frame=L, + framesep=8pt, + framerule=2pt, + xleftmargin=50pt, + xrightmargin=0pt, + rulesep=0pt, + backgroundcolor=\color{white}, + numbersep=8pt, + tabsize=4, + showstringspaces=false, + breaklines=false, + morestring=[b]", + morestring=[s]{>}{<}, + morecomment=[s]{}, + identifierstyle=\color{numbDelete}, +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{apiRoute frame style defintion} +% \begin{macrocode} \mdfdefinestyle{mystyle}{ linecolor=\methodBorderColor, backgroundcolor=\methodLightColor, @@ -670,6 +807,15 @@ nobreak=true } % \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\bodyFormat} +% \begin{macrocode} +\newcommand{\bodyFormat}{json} +% \end{macrocode} +% \end{macro} +% % % \begin{macro}{\routeBreakValue} % \begin{macrocode} @@ -733,21 +879,21 @@ { \lstset{language=jsonGet,rulecolor=\color{\methodColor}} } -\begin{comment} - \newcommand{\apiCorner}{notround} - - \newcommand{\apiCornerRound} - { - \renewcommand{\apiCorner}{round} - } - - \newcommand{\apiCornerNotRound} - { - \renewcommand{\apiCorner}{notround} - } -\end{comment} % \end{macrocode} % +% \begin{macro}{\methodXml} +% \begin{macrocode} +\newcommand{\methodXml} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +{ + \lstset{language=xmlGet,rulecolor=\color{\methodColor}} +} +% \end{macrocode} +% +% % \begin{environment}{apiRoute} % \begin{macrocode} \newenvironment{apiRoute}[3] @@ -768,6 +914,12 @@ \colorlet{numbGet}{delimGet} \lstset{language=jsonGet,rulecolor=\color{\methodColor}} } + \renewcommand{\methodXml} + { + \colorlet{delimGet}{\methodColor} + \colorlet{numbGet}{delimGet} + \lstset{language=xmlGet,rulecolor=\color{\methodColor}} + } } {} @@ -782,6 +934,12 @@ \colorlet{numbPost}{delimPost} \lstset{language=jsonPost,rulecolor=\color{\methodColor}} } + \renewcommand{\methodXml} + { + \colorlet{delimPost}{\methodColor} + \colorlet{numbPost}{delimPost} + \lstset{language=xmlPost,rulecolor=\color{\methodColor}} + } } {} @@ -796,6 +954,12 @@ \colorlet{numbPut}{delimPut} \lstset{language=jsonPut,rulecolor=\color{\methodColor}} } + \renewcommand{\methodXml} + { + \colorlet{delimPut}{\methodColor} + \colorlet{numbPut}{delimPut} + \lstset{language=xmlPut,rulecolor=\color{\methodColor}} + } } {} \ifthenelse{\equal{\method}{delete}} @@ -809,6 +973,12 @@ \colorlet{numbDelete}{delimDelete} \lstset{language=jsonDelete,rulecolor=\color{\methodColor}} } + \renewcommand{\methodXml} + { + \colorlet{delimDelete}{\methodColor} + \colorlet{numbDelete}{delimDelete} + \lstset{language=xmlDelete,rulecolor=\color{\methodColor}} + } } {} @@ -857,6 +1027,8 @@ % \begin{macrocode} \newenvironment{routeRequest}[1] { + \renewcommand{\bodyFormat}{#1} + \arrayrulecolor{\methodColor} \begin{tabularx}{\textwidth}{X l} @@ -874,7 +1046,7 @@ } \lstnewenvironment{routeRequestBody} { - \methodJson + \IfSubStr{\bodyFormat}{xml}{\methodXml}{\methodJson} } {} % \end{macrocode} @@ -915,6 +1087,8 @@ % \begin{macrocode} \newenvironment{routeResponse}[1] { + \renewcommand{\bodyFormat}{#1} + \newcommand{\noRouteResponse}[1] { \begin{tabularx}{\textwidth}{X} @@ -954,7 +1128,7 @@ \lstnewenvironment{routeResponseItemBody} { \vspace{-1.4em} - \methodJson + \IfSubStr{\bodyFormat}{xml}{\methodXml}{\methodJson} } {} \endinput diff --git a/Master/texmf-dist/source/latex/rest-api/rest-api.ins b/Master/texmf-dist/source/latex/rest-api/rest-api.ins index eba18ecd93b..92070c15728 100644 --- a/Master/texmf-dist/source/latex/rest-api/rest-api.ins +++ b/Master/texmf-dist/source/latex/rest-api/rest-api.ins @@ -16,7 +16,7 @@ \Msg{************************************************************************} \Msg{* Installation *} -\Msg{* Package: rest-api 2020/03/22 v1.2 *} +\Msg{* Package: rest-api 2020/12/04 v1.4 *} \Msg{************************************************************************} \keepsilent @@ -58,4 +58,4 @@ version 2008/05/04 or later. \Msg{* *} \Msg{*************************************************************} -\endbatchfile \ No newline at end of file +\endbatchfile diff --git a/Master/texmf-dist/tex/latex/rest-api/rest-api.sty b/Master/texmf-dist/tex/latex/rest-api/rest-api.sty index cb8d2ed2f9f..ff4ea537229 100644 --- a/Master/texmf-dist/tex/latex/rest-api/rest-api.sty +++ b/Master/texmf-dist/tex/latex/rest-api/rest-api.sty @@ -22,7 +22,8 @@ %% \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesPackage{rest-api} - [2020/06/23 v1.3 rest-api package] + [2020/12/04 v1.4 rest-api package] + @@ -220,6 +221,95 @@ literate= {[}{{{\color{delimDelete}{[}}}}{1} {]}{{{\color{delimDelete}{]}}}}{1}, } +\lstdefinelanguage{xmlGet}{ +basicstyle=\small\ttfamily\color{black}, +numberstyle=\small\color{numbGet}, +keywordstyle=\color{black}, +commentstyle=\color{black}, +stringstyle=\color{black}, +frame=L, +framesep=8pt, +framerule=2pt, +xleftmargin=50pt, +xrightmargin=0pt, +rulesep=0pt, +backgroundcolor=\color{white}, +numbersep=8pt, +tabsize=4, +showstringspaces=false, +breaklines=false, +morestring=[b]", +morestring=[s]{>}{<}, +morecomment=[s]{}, +identifierstyle=\color{numbGet}, +} +\lstdefinelanguage{xmlPost}{ +basicstyle=\small\ttfamily\color{black}, +numberstyle=\small\color{numbPost}, +keywordstyle=\color{black}, +commentstyle=\color{black}, +stringstyle=\color{black}, +frame=L, +framesep=8pt, +framerule=2pt, +xleftmargin=50pt, +xrightmargin=0pt, +rulesep=0pt, +backgroundcolor=\color{white}, +numbersep=8pt, +tabsize=4, +showstringspaces=false, +breaklines=false, +morestring=[b]", +morestring=[s]{>}{<}, +morecomment=[s]{}, +identifierstyle=\color{numbPost}, +} +\lstdefinelanguage{xmlPut}{ +basicstyle=\small\ttfamily\color{black}, +numberstyle=\small\color{numbPut}, +keywordstyle=\color{black}, +commentstyle=\color{black}, +stringstyle=\color{black}, +frame=L, +framesep=8pt, +framerule=2pt, +xleftmargin=50pt, +xrightmargin=0pt, +rulesep=0pt, +backgroundcolor=\color{white}, +numbersep=8pt, +tabsize=4, +showstringspaces=false, +breaklines=false, +morestring=[b]", +morestring=[s]{>}{<}, +morecomment=[s]{}, +stringstyle=\color{black}, +identifierstyle=\color{numbPut}, +} +\lstdefinelanguage{xmlDelete}{ +basicstyle=\small\ttfamily\color{black}, +numberstyle=\small\color{numbDelete}, +keywordstyle=\color{black}, +commentstyle=\color{black}, +stringstyle=\color{black}, +frame=L, +framesep=8pt, +framerule=2pt, +xleftmargin=50pt, +xrightmargin=0pt, +rulesep=0pt, +backgroundcolor=\color{white}, +numbersep=8pt, +tabsize=4, +showstringspaces=false, +breaklines=false, +morestring=[b]", +morestring=[s]{>}{<}, +morecomment=[s]{}, +identifierstyle=\color{numbDelete}, +} \mdfdefinestyle{mystyle}{ linecolor=\methodBorderColor, backgroundcolor=\methodLightColor, @@ -234,6 +324,7 @@ leftmargin=0pt, rightmargin=0pt, nobreak=true } +\newcommand{\bodyFormat}{json} \newcommand{\routeBreakValue}{true} \newcommand{\noBreakRoute} { @@ -250,19 +341,10 @@ nobreak=true { \lstset{language=jsonGet,rulecolor=\color{\methodColor}} } -\begin{comment} -\newcommand{\apiCorner}{notround} - -\newcommand{\apiCornerRound} -{ -\renewcommand{\apiCorner}{round} -} - -\newcommand{\apiCornerNotRound} +\newcommand{\methodXml} { -\renewcommand{\apiCorner}{notround} +\lstset{language=xmlGet,rulecolor=\color{\methodColor}} } -\end{comment} \newenvironment{apiRoute}[3] { \global\let\saved@CT@arc@\CT@arc@ @@ -281,6 +363,12 @@ nobreak=true \colorlet{numbGet}{delimGet} \lstset{language=jsonGet,rulecolor=\color{\methodColor}} } +\renewcommand{\methodXml} +{ +\colorlet{delimGet}{\methodColor} +\colorlet{numbGet}{delimGet} +\lstset{language=xmlGet,rulecolor=\color{\methodColor}} +} } {} @@ -295,6 +383,12 @@ nobreak=true \colorlet{numbPost}{delimPost} \lstset{language=jsonPost,rulecolor=\color{\methodColor}} } +\renewcommand{\methodXml} +{ +\colorlet{delimPost}{\methodColor} +\colorlet{numbPost}{delimPost} +\lstset{language=xmlPost,rulecolor=\color{\methodColor}} +} } {} @@ -309,6 +403,12 @@ nobreak=true \colorlet{numbPut}{delimPut} \lstset{language=jsonPut,rulecolor=\color{\methodColor}} } +\renewcommand{\methodXml} +{ +\colorlet{delimPut}{\methodColor} +\colorlet{numbPut}{delimPut} +\lstset{language=xmlPut,rulecolor=\color{\methodColor}} +} } {} \ifthenelse{\equal{\method}{delete}} @@ -322,6 +422,12 @@ nobreak=true \colorlet{numbDelete}{delimDelete} \lstset{language=jsonDelete,rulecolor=\color{\methodColor}} } +\renewcommand{\methodXml} +{ +\colorlet{delimDelete}{\methodColor} +\colorlet{numbDelete}{delimDelete} +\lstset{language=xmlDelete,rulecolor=\color{\methodColor}} +} } {} @@ -361,6 +467,8 @@ nobreak=true } \newenvironment{routeRequest}[1] { +\renewcommand{\bodyFormat}{#1} + \arrayrulecolor{\methodColor} \begin{tabularx}{\textwidth}{X l} @@ -374,7 +482,7 @@ nobreak=true } \lstnewenvironment{routeRequestBody} { -\methodJson +\IfSubStr{\bodyFormat}{xml}{\methodXml}{\methodJson} } {} \newenvironment{routeParameter} @@ -402,6 +510,8 @@ nobreak=true } \newenvironment{routeResponse}[1] { +\renewcommand{\bodyFormat}{#1} + \newcommand{\noRouteResponse}[1] { \begin{tabularx}{\textwidth}{X} @@ -429,7 +539,7 @@ nobreak=true \lstnewenvironment{routeResponseItemBody} { \vspace{-1.4em} -\methodJson +\IfSubStr{\bodyFormat}{xml}{\methodXml}{\methodJson} } {} \endinput -- cgit v1.2.3