After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 380824 - docs are truncated if line begins with '* returns '
docs are truncated if line begins with '* returns '
Status: RESOLVED FIXED
Product: gtk-doc
Classification: Platform
Component: general
1.8
Other Linux
: Normal normal
: 1.9
Assigned To: gtk-doc maintainers
gtk-doc maintainers
Depends on:
Blocks:
 
 
Reported: 2006-11-30 09:49 UTC by Stefan Sauer (gstreamer, gtkdoc dev)
Modified: 2007-09-22 19:15 UTC
See Also:
GNOME target: 2.20.x
GNOME version: ---


Attachments
proposed patch (2.37 KB, patch)
2007-07-09 19:08 UTC, Yeti
none Details | Review
proposed patch (warning) (581 bytes, patch)
2007-07-09 19:11 UTC, Yeti
none Details | Review
proposed patch (3.29 KB, patch)
2007-07-09 20:14 UTC, Yeti
none Details | Review
proposed patch (cumulative) (3.70 KB, patch)
2007-07-11 14:48 UTC, Yeti
committed Details | Review
patch (1.06 KB, patch)
2007-07-16 08:24 UTC, Yeti
committed Details | Review

Description Stefan Sauer (gstreamer, gtkdoc dev) 2006-11-30 09:49:08 UTC
* Returns: %TRUE if the value could be set correctly. If there was no field
 * with @fieldname or the existing field did not contain an int, this function
 * returns %FALSE.

In the above example, gtk-doc needs to check if it is already in a 'returns' statement.
Comment 1 Damon Chaplin 2006-12-17 12:09:37 UTC
This was actually done deliberately, to handle the original GNOME docs which
were a bit ambiguous. So any "Returns" found at the start of the line is assumed
to document the return value, and any previous "Returns" found is assumed to be
part of the function documentation.

We could improve it slightly by assuming that any "Returns" with a ":" after
it is definitely the return value documentation.

Comment 2 Björn Lindqvist 2007-06-19 22:40:33 UTC
IMHO, that behavior is really irritating and the GNOME docs should be fixed to use more stringent syntax instead. Often you describe a function by writing "Returns the value of foo if bar ..." and gtk-doc incorrectly assumes that that is the description for the return value. I think it only should use @returns for that.
Comment 3 Matthias Clasen 2007-06-20 01:49:09 UTC
Good luck fixing all the gnome docs to use a more stringent syntax. Come back when you are done...

@returns works if you prefer to use that, btw.
Comment 4 Yeti 2007-07-08 15:37:21 UTC
(In reply to comment #3)
> Good luck fixing all the gnome docs to use a more stringent syntax. Come back
> when you are done...

Give me the list of packages you consider `all gnome', i.e. that have to be fixed before we can finally get rid of this rubbish.  I looked at some and it isn't so bad.  I assume deprecated stuff needs no fixing as no information is lost, the return value description will just move to the body, which should be good enough for functions no one should use anyway.
Comment 5 Matthias Clasen 2007-07-09 04:43:32 UTC
It is also a matter of fitting in, imo. Stylistically,

"Return value: bla bla"

looks much nicer in doc comment in the source code than

" @returns: balbla" 

hidden in the parameter list
Comment 6 Stefan Sauer (gstreamer, gtkdoc dev) 2007-07-09 05:45:26 UTC
The form that should be used in the source is:

* ...
*
* Returns: the byte size, or 0 if there was an error
*
*/
Comment 7 Matthias Clasen 2007-07-09 05:53:10 UTC
Ah, right. I see what is being complained about here. I think Damons proposal
is a good one, to give any "return line start" that ends with a : a higher
priority than one without a :.
Comment 8 Yeti 2007-07-09 07:19:03 UTC
(In reply to comment #7)
> Ah, right. I see what is being complained about here. I think Damons proposal
> is a good one, to give any "return line start" that ends with a : a higher
> priority than one without a :.

Is is necessary to complicate it further?

Matthias, I don't see the `old Gnome documentation' argument backed by any hard data.  It is easy to obtain it: build the documentation with and without accepting bare Returns in the parser and diff foo-undocumented.txt (where new `foo_blow_up (Returns)' will show up).  It just takes lots of CPU time.  With this data, one can actually weigh the impact and also fill bugs and fix the documentation.  So please give me the list of packages that have to be fixed to enable switch to the stricter syntax.

Comment 9 Damon Chaplin 2007-07-09 09:38:05 UTC
I wouldn't want to break backwards compatability though. We don't know all the
places where gtk-doc is used.

Anyway, if we say that explicit "Returns:" has the highest priority the problem
will only affect people with ambiguous documentation.
Comment 10 Yeti 2007-07-09 09:47:18 UTC
(In reply to comment #9)
> I wouldn't want to break backwards compatability though. We don't know all the
> places where gtk-doc is used.

OK, so let's at least start producing warnings on free-form Returns as suggested in bug 322035.  This will enable us to actually remove the support for them in the future.

(Also note nothing terrible will happen to the old Returns, they will just move to the description body.)
Comment 11 Yeti 2007-07-09 19:08:03 UTC
Created attachment 91511 [details] [review]
proposed patch

Implements basic Returns priorities: old style Returns block cannot break sane Returns block.

I don't like how old-style Returns can still break *other blocks* though.
Comment 12 Yeti 2007-07-09 19:11:37 UTC
Created attachment 91512 [details] [review]
proposed patch (warning)

To be applied on top of patch 91511.

Adds a warning when old-style Returns is found and no new style one, i.e. if after all parsing all we got is an old-style Returns.
Comment 13 Yeti 2007-07-09 20:14:46 UTC
Created attachment 91514 [details] [review]
proposed patch

Patch 91511 is incomplete.  We should also catch the situation when we find a free-form Returns in the description and we already have a strict Returns.
Comment 14 Stefan Sauer (gstreamer, gtkdoc dev) 2007-07-10 20:27:27 UTC
Thanks for the patch! I run it against gstreamer and buzztard. Now isuues found. I am fixing the few warnings it spotted.

+1 from my side to get this committed.
Comment 15 Stefan Sauer (gstreamer, gtkdoc dev) 2007-07-11 07:42:28 UTC
When I build gst-plugin-base docs from CVS I get:
Use of uninitialized value in concatenation (.) or string at /usr/bin/gtkdoc-mkdb line 2985, <SRCFILE> line 95.

I added:
	if ($in_since) {
	    if (m%^\s*(returns:|return\s+value:|returns\b\s*)%i) {
                 if (! defined $return_start) {
                   print "!!! no return_start\n";
                 }
                 if (! defined $return_desc) {
                   print "!!! no return_desc\n";
                 }
                 if (! defined $description) {
                   print "!!! no description\n";
                 }
		$description .= $return_start . $return_desc;
		$return_start = $1;

and it says "!!! no return_start".
Comment 16 Yeti 2007-07-11 14:43:16 UTC
(In reply to comment #15)
> When I build gst-plugin-base docs from CVS I get:
> Use of uninitialized value in concatenation (.) or string at
> /usr/bin/gtkdoc-mkdb line 2985, <SRCFILE> line 95.

I can reproduce this problem, but it occurs regardless my patch is applied or not.  It even occurs with stock gtk-doc-1.8.

It looks like a bit too much liberal application of copy'n'paste.  I can't see any reason why anything should be done with $return_start if we are not $in_return, but $in_since or $in_stability instead.
Comment 17 Yeti 2007-07-11 14:48:10 UTC
Created attachment 91625 [details] [review]
proposed patch (cumulative)

Comment 15 is probably a separate problem.  The fix touches the same lines, so I attach a single patch that contains the two previous and fixes comment 15 as well.
Comment 18 Stefan Sauer (gstreamer, gtkdoc dev) 2007-07-12 05:49:45 UTC
Its not fixed, but I found the fix needed for gtkdoc-mkdb.in:

@@ -2830,7 +2831,9 @@
                $in_since = 0;
                $in_deprecated = 0;
                $description = "";
+               $return_start = "";
                $return_desc = "";

could you please add this to your patch?
Comment 19 Stefan Sauer (gstreamer, gtkdoc dev) 2007-07-15 09:13:10 UTC
2007-07-15  Stefan Kost  <ensonic@users.sf.net>

	Patch by: Yeti <yeti@physics.muni.cz>

	* gtkdoc-mkdb.in:
	Improve handling of legacy "return" statement doc parsing. Warn about
	those. 
Comment 20 Stefan Sauer (gstreamer, gtkdoc dev) 2007-07-15 10:03:57 UTC
The fix has a sideeffect still. See new bug #457077.
Comment 21 Yeti 2007-07-16 08:20:46 UTC
I'm confused.   I got some conflicts on svn up and it seems the

$description .= $return_start . $return_desc;

statements in non-$in_return branches are still there.  It seems what I attached as patch 91625 in comment 17 was not the final revision, I'm sorry.

Now, to comment 18: In my opinion this is wrong and it only hides the real problem: manipulation with $return_start where it makes no sense at all.
Comment 22 Yeti 2007-07-16 08:24:14 UTC
Created attachment 91846 [details] [review]
patch

This is what was missing. Note it removes both the initialization of $return_start and its bad accesses (if there are more bad accesses, we will see them as it's kept uninitialized).
Comment 23 Behdad Esfahbod 2007-08-08 23:13:00 UTC
For the record, I've been hit by this too.  I have had to reword function description to make gtk-doc pick it up, instead of parsing to return-value lines...
Comment 24 Stefan Sauer (gstreamer, gtkdoc dev) 2007-08-09 07:32:25 UTC
@Behdad, can you retry with gtkdoc from svn trunk? If it still happens, please reopen the bug.
Comment 25 Stefan Sauer (gstreamer, gtkdoc dev) 2007-08-13 06:41:42 UTC
It still happens. Will look into this later

/**
 * gst_adapter_take_buffer:
 * @adapter: a #GstAdapter
 * @nbytes: the number of bytes to take
 *
 * Returns a #GstBuffer containing the first @nbytes bytes of the
 * @adapter. The returned bytes will be flushed from the adapter.
 * This function is potentially more performant than gst_adapter_take() 
 * since it can reuse the memory in pushed buffers by subbuffering
 * or merging.
 *
 * Caller owns returned value. gst_buffer_unref() after usage.
 *
 * Since: 0.10.6
 *
 * Returns: a #GstBuffer containing the first @nbytes of the adapter, 
 * or #NULL if @nbytes bytes are not available
 */
Comment 26 Stefan Sauer (gstreamer, gtkdoc dev) 2007-08-13 07:36:58 UTC
When ever we parse a broken return, we need to remember which part we were parsing (in_since, in_description,...). If we encounter a real Returns: we have to append that broken return to the docs it belongs to (since_desc, description, ...).
Comment 27 Stefan Sauer (gstreamer, gtkdoc dev) 2007-08-13 08:36:42 UTC
Lazy fix that assumes that since/deprecated/stability won't start with 'returns '.

2007-08-13  Stefan Kost  <ensonic@users.sf.net>

	* gtkdoc-mkdb.in:
	  Now the 'broken' returns seems to work better. Fixes #380824 more.