#13969: "self" sometimes gets substituted in class docstrings
---------------------------+------------------------------------------------
       Reporter:  cnassau  |         Owner:  jason   
           Type:  defect   |        Status:  new     
       Priority:  major    |     Milestone:  sage-5.7
      Component:  misc     |    Resolution:          
       Keywords:           |   Work issues:          
Report Upstream:  N/A      |     Reviewers:          
        Authors:           |     Merged in:          
   Dependencies:           |      Stopgaps:          
---------------------------+------------------------------------------------

Comment (by cnassau):

 Here are two cases where the substitution of "self" to "objname" is
 probably desired; note that both contain instances of "{{{self}}}", but
 only "{{{self.}}}" is substituted. So the current substitution mechanism
 is already a little bit broken:
 {{{#!python
 Z = random_matrix(GF(2),10,10)
 Z.rows?
 }}}
 {{{#!python
 U=RIF(1, 2)
 U.diameter?
 }}}
 There are plenty of cases where the substitution is probably **not**
 desired. Such cases can be found with
 {{{
 grep -irn "\.\.\..*self\." devel/sage/sage/*/*py*
 }}}
 For example
 {{{#!python
 sage: sage.structure.parent?
 }}}
 shows
 {{{#!python
 sage: class A_class(Parent):
 ...     def __init__(self, name):
 ...         Parent.__init__(self, name=name)
 ...         sage._populate_coercion_lists_()
 ...         sage.rename(name)
 }}}
 (note the substitution "{{{self.}}}" -> "{{{sage.}}}").

 I would suggest to

   * remove the automatic substitution "{{{self.}}}" -> "{{{obj_name.}}}"
   * introduce a new substitution "{{{OBJNAME}}}" -> "{{{obj_name}}}" and
 use "{{{self}}}" as default object name if none is provided.

 This way we would still support dynamic object name replacement, but the
 replacement would be restricted to those cases where the docstring author
 explicitly asked for it.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13969#comment:3>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to