D-Programming-Language/dmd — pull request #1168 by AndrejMitrovic (2012-10-06 03:16:10+00:00)
Title: Fix Issue 5446 - Ddoc doesn't output aliased names 

This is an experimental pull to output aliased symbols to ddoc. I'd like to get suggestions before we even try to pull this.

I've tried to make the output look nice but at the same time semantically valid.
Aliases to symbols in imported modules look like this in ddoc:

```
alias deprecated alias core.cpuid.vendor vendor;
````

Module-scoped aliases look like so:

```
alias symb alSymb
alias nest.symb alNestSymb
```

And aliases which are nested themselves have a dot prefix to avoid any ambiguity, e.g.:

```
struct Foo {
struct Bar {
alias Foo foo; => alias .Foo foo
}
}
```

The implementation could use improvement. For one thing, calling `toDsymbol` crashes the compiler when `type->ty is of some special type such as an alias of a typeof() expression, so I've added checks, but there might be more required.

I've implemented the `printRetroTree` function because calling `toPrettyChars` will print the module name together with the symbol name, but this creates a very noisy output. `toPrettyChars` is only used when the aliased symbol is from another module, and this is required to output aliases like this:

```
deprecated alias core.cpuid.vendor vendor;
```

Which is better than `deprecated alias vendor vendor`.

I also need to add some more ddoc tests. But for now I'd like to hear about suggestions/bugs in the implementation.