@@ -35,7 +35,7 @@ def check_renderable(response, action, title):
3535
3636 renderable = data .get ("renderable" )
3737 if renderable is None :
38- # Some endpoints don’ t include renderable (e.g. DELETE)
38+ # Some endpoints don' t include renderable (e.g. DELETE)
3939 return True
4040
4141 if not renderable .get ("status" , False ):
@@ -121,8 +121,18 @@ def main():
121121 "Authorization" : "Bearer " + os .environ .get ("README_API_KEY" ),
122122 }
123123
124+ # Validate API key exists
125+ if not os .environ .get ("README_API_KEY" ):
126+ print ("❌ ERROR: README_API_KEY environment variable not set" )
127+ return
128+
124129 # path to the rst file from where we fetch all the RPC commands
125130 path_to_rst = "doc/index.rst"
131+
132+ if not os .path .exists (path_to_rst ):
133+ print (f"❌ ERROR: File not found: { path_to_rst } " )
134+ return
135+
126136 with open (path_to_rst , "r" ) as file :
127137 rst_content = file .read ()
128138
@@ -131,24 +141,31 @@ def main():
131141
132142 # Compare local and server commands list to get the list of command to add or delete
133143 commands_local_title = set (command [0 ] for command in commands_from_local )
134- commands_readme_title = set (command ['title ' ] for command in commands_from_readme )
144+ commands_readme_title = set (command ['slug ' ] for command in commands_from_readme )
135145 commands_to_delete = commands_readme_title - commands_local_title
136146 commands_to_add = commands_local_title - commands_readme_title
137147 for name in commands_to_delete :
138148 publishDoc (Action .DELETE , name , "" , 0 , headers )
139- sleep (3 )
149+ sleep (1 )
140150
141151 if commands_from_local :
142152 position = 0
143153 for name , file in commands_from_local :
144- with open ("doc/" + file ) as f :
154+ file_path = "doc/" + file
155+ if not os .path .exists (file_path ):
156+ print (f"⚠️ WARNING: File not found: { file_path } , skipping { name } " )
157+ continue
158+
159+ with open (file_path ) as f :
145160 body = f .read ()
146161 action = Action .ADD if name in commands_to_add else Action .UPDATE
147162 publishDoc (action , name , body , position , headers )
148163 position += 1
149164 sleep (1 )
150165 else :
151- print ("No commands found in the Manpages block." )
166+ print ("⚠️ No commands found in the Manpages block." )
167+
168+ print ("\n ✨ Sync complete!" )
152169
153170
154171if __name__ == "__main__" :
0 commit comments