Skip to content

Commit 1c3e210

Browse files
committed
Add repository specifier to find_path paths
1 parent 6927eb6 commit 1c3e210

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

src/pulp_docs/cli.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def find_path_callback(ctx: click.Context, param: click.Parameter, value: bool)
5959
expose_value=False,
6060
default="",
6161
callback=find_path_callback,
62-
help="A colon separated list of repository paths. Accepts glob patterns.",
62+
help="A colon separated list of lookup paths in the form: [repo1@]path1 [:[repo2@]path2 [...]].",
6363
)
6464

6565

src/pulp_docs/plugin.py

+11-14
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,21 @@ class Component:
5353
def build(cls, find_path: list[str], component_opt: ComponentOption):
5454
body = dict(component_opt)
5555
repository_name = component_opt.path.split("/")[0]
56-
expanded_path = []
57-
for dir in find_path:
58-
expanded_path.extend(glob.glob(dir))
59-
for dir in expanded_path:
60-
dir = Path(dir)
61-
component_dir = dir.parent / component_opt.path
62-
found_dir = repository_name == dir.name and component_dir.exists()
63-
if found_dir:
56+
for dir_spec in find_path:
57+
repo_filter, _, basedir = dir_spec.rpartition("@")
58+
if repo_filter and repo_filter != repository_name:
59+
continue
60+
basedir = Path(basedir)
61+
component_dir = basedir / component_opt.path
62+
if component_dir.exists():
6463
version = "unknown"
6564
try:
6665
pyproject = component_dir / "pyproject.toml"
6766
version = tomllib.loads(pyproject.read_text())["project"]["version"]
6867
except Exception:
6968
pass
7069
body["version"] = version
71-
body["repository_dir"] = dir
70+
body["repository_dir"] = basedir / repository_name
7271
body["component_dir"] = component_dir
7372
return cls(**body)
7473
return None
@@ -284,15 +283,13 @@ def on_config(self, config: MkDocsConfig) -> MkDocsConfig | None:
284283
self.draft = ctx_draft.get()
285284

286285
self.pulp_docs_dir = Path(config.docs_dir).parent
287-
# Two directories up from docs is where we expect all the other repositories by default.
288-
self.find_path = ctx_path.get() or [f"{self.pulp_docs_dir.parent}/*"]
286+
self.find_path = ctx_path.get() or [str(self.pulp_docs_dir.parent)]
289287

290288
loaded_components = load_components(self.find_path, self.config, self.draft)
291289
self.config.components = loaded_components
290+
loaded_component_dirnames = [str(c.component_dir) for c in loaded_components]
291+
log.info(f"Using components={loaded_component_dirnames}")
292292

293-
log.info(
294-
f"Using components={[str(c.component_dir) for c in loaded_components]}"
295-
)
296293
mkdocstrings_config = config.plugins["mkdocstrings"].config
297294
components_var = []
298295
for component in self.config.components:

0 commit comments

Comments
 (0)