We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 45cdb63 commit 12dd415Copy full SHA for 12dd415
torch/_torch_docs.py
@@ -1,5 +1,7 @@
1
"""Adds docstrings to functions defined in the torch._C"""
2
3
+import re
4
+
5
import torch._C
6
from torch._C import _add_docstr as add_docstr
7
@@ -14,8 +16,9 @@ def parse_kwargs(desc):
14
16
'weight (Tensor): a weight tensor\n Some optional description'
15
17
}
18
"""
- # Split by indents. Assumes each arg starts on a new line with 4 spaces.
- kwargs = [section.strip() for section in desc.split('\n ')]
19
+ # Split on exactly 4 spaces after a newline
20
+ regx = re.compile("\n\s{4}(?!\s)")
21
+ kwargs = [section.strip() for section in regx.split(desc)]
22
kwargs = [section for section in kwargs if len(section) > 0]
23
return {desc.split(' ')[0]: desc for desc in kwargs}
24
0 commit comments