Skip to content

chore: filter alias exports in docs #8782

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

Merged

Conversation

devversion
Copy link
Member

@devversion devversion commented Dec 3, 2017

Let's consider this example:

  export {ObserveContent} from './X';

  /** @deprecated */
  export {ObserveContent as CdkObserveContent} from './X';

This is a common pattern inside of Angular Material, but causes Dgeni to generate documents for both exports.

The second document is identical to the original Dgeni document and doesn't even show the aliased name. It would be useful to have a property that indicates that the given doc is an alias and maybe also refer to the original document.

This commit introduces a processor that removes the duplicate documents from the docs.

Related: angular/dgeni-packages#248 (already chatted with Pete about it).

Fixes #8693

Let's consider this example:

  export {ObserveContent} from './X';

  /** @deprecated */
  export {ObserveContent as CdkObserveContent} from './X';

This is a common pattern inside of Angular Material, but causes Dgeni to generate documents for both exports.

The second document is identical to the original Dgeni document and doesn't even show the aliased name. It would be useful to have a property that indicates that the given doc is an alias and maybe also refer to the original document.

This commit introduces a processor that removes the duplicate documents from the docs.

Fixes angular#8693
@devversion devversion requested a review from jelbourn as a code owner December 3, 2017 12:50
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Dec 3, 2017

// Remove the current export document if there are multiple Dgeni export documents with the
// same document id. If there are multiple docs with the same id, we can assume that this doc
// is an alias export.
Copy link
Member

Choose a reason for hiding this comment

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

Is there any way to more specifically target things marked as @deprecated? It's possible we may want to re-export something not as a deprecation, but as an alternate name (e.g. re-exporting something from cdk with "mat").

Copy link
Member Author

Choose a reason for hiding this comment

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

I see. Unfortunately it's not possible to detect if the re-export was marked as deprecated.

/** @deprecated */
export {XX as PP} from './test';

Dgeni doesn't provide access to the export statement/symbol. In theory it would be possible to walk through imports file by file using the AST, but this more turns into it's own docs generation tool then.

I assume even Dgeni in general (with angular/dgeni-packages#248) won't be able to differentiate between deprecated re-exports or normal re-exports.

Copy link
Member

Choose a reason for hiding this comment

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

What if we formatted it like this?

export {XX as /** @deprecated */ PP} from './test';

Copy link
Member Author

Choose a reason for hiding this comment

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

Just tried that, but that information is being lost as well.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM as a workaround until dgeni has a proper fix

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Dec 13, 2017
@josephperrott josephperrott merged commit 291f6cf into angular:master Dec 20, 2017
josephperrott pushed a commit to josephperrott/components that referenced this pull request Jan 2, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicated content in CDK Observers API docs
4 participants