Skip to content

Commit 04b3132

Browse files
authored
Add config for custom templates (#78)
1 parent 07b5407 commit 04b3132

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

neoteroi/mkdocs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.1.3"
1+
__version__ = "1.2.0"

neoteroi/mkdocs/oad/__init__.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import re
1313
from pathlib import Path
14+
from typing import Optional
1415

1516
from mkdocs.config.config_options import Type
1617
from mkdocs.plugins import BasePlugin
@@ -19,21 +20,30 @@
1920

2021

2122
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+
)
2327

2428
rx = re.compile(r"\[OAD\(([^\)]+)\)\]")
2529

2630
def _get_style(self) -> str:
2731
return "MKDOCS" if self.config.get("use_pymdownx", False) else "MARKDOWN"
2832

33+
def _get_templates_path(self) -> Optional[str]:
34+
return self.config.get("templates_path", None)
35+
2936
def _replacer(self, cwd):
3037
def replace(match) -> str:
3138
source = match.group(1).strip("'\"")
3239

3340
data = read_from_source(source, cwd)
3441

3542
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(),
3747
)
3848
return handler.write()
3949

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ keywords = [
3232
"documentation",
3333
]
3434
dependencies = [
35-
"essentials-openapi>=1.2.1",
35+
"essentials-openapi>=1.3.0",
3636
"mkdocs",
3737
"httpx",
3838
"click",

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pytest
22
pytest-cov
3-
essentials-openapi[full]>=1.2.1
3+
essentials-openapi[full]>=1.3.0
44
mkdocs
55
flake8
66
black

0 commit comments

Comments
 (0)