@@ -234,47 +234,43 @@ def clone_or_update_repo(name, branch, dir_name, owner='openwisp'):
234
234
repo_url = f'git@github.com:{ repository } .git'
235
235
else :
236
236
repo_url = f'https://github.com/{ repository } .git'
237
- clone_path = os .path .join ('modules' , dir_name )
237
+ clone_path = os .path .abspath ( os . path . join ('modules' , dir_name ) )
238
238
239
239
if os .path .exists (clone_path ):
240
240
print (f"Repository '{ name } ' already exists. Updating..." )
241
- subprocess .run (
242
- ['git' , 'remote' , 'set-branches' , 'origin' , branch ],
243
- cwd = clone_path ,
244
- check = True ,
245
- )
246
- subprocess .run (
247
- ['git' , 'fetch' , '--update-shallow' , 'origin' , branch ],
248
- cwd = clone_path ,
249
- check = True ,
250
- )
251
241
subprocess .run (['git' , 'checkout' , branch ], cwd = clone_path , check = True )
252
- subprocess .run (['git' , 'pull' , 'origin' , branch ], cwd = clone_path , check = True )
253
242
else :
254
243
print (f"Cloning repository '{ name } '..." )
255
244
subprocess .run (
256
245
[
257
246
'git' ,
258
247
'clone' ,
259
- '--single-branch' ,
260
- '--branch' ,
261
- branch ,
262
- '--depth' ,
263
- '1' ,
264
248
repo_url ,
265
249
clone_path ,
266
250
],
267
251
check = True ,
268
252
)
253
+ subprocess .run (
254
+ [
255
+ 'git' ,
256
+ 'checkout' ,
257
+ branch ,
258
+ ],
259
+ cwd = clone_path ,
260
+ check = True ,
261
+ )
269
262
# If the module contains a doc directory, copy it to the dir_name in the root.
270
263
# Otherwise, copy the entire directory.
271
- if os .path .islink (dir_name ):
272
- os .unlink (dir_name )
264
+ dest = dir_name
265
+ if dest != 'openwisp-docs' :
266
+ dest = os .path .join ('openwisp-docs' , dir_name )
267
+ if os .path .islink (dest ):
268
+ os .unlink (dest )
273
269
src = os .path .join (clone_path , 'docs' )
274
270
# openwisp docs repo
275
271
if not os .path .exists (src ):
276
272
src = clone_path
277
- os .symlink (src , dir_name )
273
+ os .symlink (src , dest )
278
274
279
275
280
276
def main ():
@@ -333,14 +329,20 @@ def main():
333
329
334
330
# If a module does not define a branch,
335
331
# it will fallback to the version_branch.
336
- version_branch = version .get ('branch' , version ['name' ])
332
+ version_branch = version .get ('module_branch' , version ['name' ])
333
+ docs_branch = version .get ('docs_branch' , 'master' )
334
+ clone_or_update_repo (
335
+ name = 'openwisp-docs' ,
336
+ branch = docs_branch ,
337
+ dir_name = 'openwisp-docs' ,
338
+ )
337
339
for module in modules :
338
340
clone_or_update_repo (
339
341
branch = module .pop ('branch' , version_branch ),
340
342
** module ,
341
343
)
342
344
module_dirs .append (module ['dir_name' ])
343
- sphinx_src_dir = version .get ('sphinx_src_dir' , '. ' )
345
+ sphinx_src_dir = version .get ('sphinx_src_dir' , 'openwisp-docs ' )
344
346
for format in ['spellcheck' ] + args .formats :
345
347
subprocess .run (
346
348
[
@@ -360,7 +362,10 @@ def main():
360
362
)
361
363
# Remove all temporary directories
362
364
for dir in module_dirs :
363
- os .unlink (dir )
365
+ path = dir
366
+ if path != 'openwisp-docs' :
367
+ path = os .path .join ('openwisp-docs' , dir )
368
+ os .unlink (path )
364
369
365
370
# Generate the index.html file which redirects to the stable version.
366
371
env = Environment (loader = FileSystemLoader ('_static' ))
0 commit comments