google / google/python-fire

Multiline docstring in help with parameters and their descriptions

未關閉
#181 7 則留言 5 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
28.2k
分支
1.5k
PR 合併指標
30 天內沒有已合併 PR

描述

I'm using the [latest version](https://github.com/google/python-fire/commit/024fbad9424cfdb0d3c93c86c856aedbac0f9d48) of Fire as of now and was wondering if it's possible to display a multiline docstring in help instead of concatenating it to one line. Also is there a way of displaying the available params and their descriptions in the help screen?

Example program:
```python
# main.py
import fire

class MyCLI:
def create(name, surname):
"""
Method to create a user \n
And some second line to describe some specific cases.
And some third line that could be concatenated with the second one
:param name name of the user
:param surname surname of the user
:raises ValueError if user with this name and surname already exist
:returns: unique id of the created user
"""
...

def remove(id):
"""
Removes user given the id
:id unique id to identify the user
:raises ValueError if there is no user with the specified id
"""
...

if __name__ == '__main__':
cli = MyCLI()
fire.Fire(cli)
```

Expected help:
```bash
main.py -h

NAME
main.py -

SYNOPSIS
main.py COMMAND

COMMANDS
COMMAND is one of the following:

create
Method to create a user
And some second line to describe some specific cases. And some third line that could be concatenated with the second one

remove
Removes user given the id
```

Example command help (more specific)
```bash
main.py create -h

NAME
main.py create - Method to create a user

SYNOPSIS
main.py create NAME SURNAME

DESCRIPTION
Method to create a user
And some second line to describe some specific cases. And some third line that could be concatenated with the second one
--name: name of the user
--surname: surname of the user
raises ValueError if user with this name and surname already exist
returns: unique id of the created user

POSITIONAL ARGUMENTS
NAME
SURNAME

NOTES
You can also use flags syntax for POSITIONAL ARGUMENTS
```

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。