You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The approved PEP 257 mentions the so-called "attribute docstrings", which are string literals in the line after where an attribute is defined. These kind of docstrings are supported by a several packages, for example sphinx's autodoc extension.
An example looks like below:
fromdataclassesimportdataclassfromtypingimportOptionalfromdocstring_parserimportparse_from_object@dataclassclassRewardConfig:
""" RewardConfig collects all training arguments related to the [`RewardTrainer`] class. """max_length: Optional[int] =None"""The maximum length of the sequences in the batch. This argument is required if you want to use the default data collator."""gradient_checkpointing: Optional[bool] =True"""If True, use gradient checkpointing to save memory at the expense of slower backward pass."""doc=parse_from_object(RewardConfig)
print(doc.short_description)
print()
foriindoc.params:
print(f"{i.arg_name}, {i.type_name} (default - {i.default})\n{i.description}")
print()
RewardConfig collects all training arguments related to the [`RewardTrainer`] class.
max_length, Optional[int] (default - None)
The maximum length of the sequences in the batch. This argument is required if you want to use the default data collator.
gradient_checkpointing, Optional[bool] (default - True)
If True, use gradient checkpointing to save memory at the expense of slower backward pass.
Copied from https://github.com/rr-/docstring_parser/issues/71#issue-1318744037
An example looks like below:
This appears not supported in the
autodoc
feature of this repo. For example, in TRL our config is https://github.com/huggingface/trl/blob/d608fea0d107d4359f9c03a9d6dd434d292a9f50/trl/trainer/ppo_config.py, but its related docs does not show the documentation.The text was updated successfully, but these errors were encountered: