From a8598ae89acd2963143b7a6b248fbecbc0e16025 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sun, 16 Jun 2019 22:07:41 +0200 Subject: Fixed the rendering of Python documentation. --- plugins/pychrysalide/helpers.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/plugins/pychrysalide/helpers.c b/plugins/pychrysalide/helpers.c index 5b7c1e6..d2215d8 100644 --- a/plugins/pychrysalide/helpers.c +++ b/plugins/pychrysalide/helpers.c @@ -61,6 +61,10 @@ static bool include_python_type_into_features(PyObject *, PyTypeObject *); #define NOT_IMPLEMENTED_MSG _("Chrysalide method implementation is missing") +/* Détermine une documentation adaptée à un type interne. */ +static void define_auto_documentation(PyTypeObject *); + + /* ---------------------------------------------------------------------------------- */ /* ACCELERATEURS POUR PYTHON UNIQUEMENT */ @@ -728,6 +732,30 @@ PyTypeObject *define_python_dynamic_type(const PyTypeObject *spec) /****************************************************************************** * * +* Paramètres : type = type dans sa version Python. * +* * +* Description : Détermine une documentation adaptée à un type interne. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void define_auto_documentation(PyTypeObject *type) +{ + /** + * L'idée est ici d'éviter la documentation automatique générée par + * pyg_object_descr_doc_get(). + */ + + PyDict_SetItemString(type->tp_dict, "__doc__", PyUnicode_FromString(type->tp_doc)); + +} + + +/****************************************************************************** +* * * Paramètres : dict = dictionnaire où conserver une référence au type créé.* * gtype = type dans sa version GLib. * * type = type dans sa version Python. * @@ -749,6 +777,8 @@ bool _register_class_for_pygobject(PyObject *dict, GType gtype, PyTypeObject *ty va_list ap; /* Parcours des arguments */ PyTypeObject *static_base; /* Base à rajouter à la liste */ + assert(gtype != G_TYPE_INVALID); + /** * pygobject_register_class() définit type->tp_base à partir des arguments fournis, * puis fait appel à PyType_Ready(). @@ -826,8 +856,13 @@ bool _register_class_for_pygobject(PyObject *dict, GType gtype, PyTypeObject *ty */ if (result && startswith(type->tp_name, "pychrysalide.")) + { + define_auto_documentation(type); + result = include_python_type_into_features(dict, type); + } + return result; } @@ -852,6 +887,8 @@ bool register_interface_for_pygobject(PyObject *dict, GType gtype, PyTypeObject bool result; /* Bilan à retourner */ char *name; /* Désignation de la classe */ + assert(gtype != G_TYPE_INVALID); + name = strrchr(type->tp_name, '.'); assert(name != NULL); @@ -860,7 +897,12 @@ bool register_interface_for_pygobject(PyObject *dict, GType gtype, PyTypeObject pyg_register_interface(dict, name, gtype, type); if (startswith(type->tp_name, "pychrysalide.")) + { + define_auto_documentation(type); + result = include_python_type_into_features(dict, type); + + } else result = true; -- cgit v0.11.2-87-g4458