This commit is contained in:
Laurens Valk
2023-11-28 15:12:05 +01:00
parent 7b2242e420
commit 2b1f161005
3 changed files with 14 additions and 4 deletions
+5
View File
@@ -4,6 +4,11 @@
## Unreleased ## Unreleased
## 3.4.0b1 - 2023-11-28
### Changed
- Include first batch of block coding images.
## 3.3.0 - 2023-11-24 ## 3.3.0 - 2023-11-24
### Changed ### Changed
+8 -3
View File
@@ -6,7 +6,6 @@ from docutils.parsers.rst.directives.images import Image
from docutils.nodes import image, paragraph from docutils.nodes import image, paragraph
from pathlib import Path from pathlib import Path
SPHINX_DOC = "main"
SPHINX_IMAGE_PATH = "blockimg" SPHINX_IMAGE_PATH = "blockimg"
SVG_SCALE = 0.9 SVG_SCALE = 0.9
@@ -22,6 +21,10 @@ def get_svg_size(file_path):
return float(width), float(height) return float(width), float(height)
# Global variable to store the app object
app = None
class BlockImageDirective(Image): class BlockImageDirective(Image):
option_spec = Image.option_spec.copy() option_spec = Image.option_spec.copy()
option_spec["stack"] = directives.flag option_spec["stack"] = directives.flag
@@ -30,7 +33,7 @@ class BlockImageDirective(Image):
# Adjust the image path # Adjust the image path
file_name = self.arguments[0] + ".svg" file_name = self.arguments[0] + ".svg"
self.arguments[0] = "/" + SPHINX_IMAGE_PATH + "/" + file_name self.arguments[0] = "/" + SPHINX_IMAGE_PATH + "/" + file_name
path = Path(os.getcwd()) / SPHINX_DOC / SPHINX_IMAGE_PATH / file_name path = Path(app.srcdir) / SPHINX_IMAGE_PATH / file_name
# Set it to the scaled SVG size unless width explicitly set. # Set it to the scaled SVG size unless width explicitly set.
if self.options.get("width") is None: if self.options.get("width") is None:
@@ -51,5 +54,7 @@ class BlockImageDirective(Image):
return nodes return nodes
def setup(app): def setup(apparg):
global app
app = apparg
app.add_directive("blockimg", BlockImageDirective) app.add_directive("blockimg", BlockImageDirective)
+1 -1
View File
@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "pybricks" name = "pybricks"
version = "3.3.0" version = "3.4.0b1"
description = "Documentation and user-API stubs for Pybricks MicroPython" description = "Documentation and user-API stubs for Pybricks MicroPython"
authors = ["The Pybricks Authors <team@pybricks.com>"] authors = ["The Pybricks Authors <team@pybricks.com>"]
maintainers = ["Laurens Valk <laurens@pybricks.com>", "David Lechner <david@pybricks.com>" ] maintainers = ["Laurens Valk <laurens@pybricks.com>", "David Lechner <david@pybricks.com>" ]