diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 46036bc..7ea90b0 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -84,7 +84,7 @@ jobs: - run: | mk python-release owner=libre-embedded \ - repo=ifgen version=4.4.4 + repo=ifgen version=4.4.5 if: | matrix.python-version == '3.12' && matrix.system == 'ubuntu-latest' diff --git a/README.md b/README.md index ef8d6e2..63a527f 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ ===================================== generator=datazen version=3.2.3 - hash=8ee0ca6fb45a3831f000ce66e553d694 + hash=bb7c6c6ee9e74f924d3169c09662b491 ===================================== --> -# ifgen ([4.4.4](https://pypi.org/project/ifgen/)) +# ifgen ([4.4.5](https://pypi.org/project/ifgen/)) [![python](https://img.shields.io/pypi/pyversions/ifgen.svg)](https://pypi.org/project/ifgen/) ![Build Status](https://github.com/libre-embedded/ifgen/workflows/Python%20Package/badge.svg) diff --git a/ifgen/__init__.py b/ifgen/__init__.py index fc6e79a..89480d1 100644 --- a/ifgen/__init__.py +++ b/ifgen/__init__.py @@ -1,7 +1,7 @@ # ===================================== # generator=datazen # version=3.2.3 -# hash=df27db53be175c0270252c83f57d166d +# hash=67eaf4ed029fdce58622eee8dd8cfdf0 # ===================================== """ @@ -10,4 +10,4 @@ DESCRIPTION = "An interface generator for distributed computing." PKG_NAME = "ifgen" -VERSION = "4.4.4" +VERSION = "4.4.5" diff --git a/ifgen/enum/python/__init__.py b/ifgen/enum/python/__init__.py index 1059195..59aaedf 100644 --- a/ifgen/enum/python/__init__.py +++ b/ifgen/enum/python/__init__.py @@ -10,6 +10,7 @@ from ifgen.generation.interface import GenerateTask from ifgen.generation.python import ( python_class, + python_docstring, python_function, python_imports, ) @@ -73,13 +74,9 @@ def python_enum_header(task: GenerateTask, writer: IndentedFileWriter) -> None: if value: final = value.get("value", final) - line = f"{to_enum_name(enum)} = {final}" + writer.write(f"{to_enum_name(enum)} = {final}") if value and "description" in value: - line += f" # {value['description']}" - - writer.write(line) - - writer.empty() + python_docstring(writer, value["description"]) # Override underlying primitive if necessary. underlying = strip_t_suffix(task.instance["underlying"]) diff --git a/ifgen/generation/python/__init__.py b/ifgen/generation/python/__init__.py index 848f489..66ae164 100644 --- a/ifgen/generation/python/__init__.py +++ b/ifgen/generation/python/__init__.py @@ -44,6 +44,19 @@ def python_imports( writer.empty(count=final_empty) +def python_docstring( + writer: IndentedFileWriter, *docstrings: str, empty: bool = True +) -> None: + """Write docstring data.""" + + writer.write('"""') + for docstring in docstrings: + writer.write(docstring) + writer.write('"""') + if empty: + writer.empty() + + @contextmanager def python_class( writer: IndentedFileWriter, @@ -61,8 +74,7 @@ def python_class( writer.write(line) with writer.indented(): - writer.write(f'"""{docstring}"""') - writer.empty() + python_docstring(writer, docstring) yield writer.empty(count=final_empty) @@ -86,8 +98,7 @@ def python_function( writer.write(f"def {name}({params}) -> {return_type}:") with writer.indented(): - writer.write(f'"""{docstring}"""') - writer.empty() + python_docstring(writer, docstring) yield writer.empty(count=final_empty) diff --git a/local/variables/package.yaml b/local/variables/package.yaml index dc8f50a..4cf3e3d 100644 --- a/local/variables/package.yaml +++ b/local/variables/package.yaml @@ -1,5 +1,5 @@ --- major: 4 minor: 4 -patch: 4 +patch: 5 entry: ig diff --git a/pyproject.toml b/pyproject.toml index 439acaa..5a5cd77 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__" [project] name = "ifgen" -version = "4.4.4" +version = "4.4.5" description = "An interface generator for distributed computing." readme = "README.md" requires-python = ">=3.12"