Issue 9695 - Ddoc should emit enum member initializers
Summary: Ddoc should emit enum member initializers
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: Andrej Mitrovic
URL:
Keywords: ddoc, pull
Depends on:
Blocks:
 
Reported: 2013-03-11 21:19 UTC by Andrej Mitrovic
Modified: 2017-10-28 15:35 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrej Mitrovic 2013-03-11 21:19:11 UTC
Example:

module test;
/** */
enum E : char
{
    /** */
    one = '1',

    /** */
    two = '2',
}

$ dmd -D -o- test.d

The initializers are not present, but for documentation purposes they really should be.

The question is whether to do it for all initializers, or only for user-provided initializers (if that's even possible to do at the ddoc generation stage).
Comment 1 Andrej Mitrovic 2013-03-19 21:55:25 UTC
https://github.com/D-Programming-Language/dmd/pull/1771
Comment 2 Walter Bright 2013-03-21 22:23:08 UTC
I don't see the rationale for why the initializers must be present in Ddoc. I think that violates the principle of hiding implementation details.
Comment 3 Andrej Mitrovic 2013-03-22 15:10:45 UTC
(In reply to comment #2)
> I don't see the rationale for why the initializers must be present in Ddoc. I
> think that violates the principle of hiding implementation details.

This only applies to documented members. Anyway I'll bring this up in the newsgroups to see if it's wanted by other people.
Comment 4 Andrej Mitrovic 2013-03-22 15:17:40 UTC
(In reply to comment #2)
> I don't see the rationale for why the initializers must be present in Ddoc. I
> think that violates the principle of hiding implementation details.

I've got an idea: How about we emit the initializer inside a new macro (say MEMBERINIT), which by default is set to output nothing.

Then a user could override this in his own .ddoc file to emit the initializer.
Comment 5 Andrej Mitrovic 2014-02-03 05:58:56 UTC
Marking as WONTFIX, although for JSON we'll probably have to introduce initializers to the output to allow DTOH to emit proper C++ header code.
Comment 6 Timothee Cour 2017-02-10 06:10:28 UTC
This causes issues because of https://issues.dlang.org/show_bug.cgi?id=129 (DDoc downgrades enum to their integer initializers); I also discuss this in https://issues.dlang.org/show_bug.cgi?id=17171
Comment 7 Andrew Edwards 2017-10-28 15:35:48 UTC
Returning to WONTFIX status. See issue 9695 comment 6 for rationale.