|
11 | 11 |
|
12 | 12 | import re |
13 | 13 | from pathlib import Path |
| 14 | +from typing import Optional |
14 | 15 |
|
15 | 16 | from mkdocs.config.config_options import Type |
16 | 17 | from mkdocs.plugins import BasePlugin |
|
19 | 20 |
|
20 | 21 |
|
21 | 22 | class MkDocsOpenAPIDocumentationPlugin(BasePlugin): |
22 | | - config_scheme = (("use_pymdownx", Type(bool, default=False)),) |
| 23 | + config_scheme = ( |
| 24 | + ("use_pymdownx", Type(bool, default=False)), |
| 25 | + ("templates_path", Type(str, default=None)), |
| 26 | + ) |
23 | 27 |
|
24 | 28 | rx = re.compile(r"\[OAD\(([^\)]+)\)\]") |
25 | 29 |
|
26 | 30 | def _get_style(self) -> str: |
27 | 31 | return "MKDOCS" if self.config.get("use_pymdownx", False) else "MARKDOWN" |
28 | 32 |
|
| 33 | + def _get_templates_path(self) -> Optional[str]: |
| 34 | + return self.config.get("templates_path", None) |
| 35 | + |
29 | 36 | def _replacer(self, cwd): |
30 | 37 | def replace(match) -> str: |
31 | 38 | source = match.group(1).strip("'\"") |
32 | 39 |
|
33 | 40 | data = read_from_source(source, cwd) |
34 | 41 |
|
35 | 42 | handler = OpenAPIV3DocumentationHandler( |
36 | | - data, style=self._get_style(), source=source |
| 43 | + data, |
| 44 | + style=self._get_style(), |
| 45 | + source=source, |
| 46 | + templates_path=self._get_templates_path(), |
37 | 47 | ) |
38 | 48 | return handler.write() |
39 | 49 |
|
|
0 commit comments