File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ from __future__ import annotations
2+
3+ from typing import TYPE_CHECKING , TypeVar
4+
5+ if TYPE_CHECKING :
6+ from collections .abc import Callable
7+
8+ from typing_extensions import ParamSpec
9+
10+ P = ParamSpec ("P" )
11+ T = TypeVar ("T" )
12+
13+
14+ def internal (f : Callable [P , T ]) -> Callable [P , T ]:
15+ """
16+ This decorator marks a function as internal
17+ by adding a warning to the docstring of the object.
18+
19+ Note that usage on a method starting with an underscore
20+ has no effect, as sphinx does not document such methods
21+
22+ .. code-block:: python
23+
24+ @internal
25+ def some_private_method(self):
26+ # does some private stuff
27+ ...
28+
29+
30+ @internal # does not do anything, don't use
31+ def _my_second_private_method(self): ...
32+ """
33+ doc : str = f .__doc__ if f .__doc__ is not None else ""
34+ newblockline = "\n "
35+ directive = f".. warning::{ newblockline } "
36+ directive += newblockline .join (
37+ (
38+ "This method is designed for internal use" ,
39+ "and may not stay the same in future versions of Manim" ,
40+ )
41+ )
42+ f .__doc__ = f"{ directive } \n \n { doc } "
43+ return f
You can’t perform that action at this time.
0 commit comments