Finalized format raises
This commit is contained in:
parent
e8c9e130c2
commit
bff6ea4d27
31
gen_docs.py
31
gen_docs.py
|
@ -3,10 +3,8 @@ import scrython
|
||||||
from scrython import *
|
from scrython import *
|
||||||
import re
|
import re
|
||||||
|
|
||||||
def format_args(string):
|
def format_args(string, f):
|
||||||
start = '|arg|type|description|\n|:---:|:---:|:---:|'
|
f.write('|arg|type|description|\n|:---:|:---:|:---:|')
|
||||||
|
|
||||||
print(start)
|
|
||||||
|
|
||||||
arg_list = re.findall(r'(\w*\s*\(\w+[,\s\w]{1,}\):[\w\s\'\\`,.]*[^\w\s\(])', string)
|
arg_list = re.findall(r'(\w*\s*\(\w+[,\s\w]{1,}\):[\w\s\'\\`,.]*[^\w\s\(])', string)
|
||||||
|
|
||||||
|
@ -18,12 +16,30 @@ def format_args(string):
|
||||||
type_and_optional = re.findall(r'(?<=\()\w+[,\s\w]+(?=\))', arg)[0]
|
type_and_optional = re.findall(r'(?<=\()\w+[,\s\w]+(?=\))', arg)[0]
|
||||||
|
|
||||||
if len(type_and_optional) > 1:
|
if len(type_and_optional) > 1:
|
||||||
print('|{}|{}|{}|'.format(arg_name, type_and_optional, description))
|
f.write('|{}|{}|{}|'.format(arg_name, type_and_optional, description))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print('|{}|{}|{}|'.format(arg_name, type_and_optional, description))
|
f.write('|{}|{}|{}|'.format(arg_name, type_and_optional, description))
|
||||||
|
|
||||||
for _class in scrython.__all__:
|
def format_returns(string):
|
||||||
|
if string == 'N/A':
|
||||||
|
return
|
||||||
|
|
||||||
|
def format_raises(string):
|
||||||
|
|
||||||
|
print('## Raises\n')
|
||||||
|
print('|exception type|reason|\n|:---:|:---:|')
|
||||||
|
|
||||||
|
exception_list = re.findall(r'\w+:[\w\s\\\']+[^\s\w:]', string)
|
||||||
|
|
||||||
|
for exception in exception_list:
|
||||||
|
exception_name = re.findall(r'[^:]*', exception)[0]
|
||||||
|
|
||||||
|
exception_description = re.findall(r'(?<=:\s)([\w\s\.\'\\]*)', exception)[0]
|
||||||
|
|
||||||
|
print('|{}|{}|'.format(exception_name, exception_description))
|
||||||
|
|
||||||
|
for _class in scrython.__all__[7:]:
|
||||||
|
|
||||||
intro = """These docs will likely not be as detailed as the official Scryfall Documentation, and you should reference that for more information.
|
intro = """These docs will likely not be as detailed as the official Scryfall Documentation, and you should reference that for more information.
|
||||||
|
|
||||||
|
@ -39,6 +55,7 @@ for _class in scrython.__all__:
|
||||||
returns = re.findall(r'(?<=Returns:)(.*)(?=Raises:)', remove_extra_spaces)[0]
|
returns = re.findall(r'(?<=Returns:)(.*)(?=Raises:)', remove_extra_spaces)[0]
|
||||||
|
|
||||||
raises = re.findall(r'(?<=Raises:)(.*)(?=Examples:)', remove_extra_spaces)[0]
|
raises = re.findall(r'(?<=Raises:)(.*)(?=Examples:)', remove_extra_spaces)[0]
|
||||||
|
format_raises(raises)
|
||||||
|
|
||||||
examples = re.findall(r'(?<=Examples:)(.*)', remove_extra_spaces)[0]
|
examples = re.findall(r'(?<=Examples:)(.*)', remove_extra_spaces)[0]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue