@@ -307,6 +307,13 @@ def log_pulp_config(
307307 log .info (display_str )
308308
309309
310+ def get_pulpdocs_git_url (config : PulpDocsPluginConfig ):
311+ for component in config .components :
312+ if component .path == "pulp-docs" :
313+ return component .git_url
314+ raise RuntimeError ("Did pulp-docs changed it's name or was removed from mkdocs.yml?" )
315+
316+
310317class PulpDocsPlugin (BasePlugin [PulpDocsPluginConfig ]):
311318 def on_config (self , config : MkDocsConfig ) -> MkDocsConfig | None :
312319 # mkdocs may default to the installation dir
@@ -320,14 +327,15 @@ def on_config(self, config: MkDocsConfig) -> MkDocsConfig | None:
320327
321328 self .mkdocs_yml_dir = Path (config .docs_dir ).parent
322329 self .find_path = ctx_path .get () or [str (Path ().cwd ().parent )]
323- self .config .components = load_components (self .find_path , self .config , self .draft )
330+ self .loaded_components = load_components (self .find_path , self .config , self .draft )
331+ self .pulpdocs_git_url = get_pulpdocs_git_url (self .config )
324332
325333 mkdocs_file = self .mkdocs_yml_dir / "mkdocs.yml"
326- log_pulp_config (mkdocs_file , self .find_path , self .config . components , config .site_dir )
334+ log_pulp_config (mkdocs_file , self .find_path , self .loaded_components , config .site_dir )
327335
328336 mkdocstrings_config = config .plugins ["mkdocstrings" ].config
329337 components_var = []
330- for component in self .config . components :
338+ for component in self .loaded_components :
331339 components_var .append (get_component_data (component ))
332340 config .watch .append (str (component .component_dir / "docs" ))
333341 component_dir = str (component .component_dir .resolve ())
@@ -350,8 +358,8 @@ def on_config(self, config: MkDocsConfig) -> MkDocsConfig | None:
350358 return config
351359
352360 def on_files (self , files : Files , / , * , config : MkDocsConfig ) -> Files | None :
353- log .info (f"Loading Pulp components: { self .config . components } " )
354- pulp_docs_component = [c for c in self .config . components if c .path == "pulp-docs" ]
361+ log .info (f"Loading Pulp components: { self .loaded_components } " )
362+ pulp_docs_component = [c for c in self .loaded_components if c .path == "pulp-docs" ]
355363 if pulp_docs_component :
356364 pulp_docs_git = Repo (pulp_docs_component [0 ].repository_dir )
357365 else :
@@ -360,7 +368,7 @@ def on_files(self, files: Files, /, *, config: MkDocsConfig) -> Files | None:
360368
361369 user_nav : dict [str , t .Any ] = {}
362370 dev_nav : dict [str , t .Any ] = {}
363- for component in self .config . components :
371+ for component in self .loaded_components :
364372 component_dir = component .component_dir
365373
366374 log .info (f"Fetching docs from '{ component .title } '." )
@@ -493,10 +501,10 @@ def get_openapi_spec(self, component, pulp_docs_git: Repo):
493501 f"docs-data:data/openapi_json/{ component .rest_api } -api.json"
494502 )
495503 except GitCommandError :
496- # Try again on the first remote.
497- remote = pulp_docs_git .remotes [ 0 ]
504+ # Not found locally. Try again fetching from the official remote url
505+ pulp_docs_git .git . fetch ( self . pulpdocs_git_url , "docs-data" )
498506 api_json = pulp_docs_git .git .show (
499- f"{ remote } /docs-data :data/openapi_json/{ component .rest_api } -api.json"
507+ f"FETCH_HEAD :data/openapi_json/{ component .rest_api } -api.json"
500508 )
501509 # fix the logo url for restapi page, which is defined in the openapi spec file
502510 api_json = api_json .replace (
0 commit comments