Skip to content

Commit 3126575

Browse files
authored
4.4.5 - Fix Python enum description comments (#95)
1 parent 8709f98 commit 3126575

File tree

7 files changed

+25
-17
lines changed

7 files changed

+25
-17
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
8585
- run: |
8686
mk python-release owner=libre-embedded \
87-
repo=ifgen version=4.4.4
87+
repo=ifgen version=4.4.5
8888
if: |
8989
matrix.python-version == '3.12'
9090
&& matrix.system == 'ubuntu-latest'

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
=====================================
33
generator=datazen
44
version=3.2.3
5-
hash=8ee0ca6fb45a3831f000ce66e553d694
5+
hash=bb7c6c6ee9e74f924d3169c09662b491
66
=====================================
77
-->
88

9-
# ifgen ([4.4.4](https://pypi.org/project/ifgen/))
9+
# ifgen ([4.4.5](https://pypi.org/project/ifgen/))
1010

1111
[![python](https://img.shields.io/pypi/pyversions/ifgen.svg)](https://pypi.org/project/ifgen/)
1212
![Build Status](https://github.com/libre-embedded/ifgen/workflows/Python%20Package/badge.svg)

ifgen/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# =====================================
22
# generator=datazen
33
# version=3.2.3
4-
# hash=df27db53be175c0270252c83f57d166d
4+
# hash=67eaf4ed029fdce58622eee8dd8cfdf0
55
# =====================================
66

77
"""
@@ -10,4 +10,4 @@
1010

1111
DESCRIPTION = "An interface generator for distributed computing."
1212
PKG_NAME = "ifgen"
13-
VERSION = "4.4.4"
13+
VERSION = "4.4.5"

ifgen/enum/python/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from ifgen.generation.interface import GenerateTask
1111
from ifgen.generation.python import (
1212
python_class,
13+
python_docstring,
1314
python_function,
1415
python_imports,
1516
)
@@ -73,13 +74,9 @@ def python_enum_header(task: GenerateTask, writer: IndentedFileWriter) -> None:
7374
if value:
7475
final = value.get("value", final)
7576

76-
line = f"{to_enum_name(enum)} = {final}"
77+
writer.write(f"{to_enum_name(enum)} = {final}")
7778
if value and "description" in value:
78-
line += f" # {value['description']}"
79-
80-
writer.write(line)
81-
82-
writer.empty()
79+
python_docstring(writer, value["description"])
8380

8481
# Override underlying primitive if necessary.
8582
underlying = strip_t_suffix(task.instance["underlying"])

ifgen/generation/python/__init__.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ def python_imports(
4444
writer.empty(count=final_empty)
4545

4646

47+
def python_docstring(
48+
writer: IndentedFileWriter, *docstrings: str, empty: bool = True
49+
) -> None:
50+
"""Write docstring data."""
51+
52+
writer.write('"""')
53+
for docstring in docstrings:
54+
writer.write(docstring)
55+
writer.write('"""')
56+
if empty:
57+
writer.empty()
58+
59+
4760
@contextmanager
4861
def python_class(
4962
writer: IndentedFileWriter,
@@ -61,8 +74,7 @@ def python_class(
6174

6275
writer.write(line)
6376
with writer.indented():
64-
writer.write(f'"""{docstring}"""')
65-
writer.empty()
77+
python_docstring(writer, docstring)
6678
yield
6779

6880
writer.empty(count=final_empty)
@@ -86,8 +98,7 @@ def python_function(
8698
writer.write(f"def {name}({params}) -> {return_type}:")
8799

88100
with writer.indented():
89-
writer.write(f'"""{docstring}"""')
90-
writer.empty()
101+
python_docstring(writer, docstring)
91102
yield
92103

93104
writer.empty(count=final_empty)

local/variables/package.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
major: 4
33
minor: 4
4-
patch: 4
4+
patch: 5
55
entry: ig

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:__legacy__"
44

55
[project]
66
name = "ifgen"
7-
version = "4.4.4"
7+
version = "4.4.5"
88
description = "An interface generator for distributed computing."
99
readme = "README.md"
1010
requires-python = ">=3.12"

0 commit comments

Comments
 (0)