8000 feat: Allow custom list of domains for inventories · FasterSpeeding/python@f5ea6fd · GitHub
[go: up one dir, main page]

Skip to content

Commit f5ea6fd

Browse files
authored
feat: Allow custom list of domains for inventories
Issue mkdocstrings/mkdocstrings#510: mkdocstrings/mkdocstrings#510 PR mkdocstrings#49: mkdocstrings#49
1 parent 32be783 commit f5ea6fd

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

docs/schema.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
"base_url": {
2727
"title": "Base URL used to build references URLs.",
2828
"type": "string"
29+
},
30+
"domains": {
31+
"title": "Domains to import from the inventory.",
32+
"description": "If not defined it will only import 'py' domain.",
33+
"type": "array",
34+
"items": {
35+
"type": "string"
36+
}
2937
}
3038
}
3139
}
@@ -203,4 +211,4 @@
203211
}
204212
},
205213
"additionalProperties": false
206-
}
214+
}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ classifiers = [
2929
"Typing :: Typed",
3030
]
3131
dependencies = [
32-
"mkdocstrings>=0.19",
32+
"mkdocstrings>=0.20",
3333
"griffe>=0.24",
3434
]
3535

src/mkdocstrings_handlers/python/handler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ def load_inventory(
169169
in_file: BinaryIO,
170170
url: str,
171171
base_url: Optional[str] = None,
172+
domains: list[str] | None = None,
172173
**kwargs: Any,
173174
) -> Iterator[Tuple[str, str]]:
174175
"""Yield items and their URLs from an inventory file streamed from `in_file`.
@@ -179,15 +180,17 @@ def load_inventory(
179180
in_file: The binary file-like object to read the inventory from.
180181
url: The URL that this file is being streamed from (used to guess `base_url`).
181182
base_url: The URL that this inventory's sub-paths are relative to.
183+
domains: A list of domain strings to filter the inventory by, when not passed, "py" will be used.
182184
**kwargs: Ignore additional arguments passed from the config.
183185
184186
Yields:
185187
Tuples of (item identifier, item URL).
186188
"""
189+
domains = domains or ["py"]
187190
if base_url is None:
188191
base_url = posixpath.dirname(url)
189192

190-
for item in Inventory.parse_sphinx(in_file, domain_filter=("py",)).values(): # noqa: WPS526
193+
for item in Inventory.parse_sphinx(in_file, domain_filter=domains).values(): # noqa: WPS526
191194
yield item.name, posixpath.join(base_url, item.uri)
192195

193196
def collect(self, identifier: str, config: Mapping[str, Any]) -> CollectorItem: # noqa: D102,WPS231

0 commit comments

Comments
 (0)
0