Skip to content

Commit 0c1f43f

Browse files
authored
Fix erros when spec in subdir (#194)
Co-authored-by: Kai Harder <[email protected]>
1 parent 838bb89 commit 0c1f43f

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 5.0.1
4+
5+
* Fix some errors when the spec is in a subdirectory
6+
37
## 5.0.0
48

59
This release combines the previous three way into one directive streamlining the project

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "swagger-plugin-for-sphinx"
7-
version = "5.0.0"
7+
version = "5.0.1"
88
description = "Sphinx plugin which renders a OpenAPI specification with Swagger"
99
authors = [{ name = "Kai Harder", email = "[email protected]" }]
1010
readme = "README.md"

swagger_plugin_for_sphinx/_plugin.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ def run(self) -> list[nodes.Node]:
5555
)
5656

5757
rel_parts = Path(relpath).parts
58-
static = Path(app.srcdir).joinpath(rel_parts[0])
59-
logger.info(f"Adding to html_static_path: {static}.")
60-
app.config.html_static_path.extend([static])
61-
62-
# If the relative path does not start with _static/, add it.
63-
url_path = self.arguments[0]
64-
if not url_path.startswith("_static/"):
65-
url_path = "_static/" + url_path
58+
logger.info(f"Adding to html_static_path: {spec}.")
59+
app.config.html_static_path.extend([spec])
60+
61+
url_path = (
62+
"../".join(["" for _ in range(len(rel_parts))])
63+
+ "_static/"
64+
+ self.arguments[0]
65+
)
6666

6767
config = {
6868
"full_page": "full-page" in self.options,

0 commit comments

Comments
 (0)