The DocstringRemover class as currently implemented does not provide
any functionality to handle cases where docstrings serve a function
other than documentation, such as function decorators. It simply removes
any docstrings it encounters.
However, it is technically possible to adjust it to take into account
instances where docstrings have a functional role. This could be done by
adding additional checks or conditions when the DocstringRemover
encounters a docstring.
This would require some custom logic and understanding of the specific cases you’re trying to handle. In the case of function decorators, one possible approach might be to check if the docstring is followed by a decorator list and in such situation, skip the docstring removal.
However, it should be noted that the use of docstrings as functional elements in the code is not common practice and could lead to confusion. Python’s Zen advises that “Explicit is better than Implicit”. Therefore, using docstrings for anything other than documentation may not be recommended.