Update How to deprecate authored by Julien Michel's avatar Julien Michel
So you want to deprecate something in OTB? Follow the guide: So you want to deprecate something in OTB? Follow the guide:
#### A C++ class (WIP) #### A C++ class
In the doxygen documentation of the class, add the `\deprecated` keyword. In the doxygen documentation of the class, add the `\deprecated` keyword.
In the class declaration, use the `[[deprecated]]` attribute. If the class declaration already has an export macro, use the macro `_DEPRECATED_EXPORT`. #### A method of a C++ class or free function
#### A method of a C++ class (WIP) In the doxygen documentation of the method, add the `\deprecated` keyword.
Use the `[[deprecated]]` attribute. #### A part of the Python API
#### A part of the Python API (WIP)
#### An OTB application
#### An OTB application (WIP) Add the deprecated tag to `DoInit()` section:
Add the tag deprecated:
``` ```
AddDocTag(Tags::Deprecated); AddDocTag(Tags::Deprecated);
...@@ -40,8 +38,7 @@ otb_module(OTBDeprecatedModuleName ...@@ -40,8 +38,7 @@ otb_module(OTBDeprecatedModuleName
"${DOCUMENTATION}" "${DOCUMENTATION}"
) )
``` ```
One need to make sure that the deprecated module is not a mandatory dependency of any other module. One can still allow the module to be used thanks to the `OPTIONAL_DEPENDS` key word :
One need to make sure that the deprecated module is not a mandatory dependency of any other module. One can still allow the module to be use thanks to the `OPTIONAL_DEPENDS` key word :
```CMake ```CMake
set(DOCUMENTATION "Some documentation") set(DOCUMENTATION "Some documentation")
otb_module(OTBDModuleName otb_module(OTBDModuleName
...@@ -61,12 +58,4 @@ otb_module(OTBDModuleName ...@@ -61,12 +58,4 @@ otb_module(OTBDModuleName
) )
``` ```
Please make sure that all of the classes in the module have the `ModuleName_DEPRECATED_EXPORT` and the Doxygene tag `\deprecated`. Please make sure that all of the classes, methods and free functions in the module have the `ModuleName_DEPRECATED_EXPORT` and the Doxygene tag `\deprecated`.
#### How to disable deprecated features when `OTB_USE_DEPRECATED=OFF`?
For an example, see [this MR](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/merge_requests/236/diffs)
* If you deprecate a whole module, it will be disabled during configure step.
* If you want to deprecate a C++ class and the associated tests: use variable `OTB_USE_DEPRECATED` to protect the inclusion of this class in `src/CMakeLists.txt` and `test/CMakeLists.txt`
* in otbConfigure.h, there is a macro `OTB_USE_DEPRECATED`, which is defined when CMake option `OTB_USE_DEPRECATED=ON`. Use it to disable portions of code in `test/otbXXXTestDriver.cxx` for instance