Bug 37793

Summary: Improve documentation coverage
Product: dbus Reporter: Simon McVittie <smcv>
Component: GLibAssignee: Simon McVittie <smcv>
Status: RESOLVED FIXED QA Contact: John (J5) Palmieri <johnp>
Severity: enhancement    
Priority: medium CC: cosimo.alfarano, rob.taylor, smcv, will
Version: unspecifiedKeywords: patch
Hardware: All   
OS: Linux (All)   
URL: http://cgit.freedesktop.org/~smcv/dbus-glib/log/?h=more-docs-37793
Whiteboard: NB#218973, review?
i915 platform: i915 features:
Bug Depends on: 10890    
Bug Blocks:    
Attachments: [PATCH 01/14] Add some missing symbols to the docs
[PATCH 02/14] Mention which header to include in the gtk-doc
[PATCH 03/14] Remove stray empty subsection
[PATCH 04/14] Ignore non-API source files correctly
[PATCH 05/14] Clean up docs for DBusGConnection
[PATCH 06/14] Tidy up docs for DBusGMessage
[PATCH 07/14] Tidy up docs for DBusGError and its pseudo-methods
[PATCH 08/14] Add DBUS_TYPE_CONNECTION, DBUS_TYPE_MESSAGE to the docs, and document them better
[PATCH 09/14] Remove declaration of dbus_pending_call_get_g_type, which doesn't exist
[PATCH 10/14] specialized types: improve documentation and document more things
[PATCH 11/14] DBusGProxy: mark struct contents as private
[PATCH 12/14] DBusGProxy: make argument names in declaration, definition and docs consistent
[PATCH 13/14] DBusGProxy: misc documentation tidying
[PATCH 14/14] DBusGProxy: be more pedantic about boolean returns
[1/6 v2] Tidy up docs for DBusGError and its pseudo-methods
[2/6] dbus-gtype-specialized: warn if vtables have missing callbacks
[3/6] dbus_g_type_collection_get_fixed: check preconditions on the type and vtable
[4/6] dbus_g_type_collection_value_iterate, etc.: check that the type is suitable
[5/6] specialized types: improve documentation and document more things
[6/6] Fix various minor documentation bugs

Description Simon McVittie 2011-05-31 08:24:18 UTC
+++ This bug was initially created as a clone of Bug #10890 +++

dbus-glib's documentation coverage is rather patchy, and running gtk-doc produces lots of warnings. We can easily do better.
Comment 1 Simon McVittie 2011-05-31 08:25:15 UTC
Created attachment 47383 [details] [review]
[PATCH 01/14] Add some missing symbols to the docs
Comment 2 Simon McVittie 2011-05-31 08:25:31 UTC
Created attachment 47384 [details] [review]
[PATCH 02/14] Mention which header to include in the gtk-doc
Comment 3 Simon McVittie 2011-05-31 08:25:46 UTC
Created attachment 47385 [details] [review]
[PATCH 03/14] Remove stray empty subsection
Comment 4 Simon McVittie 2011-05-31 08:26:06 UTC
Created attachment 47386 [details] [review]
[PATCH 04/14] Ignore non-API source files correctly

gtk-doc only cares about the basename of the files.
Comment 5 Simon McVittie 2011-05-31 08:26:26 UTC
Created attachment 47387 [details] [review]
[PATCH 05/14] Clean up docs for DBusGConnection

* introductory doc-comment for the (pseudo-)class
* attach the doc-comment for the GType to the macro, not the internal
  function
* rename function parameters to match what the header file says
Comment 6 Simon McVittie 2011-05-31 08:26:48 UTC
Created attachment 47388 [details] [review]
[PATCH 06/14] Tidy up docs for DBusGMessage

* document the instance struct 
* make argument names match the headers
* document the GType macro, not the function it calls, and mention it
  in the documentation (since this is a boxed type, so it's non-obvious)
Comment 7 Simon McVittie 2011-05-31 08:27:11 UTC
Created attachment 47389 [details] [review]
[PATCH 07/14] Tidy up docs for DBusGError and its pseudo-methods

* attach the introductory doc-comments to the enum and macro names,
  not the internal function 
* remove docs for method parameters which didn't actually exist
* more cross-references
* make the domain macro visible in the documentation index
Comment 8 Simon McVittie 2011-05-31 08:27:25 UTC
Created attachment 47390 [details] [review]
[PATCH 08/14] Add DBUS_TYPE_CONNECTION, DBUS_TYPE_MESSAGE to the  docs, and document them better
Comment 9 Simon McVittie 2011-05-31 08:27:47 UTC
Created attachment 47391 [details] [review]
[PATCH 09/14] Remove declaration of dbus_pending_call_get_g_type,  which doesn't exist
Comment 10 Simon McVittie 2011-05-31 08:28:01 UTC
Created attachment 47392 [details] [review]
[PATCH 10/14] specialized types: improve documentation and document  more things
Comment 11 Simon McVittie 2011-05-31 08:28:17 UTC
Created attachment 47393 [details] [review]
[PATCH 11/14] DBusGProxy: mark struct contents as private
Comment 12 Simon McVittie 2011-05-31 08:28:40 UTC
Created attachment 47394 [details] [review]
[PATCH 12/14] DBusGProxy: make argument names in declaration,  definition and docs consistent
Comment 13 Simon McVittie 2011-05-31 08:28:56 UTC
Created attachment 47395 [details] [review]
[PATCH 13/14] DBusGProxy: misc documentation tidying
Comment 14 Simon McVittie 2011-05-31 08:29:18 UTC
Created attachment 47396 [details] [review]
[PATCH 14/14] DBusGProxy: be more pedantic about boolean returns

Returning false doesn't strictly imply that the error is set; if you're
being pedantic enough, it's really a tri-state where TRUE indicates
success, FALSE indicates failure, and calling the function incorrectly
results in undefined behaviour (currently a critical warning and
returning FALSE).

Bug-NB: NB#218973
Comment 15 Simon McVittie 2011-09-22 04:08:30 UTC
Cosimo, could you review these please? They resolve NB#218973.

I've rebased the branch in cgit onto dbus-glib 0.96, which I released yesterday.
Comment 16 Cosimo Alfarano 2011-09-27 05:27:59 UTC
Review of attachment 47383 [details] [review]:

Fine to me
Comment 17 Cosimo Alfarano 2011-09-27 05:28:06 UTC
Review of attachment 47384 [details] [review]:

Fine to me.
Comment 18 Cosimo Alfarano 2011-09-27 05:28:12 UTC
Review of attachment 47385 [details] [review]:

Also fine.
Comment 19 Cosimo Alfarano 2011-09-27 05:28:26 UTC
Review of attachment 47386 [details] [review]:

OK
Comment 20 Cosimo Alfarano 2011-09-27 05:28:35 UTC
Review of attachment 47387 [details] [review]:

Fine
Comment 21 Cosimo Alfarano 2011-09-27 05:28:45 UTC
Review of attachment 47388 [details] [review]:

Also Fine
Comment 22 Cosimo Alfarano 2011-09-27 05:29:14 UTC
Review of attachment 47389 [details] [review]:

Fine for me either with or without the "iff" amend.

::: dbus/dbus-glib.c
@@ +187,3 @@
  * the given name.  This function is intended to be invoked on a
+ * #GError returned from an invocation of a remote method, e.g. via
+ * dbus_g_proxy_end_call().  It will silently return FALSE for errors

%FALSE

@@ +193,2 @@
  *
  * Returns: TRUE iff the remote error has the given name

%TRUE

Also, since you're touching the file, what do you think of extending "iff" as "if and only if", for clarity sake?
One might thing it's a typo, which wouldn't change much, but it's still documentation :)

I don't know if it occurs elsewhere.
Comment 23 Cosimo Alfarano 2011-09-27 05:29:21 UTC
Review of attachment 47390 [details] [review]:

Fine for me
Comment 24 Cosimo Alfarano 2011-09-27 05:29:28 UTC
Review of attachment 47391 [details] [review]:

OK
Comment 25 Cosimo Alfarano 2011-09-27 05:29:37 UTC
Review of attachment 47392 [details] [review]:

::: dbus/dbus-gtype-specialized.c
@@ +822,1 @@
  *

I find confusing "If <return value> otherwise it's an error". I expect that "otherwise" in this sentence structure has other possible return values, while it is actually warning about something stronger.

What about something like (rephrase as you wish, not native speaker here :)

--
It requires the collection having elements of fixed size (i.e. ...).
Otherwise, it is an error to call this function. [what can it happen?]

Return the contents of the array.
--

@@ +822,3 @@
  *
+ * It's probably a bad idea to call this.
+ *

I'd move this sentence in the beginning of the description, to help users to drop the idea of using it before actually imaging an actual use for it :)

Probably joint together with the "it's an error" case above.
Comment 26 Cosimo Alfarano 2011-09-27 05:29:46 UTC
Review of attachment 47393 [details] [review]:

K.
Comment 27 Cosimo Alfarano 2011-09-27 05:29:55 UTC
Review of attachment 47394 [details] [review]:

OK
Comment 28 Cosimo Alfarano 2011-09-27 05:30:07 UTC
Review of attachment 47395 [details] [review]:

Fine
Comment 29 Cosimo Alfarano 2011-09-27 05:31:21 UTC
Review of attachment 47396 [details] [review]:

OK
Comment 30 Simon McVittie 2011-09-27 07:14:35 UTC
(In reply to comment #22)
> ::: dbus/dbus-glib.c
> @@ +187,3 @@
>   * the given name.  This function is intended to be invoked on a
> + * #GError returned from an invocation of a remote method, e.g. via
> + * dbus_g_proxy_end_call().  It will silently return FALSE for errors
> 
> %FALSE

Good catch, I'll annotate that

> Also, since you're touching the file, what do you think of extending "iff" as
> "if and only if", for clarity sake?

Yeah, we should be kind to non-mathematicians :-)

> I don't know if it occurs elsewhere.

I'll grep.

(In reply to comment #25)
> What about something like (rephrase as you wish, not native speaker here :)
> 
> --
> It requires the collection having elements of fixed size (i.e. ...).
> Otherwise, it is an error to call this function. [what can it happen?]

Yeah, you're right. I'll look for a good phrasing.

> + * It's probably a bad idea to call this.
> + *
> 
> I'd move this sentence in the beginning of the description, to help users to
> drop the idea of using it before actually imaging an actual use for it :)

Yeah, perhaps that would be better :-)
Comment 31 Simon McVittie 2011-09-27 11:02:29 UTC
Created attachment 51673 [details] [review]
[1/6 v2] Tidy up docs for DBusGError and its pseudo-methods

* attach the introductory doc-comments to the enum and macro names,
  not the internal function
* remove docs for method parameters which didn't actually exist
* more cross-references
* make the domain macro visible in the documentation index

---

Fixed according to Cosimo's comments regarding % and iff
Comment 32 Simon McVittie 2011-09-27 11:03:45 UTC
Created attachment 51674 [details] [review]
[2/6] dbus-gtype-specialized: warn if vtables have missing callbacks

It's just about conceivable that they wouldn't segfault, if application
authors carefully avoided the unimplemented functionality... but still.

---

I noticed while fixing the documentation that most functions dereference struct members without checking. That's fine, but we should check it *somewhere*.
Comment 33 Simon McVittie 2011-09-27 11:04:38 UTC
Created attachment 51676 [details] [review]
[3/6] dbus_g_type_collection_get_fixed: check preconditions on the type and vtable

Previously, if it wasn't a collection or didn't have the fixed_accessor,
we'd just segfault. Not ideal.

---

Also noticed while fixing Cosimo's review comments.
Comment 34 Simon McVittie 2011-09-27 11:05:47 UTC
Created attachment 51677 [details] [review]
[4/6] dbus_g_type_collection_value_iterate, etc.: check that  the type is suitable

Otherwise we'd probably crash when we cast the vtable to an inappropriate
type, and call its methods with inappropriate arguments as a result.

---

Like Attachment #51676 [details] but for the other functions, which call callbacks whose existence is checked in Attachment #51674 [details].
Comment 35 Simon McVittie 2011-09-27 11:06:37 UTC
Created attachment 51679 [details] [review]
[5/6] specialized types: improve documentation and document  more things

---

Many changes since Attachment #47392 [details], please re-review.
Comment 36 Simon McVittie 2011-09-27 11:07:05 UTC
Created attachment 51680 [details] [review]
[6/6] Fix various minor documentation bugs
Comment 37 Simon McVittie 2011-09-27 11:08:57 UTC
I applied the patches that Cosimo approved. With these new 6 patches applied, we have almost 100% documentation coverage.

The only missing thing now is documentation for the members of DBusGError.
Comment 38 Cosimo Alfarano 2011-09-28 03:39:26 UTC
Re-reviewed and they look all ok :)
Comment 39 Simon McVittie 2011-09-28 09:53:02 UTC
Thanks, fixed in git for 0.98.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.