Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion neoteroi/mkdocs/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.1.3"
__version__ = "1.2.0"
14 changes: 12 additions & 2 deletions neoteroi/mkdocs/oad/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import re
from pathlib import Path
from typing import Optional

from mkdocs.config.config_options import Type
from mkdocs.plugins import BasePlugin
Expand All @@ -19,21 +20,30 @@


class MkDocsOpenAPIDocumentationPlugin(BasePlugin):
config_scheme = (("use_pymdownx", Type(bool, default=False)),)
config_scheme = (
("use_pymdownx", Type(bool, default=False)),
("templates_path", Type(str, default=None)),
)

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

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

def _get_templates_path(self) -> Optional[str]:
return self.config.get("templates_path", None)

def _replacer(self, cwd):
def replace(match) -> str:
source = match.group(1).strip("'\"")

data = read_from_source(source, cwd)

handler = OpenAPIV3DocumentationHandler(
data, style=self._get_style(), source=source
data,
style=self._get_style(),
source=source,
templates_path=self._get_templates_path(),
)
return handler.write()

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ keywords = [
"documentation",
]
dependencies = [
"essentials-openapi>=1.2.1",
"essentials-openapi>=1.3.0",
"mkdocs",
"httpx",
"click",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pytest
pytest-cov
essentials-openapi[full]>=1.2.1
essentials-openapi[full]>=1.3.0
mkdocs
flake8
black
Expand Down
Loading