Bug 644 – Ddoc: aliases used as parameters/fields revert to base type in generated docs.
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-12-04T02:45:00Z
Last change time
2014-02-15T13:20:24Z
Keywords
ddoc
Assigned to
bugzilla
Creator
tomas
Comments
Comment #0 by tomas — 2006-12-04T02:45:26Z
/// Alias for something
alias something A;
/// Some function
void func(A a);
---------------------
The above will generate docs like:
alias A;
void func(something a);
Comment #1 by tomas — 2006-12-06T09:00:21Z
In my case this is problematic because:
// code
version(Windows) alias HWND WindowPeer;
else version(Motif) alias Widget WindowPeer;
else version(GTK) alias GtkWidget* WindowPeer;
// docs
alias void* WindowPeer;
---------------------------
In the docs all occurences of WindowPeer is replaced with void* :/
A workaround is to do:
typedef void* WindowPeer_;
alias WindowPeer_ WindowPeer;
This is better but the name will never be correct.
If I just do
typedef void* WindowPeer;
I can't have the alias documented correctly as an alias!
Comment #2 by tomas — 2006-12-12T15:16:45Z
I definitely think we need some more control over how aliases are documented.
Consider this code:
import std.string;
///
alias char[] Foo;
///
alias int Bar;
///
Foo func(Bar b)
{
return toString(b);
}
This will be documented as:
alias Foo;
alias Bar;
char[] func(int);
Here if the proposed bug is fixed would become:
alias Foo;
alias Bar;
Foo func(Bar);
In the first example the docs show two aliases but it's impossible to see where they are used.
In the second example the docs show two aliases and a function that uses them, but it doesn't given any kind of clue as to what Foo and Bar might be.
I propose something like this...
--------------------------------------------
/// some alias
alias char[] Foo;
/// some function
Foo func(Foo);
becomes:
alias Foo;
some alias
char[] func(char[]);
some func
--------------------------------------------
/// some alias
/// KeepAlias:
alias char[] Foo;
/// some func
Foo func(Foo);
becomes:
alias char[] Foo;
some alias
Foo func(Foo);
some func
--------------------------------------------
/// some alias
/// RefsKeepAlias:
alias char[] Foo;
/// some func
Foo func(Foo);
becomes:
alias Foo;
some alias
Foo func(Foo);
some func
--------------------------------------------
The last one is needed when the alias is dependent on conditional compilation. In those cases I think it's better to put the different things the alias can be in the alias's description.
Comment #3 by matti.niemenmaa+dbugzilla — 2007-06-18T03:22:08Z
*** Bug 1271 has been marked as a duplicate of this bug. ***
Comment #4 by andrej.mitrovich — 2013-01-13T11:48:10Z
Works in 1.076 and 2.061. D2 will additionally export aliases (See Issue 5446).