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

Display deprecated label when @[Deprecated] is used #7653

Merged

Conversation

bcardiff
Copy link
Member

@bcardiff bcardiff commented Apr 8, 2019

Depends on #7652 (marked as draft until merged)

The last commit of the PR adds support of the doc generator tool to understand the @[Deprecated] and emit the same label that is currently emitted when a # DEPRECATED: ... comment is found.

Even before this PR the labels are only emitted for methods. But the implementation will be ready to handle them once other annotations are preserved by the parser/compiler.

Show me a sample (with screenshot)

Given the following code:

module FOO
  # DEPRECATED: Use `Bar` instead1
  @[Deprecated("Use `Bar` instead2", "sdfs")]
  class Foo
    # DEPRECATED: Use `VAL_B` instead1
    @[Deprecated("Use `VAL_B` instead2")]
    VAL_A = 10
    VAL_B = 20

    # DEPRECATED: Use `#bar` instead1
    @[Deprecated("Use `#bar` instead2")]
    def foo
    end

    # DEPRECATED
    @[Deprecated]
    def foo2
    end

    def bar
    end

    # DEPRECATED: Use `#qux` instead1
    @[Deprecated("Use `#qux` instead2")]
    macro baz
    end

    macro qux
    end
  end

  class Bar
  end
end

This is the generated output:

screencapture-file-Users-bcardiff-Projects-crystal-master-docs-FOO-Foo-html-2019-04-08-17_50_00

@bcardiff bcardiff force-pushed the feature/deprecation-docs-tool branch from 14c1722 to 131aab0 Compare April 10, 2019 22:09
@bcardiff bcardiff marked this pull request as ready for review April 10, 2019 22:10
Copy link
Member

@straight-shoota straight-shoota left a comment

Choose a reason for hiding this comment

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

Injecting annotations into the markdown string looks like a cheap hack.
But should be fine for now.

@bcardiff
Copy link
Member Author

Yes @straight-shoota I agree. It's cheap.

Merging this will mean that the time deprecation does not need to be in the comments 🚀

@bcardiff bcardiff merged commit 9871f43 into crystal-lang:master Apr 11, 2019
@bcardiff bcardiff added this to the 0.28.0 milestone Apr 11, 2019
@bcardiff bcardiff deleted the feature/deprecation-docs-tool branch April 11, 2019 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants