Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0c275fa

Browse files
committed
Added support for \platform, \platformof, and \ignorePlatformAnnotation.
1 parent 557460c commit 0c275fa

1 file changed

Lines changed: 47 additions & 10 deletions

File tree

Doc/texinputs/python.sty

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,11 @@
261261
\setindexsubitem{(in module #1)}%
262262
\index{#1@{\py@idxcode{#1}} (#2module)|textbf}%
263263
\ifpy@UseModuleIndex%
264-
\write\modindexfile{\protect\indexentry{#1@{\texttt {#1}}}{\thepage}}%
264+
\@ifundefined{py@modplat@\py@thismodulekey}{
265+
\write\modindexfile{\protect\indexentry{#1@{\texttt{#1}}}{\thepage}}%
266+
}{\write\modindexfile{\protect\indexentry{#1@{\texttt{#1} %
267+
\emph{(\platformof[\py@thismodulekey]{})}}}{\thepage}}%
268+
}
265269
\fi%
266270
}
267271

@@ -287,27 +291,56 @@
287291

288292
% Module synopsis processing -----------------------------------------------
289293
%
294+
\newcommand{\py@thisclass}{}
295+
\newcommand{\py@thismodule}{}
296+
\newcommand{\py@thismodulekey}{}
297+
\newcommand{\py@thismoduletype}{}
298+
290299
\newcommand{\py@standardIndexModule}[1]{\stmodindex{#1}}
291300
\newcommand{\py@builtinIndexModule}[1]{\bimodindex{#1}}
292301
\newcommand{\py@extensionIndexModule}[1]{\exmodindex{#1}}
293302
\newcommand{\py@IndexModule}[1]{\modindex{#1}}
294303

295-
\newif\ifpy@HaveModSynopsis\py@HaveModSynopsisfalse
296-
\newif\ifpy@ModSynopsisFileIsOpen\py@ModSynopsisFileIsOpenfalse
304+
\newif\ifpy@HaveModSynopsis \py@HaveModSynopsisfalse
305+
\newif\ifpy@ModSynopsisFileIsOpen \py@ModSynopsisFileIsOpenfalse
306+
\newif\ifpy@HaveModPlatform \py@HaveModPlatformfalse
297307

298308
% \declaremodule[key]{type}{name}
299309
\newcommand{\declaremodule}[3][\py@modulebadkey]{
300310
\py@openModSynopsisFile
301311
\renewcommand{\py@thismoduletype}{#2}
302-
\csname py@#2IndexModule\endcsname{#3}
303312
\ifx\py@modulebadkey#1
304313
\renewcommand{\py@thismodulekey}{#3}
305314
\else
306315
\renewcommand{\py@thismodulekey}{#1}
307316
\fi
317+
\csname py@#2IndexModule\endcsname{#3}
308318
\label{module-\py@thismodulekey}
309-
\py@HaveModSynopsistrue
310319
}
320+
\newif\ifpy@ModPlatformFileIsOpen \py@ModPlatformFileIsOpenfalse
321+
\newcommand{\py@ModPlatformFilename}{\jobname.pla}
322+
\newcommand{\platform}[1]{
323+
\ifpy@ModPlatformFileIsOpen\else
324+
\newwrite\py@ModPlatformFile
325+
\openout\py@ModPlatformFile=\py@ModPlatformFilename
326+
\py@ModPlatformFileIsOpentrue
327+
\fi
328+
\@ifundefined{py@modplat@\py@thismodulekey}{
329+
\py@writeModPlatformFile{%
330+
\newcommand{\csname py@modplat@\py@thismodulekey\endcsname}{#1}}%
331+
}{\py@writeModPlatformFile{%
332+
\newcommand{\string\py@modplat@\py@thismodulekey}{#1}%
333+
}
334+
}
335+
}
336+
\InputIfFileExists{\jobname.pla}{}{}
337+
\newcommand{\platformof}[2][\py@modulebadkey]{%
338+
\ifx\py@modulebadkey#1 \def\py@key{#2}%
339+
\else \def\py@key{#1}%
340+
\fi%
341+
\csname py@modplat@\py@key\endcsname%
342+
}
343+
\newcommand{\ignorePlatformAnnotation}[1]{}
311344

312345
% \moduleauthor{name}{email}
313346
\newcommand{\moduleauthor}[2]{}
@@ -319,6 +352,7 @@
319352
\newcommand{\py@defsynopsis}{Module has no synopsis.}
320353
\newcommand{\py@modulesynopsis}{\py@defsynopsis}
321354
\newcommand{\modulesynopsis}[1]{
355+
\py@HaveModSynopsistrue
322356
\renewcommand{\py@modulesynopsis}{#1}
323357
}
324358

@@ -355,6 +389,14 @@
355389
}
356390
\AtEndDocument{\py@ProcessModSynopsis\py@closeModSynopsisFile}
357391

392+
393+
\long\def\py@writeModPlatformFile#1{%
394+
\protected@write\py@ModPlatformFile%
395+
{\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
396+
{\string#1}%
397+
}
398+
399+
358400
\newcommand{\localmoduletable}{
359401
\IfFileExists{\py@ModSynopsisFilename}{
360402
\begin{synopsistable}
@@ -381,11 +423,6 @@
381423
% --------------------------------------------------------------------------
382424

383425

384-
\newcommand{\py@thisclass}{}
385-
\newcommand{\py@thismodule}{}
386-
\newcommand{\py@thismodulekey}{}
387-
\newcommand{\py@thismoduletype}{}
388-
389426
\newcommand{\py@reset}{
390427
\py@ProcessModSynopsis
391428
\renewcommand{\py@thisclass}{}

0 commit comments

Comments
 (0)