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 736483 - Single-Line document comments not supported
Single-Line document comments not supported
Status: RESOLVED FIXED
Product: valadoc
Classification: Other
Component: libvaladoc/parser
git master
Other Linux
: Normal normal
: ---
Assigned To: valadoc-maint
valadoc-maint
Depends on:
Blocks:
 
 
Reported: 2014-09-11 14:41 UTC by Nathan Lowe
Modified: 2018-01-09 13:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add support for single line documentation comments (2.68 KB, patch)
2018-01-09 01:42 UTC, Michael Gratton
committed Details | Review

Description Nathan Lowe 2014-09-11 14:41:31 UTC
Valadoc does not appear to support single line documentation comments, eg: 

/** The parent object this object belongs to */
public weak A parent{get; private set;}
Comment 1 Nathan Lowe 2014-09-11 14:42:27 UTC
Valadoc 0.23.2
Comment 2 Michael Gratton 2016-12-30 02:43:43 UTC
This is a very convenient form for single line properties, so I have been looking into a fix. Here's an example, using valadoc rebuilt with DEBUG and DEBUG_HARD:

> rfc822.vala:9.4-9.10: error: expected <end-of-line>: Common
> * Common text formats supported by {@link Geary.RFC822}. 
>    ^^^^^^                                                 
> An error occured while parsing: expected <end-of-line>: Common
> 
> Dumping rule stack:
> 	 0: Comment        [seq]          (index=0/3)

The immediate problem seems to be the Comment rule in documentationparser.vala, which does indeed require an EOL up front:

>  		Rule comment =
> 			Rule.seq ({
> 				TokenType.EOL,
>  				Rule.option ({
>  					description
>  				}),
> ...

That can be changed to make the initial EOL optional:

> 		Rule comment =
> 			Rule.seq ({
> 				Rule.option ({
> 					TokenType.EOL,
> 				}),
> ...

But then the parser will complain about the EOF instead:

> rfc822.vala:9.59-9.59: error: unexpected token: <end-of-file>
> * Common text formats supported by {@link Geary.RFC822}. 
>                                                           
> An error occured while parsing: unexpected token: <end-of-file>
> 
> Dumping rule stack:
> 	 0: Comment        [seq]          (index=2/3)
> 	 1:                [option]       (started=true)
> 	 2: Description    [seq]          (index=1/2)
> 	 3: Blocks         [one-of]       (selected=5/6)
> 	 4: Paragraph      [seq]          (index=2/2)
> 	 5:                [many]         (started=true;done_one=true)
> 	 6:                [seq]          (index=1/2)
> 	 7: Run            [seq]          (index=3/3)
> 	 8:                [option]       (started=true)
> 	 9:                [many]         (started=true;done_one=true)
> 	10:                [one-of]       (selected=1/3)
> 	11:                [one-of]       (selected=0/2)
> 	12:                [seq]          (index=1/1)
> 	13: Text           [many]         (started=true;done_one=true)

Adding a further optional EOF to Comment (also tried Description and a few others), or getting a \n inserted on EOF seems to break parsing all comments, with the following:

> An error occured while parsing: Rule stack is not empty!

So I'm not sure where to go from here, any pointers?
Comment 3 Michael Gratton 2016-12-30 02:49:44 UTC
CC'ing Florian and Didier for some advice, since they seem to have written most of that class.
Comment 4 Didier "Ptitjes" 2016-12-30 10:47:50 UTC
Hi Nathan and Michael,
I don't have a computer at hand these days. I'll take a look at it on Monday evening or next week if you did not find a fix before.
Comment 5 Florian Brosch 2017-01-01 20:51:02 UTC
Hey guys,

there is a similar issue at the end if I recall it correctly. I think the easiest solution is to build a new rule based on `run` and apply it to single-line documentation comments.
Comment 6 Michael Gratton 2018-01-09 01:42:07 UTC
Created attachment 366525 [details] [review]
Add support for single line documentation comments

Patch adds support for single line comments, using Florian's suggestion to base a new rule off the Run rule.

It should be pretty safe to commit, since it only is triggered if the original form starting with a LF does not apply.

This fixes all instances of the issue in Geary's codebase.
Comment 7 Rico Tzschichholz 2018-01-09 13:09:52 UTC
commit 45792e40c2acb2f19e3124d2f41632f044c1158d
Author: Michael James Gratton <mike@vee.net>
Date:   Tue Jan 9 12:30:50 2018 +1100

    libvaladoc: Add support for single line documentation comments