@@ -14,61 +14,63 @@ def checkIfDocIsPresent(title, headers):
14
14
check_url = URL + "/" + title
15
15
response = requests .get (check_url , headers = headers )
16
16
17
- if ( response .status_code == 200 ) :
17
+ if response .status_code == 200 :
18
18
return True
19
19
else :
20
20
return False
21
21
22
22
23
23
def publishDoc (title , body , order ):
24
- key = os .environ .get (' README_API_KEY' )
24
+ key = os .environ .get (" README_API_KEY" )
25
25
payload = {
26
26
"title" : title ,
27
27
"type" : "basic" ,
28
28
"body" : body ,
29
29
"category" : CATEGORY_ID ,
30
30
"hidden" : False ,
31
- "order" : order
31
+ "order" : order ,
32
32
}
33
33
headers = {
34
34
"accept" : "application/json" ,
35
35
"content-type" : "application/json" ,
36
- "authorization" : "Basic " + key
36
+ "authorization" : "Basic " + key ,
37
37
}
38
38
39
39
isDocPresent = checkIfDocIsPresent (title , headers )
40
- if ( isDocPresent ) :
40
+ if isDocPresent :
41
41
# update doc
42
42
update_url = URL + "/" + title # title == slug
43
43
response = requests .put (update_url , json = payload , headers = headers )
44
- if ( response .status_code != 200 ) :
44
+ if response .status_code != 200 :
45
45
print (response .text )
46
46
else :
47
47
print ("Updated " , title )
48
48
else :
49
49
# create doc
50
50
response = requests .post (URL , json = payload , headers = headers )
51
- if ( response .status_code != 201 ) :
51
+ if response .status_code != 201 :
52
52
print (response .text )
53
53
else :
54
54
print ("Created " , title )
55
55
56
56
57
57
def extract_rpc_commands (rst_content ):
58
- manpages_block = re .search
59
- (r"\.\. block_start manpages(.*?)\.\. block_end manpages" ,
60
- rst_content , re .DOTALL )
58
+ manpages_block = re .search (
59
+ r"\.\. block_start manpages(.*?)" r"\.\. block_end manpages" ,
60
+ rst_content ,
61
+ re .DOTALL ,
62
+ )
61
63
if manpages_block :
62
- commands = re .findall
63
- ( r' \b([a-zA-Z0-9_-]+)\s+<([^>]+)>\n' ,
64
- manpages_block . group ( 1 ) )
64
+ commands = re .findall (
65
+ r" \b([a-zA-Z0-9_-]+)" r" \s+<([^>]+)>\n" , manpages_block . group ( 1 )
66
+ )
65
67
return commands
66
68
return []
67
69
68
70
69
71
def main ():
70
72
# path to the rst file from where we fetch all the RPC commands
71
- path_to_rst = ' doc/index.rst'
73
+ path_to_rst = " doc/index.rst"
72
74
with open (path_to_rst , "r" ) as file :
73
75
rst_content = file .read ()
74
76
0 commit comments