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