mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Added support for optional explanation parameter to the \versionadded
macro. Refactored do_cmd_versionadded() and do_cmd_versionchanged() to do most of the work in a helper function, with the do_cmd_*() wrappers just supplying a portion of the replacement text.
This commit is contained in:
		
							parent
							
								
									fdfb05bb0b
								
							
						
					
					
						commit
						c2b29d0fee
					
				
					 1 changed files with 15 additions and 14 deletions
				
			
		| 
						 | 
				
			
			@ -344,24 +344,25 @@ sub do_cmd_deprecated{
 | 
			
		|||
            . $_);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub do_cmd_versionadded{
 | 
			
		||||
    # one parameter:  \versionadded{version}
 | 
			
		||||
    local($_) = @_;
 | 
			
		||||
sub versionnote{
 | 
			
		||||
    # one or two parameters:  \versionnote[explanation]{version}
 | 
			
		||||
    my $type = @_[0];
 | 
			
		||||
    local $_ = @_[1];
 | 
			
		||||
    my $explanation = next_optional_argument();
 | 
			
		||||
    my $release = next_argument();
 | 
			
		||||
    return ("\n<span class='versionnote'>New in version $release.</span>\n"
 | 
			
		||||
            . $_);
 | 
			
		||||
    my $text = "$type in version $release.";
 | 
			
		||||
    if ($explanation) {
 | 
			
		||||
        $text = "$type in version $release:\n$explanation.";
 | 
			
		||||
    }
 | 
			
		||||
    return "\n<span class='versionnote'>$text</span>\n" . $_;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub do_cmd_versionadded{
 | 
			
		||||
    return versionnote('New', @_);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub do_cmd_versionchanged{
 | 
			
		||||
    # one parameter:  \versionchanged{version}
 | 
			
		||||
    local($_) = @_;
 | 
			
		||||
    my $explanation = next_optional_argument();
 | 
			
		||||
    my $release = next_argument();
 | 
			
		||||
    my $text = "Changed in version $release.";
 | 
			
		||||
    if ($explanation) {
 | 
			
		||||
        $text = "Changed in version $release:\n$explanation.";
 | 
			
		||||
    }
 | 
			
		||||
    return "\n<span class='versionnote'>$text</span>\n" . $_;
 | 
			
		||||
    return versionnote('Changed', @_);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue