Force document private methods/functions
PiperOrigin-RevId: 338486134 Change-Id: I62efc520652e6db7d5f84cbfc55a6def48f5be4f
This commit is contained in:
parent
d85a67ef53
commit
7dd6c9976f
@ -250,3 +250,34 @@ def for_subclass_implementers(obj):
|
||||
|
||||
|
||||
do_not_doc_in_subclasses = for_subclass_implementers
|
||||
|
||||
_DOC_PRIVATE = "_tf_docs_doc_private"
|
||||
|
||||
|
||||
def doc_private(obj):
|
||||
"""A decorator: Generates docs for private methods/functions.
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
class Try:
|
||||
|
||||
@doc_controls.doc_private
|
||||
def _private(self):
|
||||
...
|
||||
```
|
||||
|
||||
As a rule of thumb, private(beginning with `_`) methods/functions are
|
||||
not documented.
|
||||
|
||||
This decorator allows to force document a private method/function.
|
||||
|
||||
Args:
|
||||
obj: The class-attribute to hide from the generated docs.
|
||||
|
||||
Returns:
|
||||
obj
|
||||
"""
|
||||
|
||||
setattr(obj, _DOC_PRIVATE, None)
|
||||
return obj
|
||||
|
Loading…
Reference in New Issue
Block a user