deprecations.rst 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. .. _deprecations:
  2. Deprecation Helpers
  3. ===================
  4. FlaskBB publicly provides tools for handling deprecations and are open to use
  5. by plugins or other extensions to FlaskBB. For example if a plugin wants to
  6. deprecate a particular function it could do::
  7. from flaskbb.deprecation import FlaskBBDeprecation, deprecated
  8. class RemovedInPluginV2(FlaskBBDeprecation):
  9. version = (2, 0, 0)
  10. @deprecated(category=RemovedInPluginV2)
  11. def thing_removed_in_plugin_v2():
  12. ...
  13. When used in live code, a warning will be issue like::
  14. warning: RemovedInPluginV2: thing_removed_in_plugin_v2 and will be removed
  15. in version 2.0.0.
  16. Optionally, a message can be provided to give further information about the
  17. warning::
  18. @deprecated(message="Use plugin.frobinator instead.", category=RemovedInPluginV2)
  19. def thing_also_removed_in_plugin_v2():
  20. ...
  21. This will produce a warning like::
  22. warning: RemovedInPluginV2: thing_removed_in_plugin_v2 and will be removed
  23. in version 2.0.0. Use plugin.frobinator instead.
  24. If a decorated function has a docstring, the entire warning message will be
  25. appended to it for introspection and documentation purposes.
  26. Helpers
  27. ~~~~~~~
  28. .. module:: flaskbb.deprecation
  29. .. autoclass:: FlaskBBWarning
  30. .. autoclass:: FlaskBBDeprecation
  31. .. autoclass:: RemovedInFlaskBB3
  32. .. autofunction:: deprecated