Skip to content

Replace _sage_doc_ by a __doc__ descriptor #22611

@jdemeyer

Description

@jdemeyer

Currently, the method _sage_doc_ is used to implement custom documentation for instances of a class. Such a use case makes sense, but it should be implemented as the __doc__ attribute instead of the Sage-specific _sage_doc_.

I tried various ways of implementing this and I found several Cython bugs along the way. The current solution is not the cleanest, but it works in all cases (Cython and Python, extension types and normal classes).

In the cases where _sage_doc_ was implemented for a base class, this patch requires adding @instancedoc to every subclass. This is because Python never inherits the __doc__ attribute. There is a way around this using a metaclass, but I avoided that because metaclasses have their own problems (see #21681).

CC: @hivert @nthiery

Component: documentation

Keywords: days85

Author: Jeroen Demeyer

Branch/Commit: 5fe7cb0

Reviewer: Erik Bray

Issue created by migration from https://trac.sagemath.org/ticket/22611

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions