From ripley at stats.ox.ac.uk  Tue Sep 18 10:42:37 2007
From: ripley at stats.ox.ac.uk (ripley at stats.ox.ac.uk)
Date: Tue, 18 Sep 2007 10:42:37 +0200 (CEST)
Subject: [Rd] (PR#9915) *.Rd file: space after topic in "\alias{topic }"
Message-ID: <20070918084237.4E8BF6682F@slim.kubism.ku.dk>

Spaces are indeed significant in \alias, and the treatment of leading and 
trailing spaces seems undocumented.  (Four CRAN package authors have made 
assumptions here.)

As far as I can see this comes up in 3 places:

1) Writing AnIndex strips leading but not trailing spaces.
2) get_multi used to create @aliases strips both.
3) Looking up aliases in \link happens at both compile and (for [C]HTML) 
run times, and it seems never strips spaces.

I think it would have been better to leave spaces alone, but I propose to 
consistently strip leading and trailing spaces in aliases and not links, 
and to document that.

On Mon, 17 Sep 2007, bill at insightful.com wrote:

> On Mon, 17 Sep 2007 bill at insightful.com wrote:
>
>> Full_Name: Bill Dunlap
>> Version: R version 2.6.0 Under development (unstable) (2007-07-26 r42329)
>> OS: Linux
>> Submission from: (NULL) (24.16.101.199)
>>
>> If a *.Rd file has an \alias{topic } with a space
>> between 'topic' and the closing '}' then the space
>> is copied to the help/AnIndex file and help(topic)
>> fails to find the help file.
>>
>> E.g., if the help file starts with
>>    \name{test1}
>>    \alias{test1 }
>>    \alias{test2}
>>    \alias{test3 }
>>    \alias{test4}
>> then help(test1) and help(test4) work, but not
>> help(test1) or help(test3).
>>
>> A possible fix is
>> --- share/perl/R/Rdlists.pm     (revision 42846)
>> +++ share/perl/R/Rdlists.pm     (working copy)
>> @@ -329,7 +329,7 @@
>>                 $main::title2file{$rdtitle} = $manfilebase;
>>             }
>>
>> -           while($text =~ s/\\alias\{\s*(.*)\s*\}//){
>> +           while($text =~ s/\\alias\{\s*([^\s]*)\s*\}//){
>>                 $alias = $1;
>>                 $alias =~ s/\\%/%/g;
>>                 if ($internal){
>
> It looks like internal spaces are used in \alias entries,
> e.g.,
>  ./R.utils/man/Non-documented_objects.Rd:\alias{Non-documented objects}
>  ./SparseM/man/character-null-class.Rd:\alias{character or NULL-class}
> I think the trailing spaces are intended to be ignored,
> so a better fix would be
>
> --- Rdlists.pm  (revision 42846)
> +++ Rdlists.pm  (working copy)
> @@ -332,6 +332,7 @@
>            while($text =~ s/\\alias\{\s*(.*)\s*\}//){
>                $alias = $1;
>                $alias =~ s/\\%/%/g;
> +               $alias =~ s/\s*$//;
>                if ($internal){
>                    $internal{$alias} = 1;
>                }
>
>
>
> ----------------------------------------------------------------------------
> Bill Dunlap
> Insightful Corporation
> bill at insightful dot com
> 360-428-8146
>
> "All statements in this message represent the opinions of the author and do
> not necessarily reflect Insightful Corporation policy or position."
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] (PR#9915) *.Rd file: space after topic in "\alias{topic }"
ripley at stats.ox.ac.uk