summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/helpers.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-06-16 20:07:41 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-11-01 10:16:01 (GMT)
commita8598ae89acd2963143b7a6b248fbecbc0e16025 (patch)
tree1f094fa3175200b1cef8d6c6c079f7358802175a /plugins/pychrysalide/helpers.c
parentc59efee8c71c77d507356e53733a5607ff7814b3 (diff)
Fixed the rendering of Python documentation.
Diffstat (limited to 'plugins/pychrysalide/helpers.c')
-rw-r--r--plugins/pychrysalide/helpers.c42
1 files changed, 42 insertions, 0 deletions
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;