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

Skip to content

Commit 06a01e8

Browse files
committed
Define a new environment, classdesc*, which can be used to document a
class without providing any information about the constructor. This should be used for classes which only exist to act as containers rather than as factories for instances.
1 parent 986bada commit 06a01e8

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

Doc/perl/python.perl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,17 @@ sub do_env_classdesc{
906906
return handle_classlike_descriptor(@_[0], "class");
907907
}
908908

909+
sub do_env_classdescstar{
910+
local($_) = @_;
911+
$THIS_CLASS = next_argument();
912+
$idx = make_str_index_entry(
913+
"<tt class='class'>$THIS_CLASS</tt> (class in $THIS_MODULE)" );
914+
$idx =~ s/ \(.*\)//;
915+
return ("<dl><dt><b>class $idx</b>\n<dd>"
916+
. $_
917+
. '</dl>');
918+
}
919+
909920
sub do_env_excclassdesc{
910921
return handle_classlike_descriptor(@_[0], "exception");
911922
}

Doc/texinputs/python.sty

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,15 @@
623623
\index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}]
624624
}{\end{fulllineitems}}
625625

626+
% \begin{classdesc*}{name}
627+
\newenvironment{classdesc*}[1]{
628+
% Using \renewcommand doesn't work for this, for unknown reasons:
629+
\global\def\py@thisclass{#1}
630+
\begin{fulllineitems}
631+
\item[\strong{class }\code{\bfcode{#1}}%
632+
\index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}]
633+
}{\end{fulllineitems}}
634+
626635
% \begin{excclassdesc}{name}{constructor args}
627636
% but indexes as an exception
628637
\newenvironment{excclassdesc}[2]{
@@ -633,6 +642,9 @@
633642
\index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}]
634643
}{\end{fulllineitems}}
635644

645+
% There is no corresponding {excclassdesc*} environment. To describe
646+
% a class exception without parameters, use the {excdesc} environment.
647+
636648

637649
\let\py@classbadkey=\@undefined
638650

0 commit comments

Comments
 (0)