@@ -190,12 +190,19 @@ def _place_doc_files(src_dir: Path, docs_dir: Path, repo: Repo, api_src_dir: Pat
190
190
191
191
try :
192
192
shutil .copytree (
193
- src_dir / SRC_DOCS_DIRNAME ,
193
+ src_dir / "staging_docs" ,
194
194
docs_dir / "docs" ,
195
195
)
196
+ repo .status .has_staging_docs = True
196
197
except FileNotFoundError :
197
- Path (docs_dir / "docs" ).mkdir (parents = True )
198
198
repo .status .has_staging_docs = False
199
+ try :
200
+ shutil .copytree (
201
+ src_dir / "docs" ,
202
+ docs_dir / "docs" ,
203
+ )
204
+ except FileNotFoundError :
205
+ Path (docs_dir / "docs" ).mkdir (parents = True )
199
206
200
207
# Add index pages to User and Dev sections
201
208
main_index = docs_dir / "docs/index.md"
@@ -398,9 +405,11 @@ def define_env(env):
398
405
if feature_id in config .disabled :
399
406
env .conf ["plugins" ][plugin_name ].config ["enabled" ] = False
400
407
401
- # Try to watch CWD/staging_docs
402
- watched_workdir = Path ("staging_docs" )
403
- if watched_workdir .exists ():
408
+ # Try to watch CWD/staging_docs or CWD/docs
409
+ watched_workdir = next (
410
+ (p for p in (Path ("staging_docs" ), Path ("docs" )) if p .exists ()), None
411
+ )
412
+ if watched_workdir :
404
413
env .conf ["watch" ].append (str (watched_workdir .resolve ()))
405
414
406
415
# Pass relevant data for future processing
@@ -445,16 +454,25 @@ def on_pre_page_macros(env):
445
454
repos : Repos = env .conf ["pulp_repos" ] # type: ignore
446
455
447
456
# Configure the edit_url with correct repository and path
448
- src_uri = env .page .file .src_uri . replace ( "/docs/" , f"/ { SRC_DOCS_DIRNAME } /" )
457
+ src_uri = env .page .file .src_uri
449
458
if src_uri != "index.md" :
450
459
repo , _ , path = src_uri .partition ("/" )
451
460
else :
452
461
repo = "pulpcore"
453
- path = f" { SRC_DOCS_DIRNAME } /index.md"
462
+ path = "docs /index.md"
454
463
455
464
repo_obj = repos .get (repo )
456
- repo_branch = getattr (repo_obj , "branch" , "main" )
457
- edit_url = f"https://github.com/pulp/{ repo } /edit/{ repo_branch } /{ path } "
465
+ if repo_obj :
466
+ if repo_obj .status .has_staging_docs :
467
+ path = ("/" + path ).replace ("/docs/" , "/staging_docs/" )[1 :]
468
+ if isinstance (repo_obj , SubPackage ):
469
+ path = repo_obj .name + "/" + path
470
+ repo = repo_obj .subpackage_of
471
+ repo_obj = repos .get (repo )
472
+ repo_branch = getattr (repo_obj , "branch" , "main" )
473
+ edit_url = f"https://github.com/pulp/{ repo } /edit/{ repo_branch } /{ path } "
474
+ else :
475
+ edit_url = None
458
476
env .page .edit_url = edit_url
459
477
460
478
0 commit comments