Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 5446 - Ddoc doesn't output aliased names #1209

Merged
merged 1 commit into from Oct 27, 2012
Merged

Fix Issue 5446 - Ddoc doesn't output aliased names #1209

merged 1 commit into from Oct 27, 2012

Conversation

ghost
Copy link

@ghost ghost commented Oct 23, 2012

http://d.puremagic.com/issues/show_bug.cgi?id=5446

This is a fix to output aliased symbols when generating documentation. I've tried to make the output look nice but at the same time semantically valid.

I've implemented the prettyPrintDsymbol function for better pretty printing because calling toPrettyChars will print the module name together with the symbol name and in most cases this creates a very noisy output. Instead toPrettyChars is only used when the aliased symbol is from another module, since this is required to output aliases like this:

deprecated alias core.cpuid.vendor vendor; 

Which is better than just deprecated alias vendor vendor since that is ambiguous to the reader.

@@ -877,7 +877,56 @@ void Declaration::toDocBuffer(OutBuffer *buf)
declarationToDocBuffer(this, buf, NULL);
}

void AliasDeclaration::toDocBuffer(OutBuffer *buf)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line shouldn't change.

Add missing else clause.

Rebase and fix html.
@ghost
Copy link
Author

ghost commented Oct 27, 2012

Retesting now.

yebblies added a commit that referenced this pull request Oct 27, 2012
Fix Issue 5446 - Ddoc doesn't output aliased names
@yebblies yebblies merged commit 1e3b6d9 into dlang:master Oct 27, 2012
@ghost
Copy link
Author

ghost commented Oct 27, 2012

I forgot to ask @andralex if he's ok with this change, in particular if the way ddoc looks with this change is ok. We can easily amend things of course. :)

@ghost
Copy link
Author

ghost commented Oct 29, 2012

I've noticed a small issue w.r.t. templated function aliases:

alias listDir(C) listdir; 

listDir is a templated function. This is a result of a toChars() call on a TemplateDeclaration, toPrettyChars() does a similar thing.

Do any code paths rely on specific behavior for toChars? If not I could change how TemplateDeclaration prints itself. Otherwise I'll have to add checks in ddoc and use:

TemplateDeclaration *td = s->isTemplateDeclaration();
if (td)
    buf->writestring(td->ident->toChars());
else
    buf->writestring(s->toChars());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants