[gedit/wip/spell-checking] spell: add API documentation



commit e115e76f7182d2f76007a5d306961d1ef5679f9e
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Fri Aug 7 15:43:43 2015 +0200

    spell: add API documentation

 plugins/spell/gedit-spell-checker.c |  120 +++++++++++++++++++++++++++++++++--
 1 files changed, 115 insertions(+), 5 deletions(-)
---
diff --git a/plugins/spell/gedit-spell-checker.c b/plugins/spell/gedit-spell-checker.c
index 0570454..b392df5 100644
--- a/plugins/spell/gedit-spell-checker.c
+++ b/plugins/spell/gedit-spell-checker.c
@@ -32,6 +32,16 @@
 #include "gedit-spell-osx.h"
 #endif
 
+/**
+ * SECTION:spell-checker
+ * @Short_description: Spell checker
+ * @Title: GeditSpellChecker
+ * @See_also: #GeditSpellCheckerLanguage
+ *
+ * #GeditSpellChecker is a spell checker. It is a wrapper around the Enchant
+ * library, to have a #GObject-based API.
+ */
+
 typedef struct _GeditSpellCheckerPrivate GeditSpellCheckerPrivate;
 
 struct _GeditSpellCheckerPrivate
@@ -143,6 +153,11 @@ gedit_spell_checker_class_init (GeditSpellCheckerClass *klass)
        object_class->get_property = gedit_spell_checker_get_property;
        object_class->finalize = gedit_spell_checker_finalize;
 
+       /**
+        * GeditSpellChecker:language:
+        *
+        * The #GeditSpellCheckerLanguage used.
+        */
        g_object_class_install_property (object_class,
                                         PROP_LANGUAGE,
                                         g_param_spec_pointer ("language",
@@ -152,6 +167,13 @@ gedit_spell_checker_class_init (GeditSpellCheckerClass *klass)
                                                               G_PARAM_CONSTRUCT |
                                                               G_PARAM_STATIC_STRINGS));
 
+       /**
+        * GeditSpellChecker::add-word-to-personal:
+        * @spell_checker: the #GeditSpellChecker.
+        * @word: the added word.
+        *
+        * Emitted when a word is added to the personal dictionary.
+        */
        signals[SIGNAL_ADD_WORD_TO_PERSONAL] =
                g_signal_new ("add-word-to-personal",
                              G_OBJECT_CLASS_TYPE (object_class),
@@ -162,6 +184,14 @@ gedit_spell_checker_class_init (GeditSpellCheckerClass *klass)
                              1,
                              G_TYPE_STRING);
 
+       /**
+        * GeditSpellChecker::add-word-to-session:
+        * @spell_checker: the #GeditSpellChecker.
+        * @word: the added word.
+        *
+        * Emitted when a word is added to the session dictionary. The session
+        * dictionary is lost when the application exits.
+        */
        signals[SIGNAL_ADD_WORD_TO_SESSION] =
                g_signal_new ("add-word-to-session",
                              G_OBJECT_CLASS_TYPE (object_class),
@@ -172,6 +202,12 @@ gedit_spell_checker_class_init (GeditSpellCheckerClass *klass)
                              1,
                              G_TYPE_STRING);
 
+       /**
+        * GeditSpellChecker::clear-session:
+        * @spell_checker: the #GeditSpellChecker.
+        *
+        * Emitted when the session dictionary is cleared.
+        */
        signals[SIGNAL_CLEAR_SESSION] =
                g_signal_new ("clear-session",
                              G_OBJECT_CLASS_TYPE (object_class),
@@ -194,6 +230,12 @@ gedit_spell_checker_init (GeditSpellChecker *checker)
        priv->active_lang = NULL;
 }
 
+/**
+ * gedit_spell_checker_new:
+ * @language: the #GeditSpellCheckerLanguage to use.
+ *
+ * Returns: a new #GeditSpellChecker object.
+ */
 GeditSpellChecker *
 gedit_spell_checker_new        (const GeditSpellCheckerLanguage *language)
 {
@@ -295,8 +337,14 @@ init_dictionary (GeditSpellChecker *checker)
        return TRUE;
 }
 
-/* If @language is %NULL, find the best available language based on the current
- * locale.
+/**
+ * gedit_spell_checker_set_language:
+ * @checker: a #GeditSpellChecker.
+ * @language: (nullable): the #GeditSpellCheckerLanguage to use, or %NULL.
+ *
+ * Sets the language to use for the spell checking. If @language is %NULL, finds
+ * the best available language based on the current locale.
+ *
  * Returns: whether the operation was successful.
  */
 gboolean
@@ -329,6 +377,12 @@ gedit_spell_checker_set_language (GeditSpellChecker               *checker,
        return success;
 }
 
+/**
+ * gedit_spell_checker_get_language:
+ * @checker: a #GeditSpellChecker.
+ *
+ * Returns: the #GeditSpellCheckerLanguage currently used.
+ */
 const GeditSpellCheckerLanguage *
 gedit_spell_checker_get_language (GeditSpellChecker *checker)
 {
@@ -341,7 +395,14 @@ gedit_spell_checker_get_language (GeditSpellChecker *checker)
        return priv->active_lang;
 }
 
-/* Returns whether @word is correctly spelled. */
+/**
+ * gedit_spell_checker_check_word:
+ * @checker: a #GeditSpellChecker.
+ * @word: the word to check.
+ * @error: (out) (optional): a location to a %NULL #GError, or %NULL.
+ *
+ * Returns: whether @word is correctly spelled.
+ */
 gboolean
 gedit_spell_checker_check_word (GeditSpellChecker  *checker,
                                const gchar        *word,
@@ -384,7 +445,16 @@ gedit_spell_checker_check_word (GeditSpellChecker  *checker,
        return correctly_spelled;
 }
 
-/* return NULL on error or if no suggestions are found */
+/**
+ * gedit_spell_checker_get_suggestions:
+ * @checker: a #GeditSpellChecker.
+ * @word: a misspelled word.
+ *
+ * Gets the suggestions for @word. Free the return value with
+ * g_slist_free_full(suggestions, g_free).
+ *
+ * Returns: (transfer full) (element-type utf8): the list of suggestions.
+ */
 GSList *
 gedit_spell_checker_get_suggestions (GeditSpellChecker *checker,
                                     const gchar       *word)
@@ -422,6 +492,17 @@ gedit_spell_checker_get_suggestions (GeditSpellChecker *checker,
        return g_slist_reverse (suggestions_list);
 }
 
+/**
+ * gedit_spell_checker_add_word_to_personal:
+ * @checker: a #GeditSpellChecker.
+ * @word: a word.
+ *
+ * Adds a word to the personal dictionary. It is typically saved in the user
+ * home directory.
+ *
+ * Returns: whether the operation was successful.
+ * TODO do not return a value.
+ */
 gboolean
 gedit_spell_checker_add_word_to_personal (GeditSpellChecker *checker,
                                          const gchar       *word)
@@ -445,6 +526,18 @@ gedit_spell_checker_add_word_to_personal (GeditSpellChecker *checker,
        return TRUE;
 }
 
+/**
+ * gedit_spell_checker_add_word_to_session:
+ * @checker: a #GeditSpellChecker.
+ * @word: a word.
+ *
+ * Adds a word to the session dictionary. The session dictionary is lost when
+ * the application exits. This function is typically called when an “Ignore All”
+ * action is activated.
+ *
+ * Returns: whether the operation was successful.
+ * TODO do not return a value.
+ */
 gboolean
 gedit_spell_checker_add_word_to_session (GeditSpellChecker *checker,
                                         const gchar       *word)
@@ -468,6 +561,14 @@ gedit_spell_checker_add_word_to_session (GeditSpellChecker *checker,
        return TRUE;
 }
 
+/**
+ * gedit_spell_checker_clear_session:
+ * @checker: a #GeditSpellChecker.
+ *
+ * Clears the session dictionary.
+ *
+ * Returns: whether the operation was successful.
+ */
 gboolean
 gedit_spell_checker_clear_session (GeditSpellChecker *checker)
 {
@@ -494,7 +595,16 @@ gedit_spell_checker_clear_session (GeditSpellChecker *checker)
        return TRUE;
 }
 
-/* Informs dictionary, that @word will be replaced/corrected by @replacement. */
+/**
+ * gedit_spell_checker_set_correction:
+ * @checker: a #GeditSpellChecker.
+ * @word: a word.
+ * @replacement: the replacement word.
+ *
+ * Informs the spell checker that @word is replaced/corrected by @replacement.
+ *
+ * Returns: whether the operation was successful.
+ */
 gboolean
 gedit_spell_checker_set_correction (GeditSpellChecker *checker,
                                    const gchar       *word,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]