Thread overview
[Issue 9472] New: Include comments in ddoc'd unittest blocks
Feb 08, 2013
Andrej Mitrovic
Feb 08, 2013
Jonathan M Davis
Feb 08, 2013
Andrej Mitrovic
Feb 08, 2013
Andrej Mitrovic
Feb 13, 2013
Andrej Mitrovic
February 07, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9472

           Summary: Include comments in ddoc'd unittest blocks
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: hsteoh@quickfur.ath.cx


--- Comment #0 from hsteoh@quickfur.ath.cx 2013-02-07 15:28:47 PST ---
Code:

---
/// A magic function that can do anything
void dotDotDotMagic() { doAnything(); }

/// Example
unittest
{
    // Call the very powerful function that can do anything!
    dotDotDotMagic();
}
---

The comment inside the unittest should be included in the generated DDoc for
dotDotDotMagic().

Alternatively, if we want to be able to put comments inside the unittest block that doesn't get seen by the user, we can require the inner comments to be doc comments as well (i.e., with /// instead of just //).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 08, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9472


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-07 16:26:38 PST ---
I think the issue is that the lexer simply skips over regular non-ddoc comments. I also don't think that statements can have ddoc comments, but only declarations can.

I'm going to need help from Kenji on this one.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 08, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9472



--- Comment #2 from hsteoh@quickfur.ath.cx 2013-02-07 16:31:01 PST ---
I'm OK with requiring that comments to be included in the doc must be ddoc comments, if that makes it easier to implement.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 08, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9472


Jonathan M Davis <jmdavisProg@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg@gmx.com


--- Comment #3 from Jonathan M Davis <jmdavisProg@gmx.com> 2013-02-07 21:44:09 PST ---
> I'm OK with requiring that comments to be included in the doc must be ddoc comments, if that makes it easier to implement.

If we _have_ to do that, then we have to do that, but that's not particularly user-friendly. And you _definitely_ wouldn't want them to show up as ddoc comments (rather than regular comments) in the example because of the confusion that it would cause. I really think that we should try to get it working with regular comments.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 08, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9472



--- Comment #4 from hsteoh@quickfur.ath.cx 2013-02-07 22:15:45 PST ---
Supporting regular comments may require non-trivial modifications to the lexer, though. Lexers by default just skip over comments entirely.

But then again, if we're going to need to retain indentation (because right now that doesn't work either), then we're going to have to modify the lexer anyway, so we might as well throw in comments as well. But I doubt it's going to be pretty, in terms of changes to the lexer code. And there may be lexer performance considerations as well, depending on what needs to be done.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 08, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9472



--- Comment #5 from hsteoh@quickfur.ath.cx 2013-02-07 22:18:18 PST ---
Makes me wonder if this feature should be done the *other* way round: that is, unittest injection from ddoc code snippets. It may be easier going in that direction than the current direction of code -> ddocs, because then you don't have to fight with the lexer to _not_ eat spaces and ignore comments, as it's designed to do.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 08, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9472


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|k.hara.pg@gmail.com         |


--- Comment #6 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-08 04:41:23 PST ---
Actually I came up with an idea this morning, I should be able to implement it today. This will also resolve the other issue about indentation.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 08, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9472


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #7 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-08 06:42:54 PST ---
Caused by same issue as in 9475.

*** This issue has been marked as a duplicate of issue 9475 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 13, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9472



--- Comment #8 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-12 17:36:53 PST ---
(In reply to comment #4)
> Supporting regular comments may require non-trivial modifications to the lexer, though. Lexers by default just skip over comments entirely.

It was actually trivial to fix Issue9472 and Issue9475, see https://github.com/D-Programming-Language/dmd/pull/1641

All that was required was to fetch the end pointer where the unittest body closes, and then we can extract the string. Still waiting for the pull to be reviewed and pulled (I'm hoping it makes it into 2.062 or we'll have a half-baked documented unittest feature in release).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------