While I have no ideas/suggestions on how to implement it, I think that
it is highly desirable to have such a functionality. In addition to
simplifying life of those who write doctests with links, it will help
to make documentation more stable - if some classes/functions were
moved around modules but were still exported through all.py, all
references would remain accurate with automatic search rather than
hardcoded direct links.

Thank you,
Andrey

On Jun 2, 3:06 pm, Florent Hivert <florent.hiv...@univ-rouen.fr>
wrote:
>       Hi There,
>
> Since nobody answered I investigated this further:
>
>
>
> >    Though sphinx is perfectly working with target in the local module he 
> > isn't
> > able to find reference target from other modules even if they are exported 
> > in
> > all.py. For example, if I want to link Parent from anywhere but parent.pyx, 
> > I
> > have to write the full path (ie. :class:`~sage.structure.parent.Parent`) 
> > even
> > if it is imported in my module. I find this extremely annoying since, in the
> > task of improving the category doc, I'm setting up a lot of huge cross
> > references such as:
>
> >     :meth:`Algebras.ParentMethods.algebra_generators()
> >     <sage.categories.algebras.Algebras.ParentMethods.algebra_generators>`.
>
> > I would be very happy if I had to write only
>
> >     :meth:`Algebras.ParentMethods.algebra_generators`
>
> > Does anyone know if there is a way to have sphinx aware of all.py
> > or local import in a module ?
>
> It seems that this is more or less easily feasible. I've a prototype patch to
> sphinx which only works for objects (eg: Parent). It won't work on thing like
> "Parent.rename". I'd like to know if it is a desired feature before polishing
> it further (and asking on sphinx-user for the good way to do this)... Also my
> solution involve hacking directly into sphinx. Any suggestion for a better way
> is welcome.
>
> So if anyone has a comment. Please answer.
>
> Cheers,
>
> Florent
>
> --- environment.py.orig 2010-06-02 22:52:17.000000000 +0200
> +++ environment.py      2010-06-02 23:55:35.000000000 +0200
> @@ -1606,7 +1606,18 @@
>                   'object.' + name in self.descrefs:
>                  newname = 'object.' + name
>          if newname is None:
> -            return None, None
> +            import sage
> +            try:
> +                obj = getattr(sage.all, name)
> +            except AttributeError:
> +                return None, None
> +            newname = obj.__module__+"."+obj.__name__
> +            if newname not in self.descrefs:
> +                return None, None
> +            else:
> +                print "find_desc called modname=%s, classname=%s, name=%s, 
> type=%s"%(
> +                    modname, classname, name, type)
> +                print "found %s"%(newname)
>          return newname, self.descrefs[newname]
>
>      def find_keyword(self, keyword, avoid_fuzzy=False, cutoff=0.6, n=20):

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to