PickNikRobotics / generate_parameter_library

Declarative ROS 2 Parameters
BSD 3-Clause "New" or "Revised" License
230 stars 43 forks source link

Code generation gives syntax errors with newlines #170

Closed wouterio closed 6 months ago

wouterio commented 7 months ago

A description containing newlines

  hover_override: {
    type: int,
    default_value: 1,
    description: "Override hover action:\n0: Hover\n1: Push\n2: Pull\n-1: Do not override",
    validation: {
      one_of<>: [ [ 0, 1, 2, -1 ] ],
    },
  }

leads to generated python code with syntax errors:

            if not self.node_.has_parameter(self.prefix_ + "hover_override"):
                descriptor = ParameterDescriptor(description="Override hover action:   <<< missing quote
                0: Hover
                1: Push
                2: Pull
                -1: Do not override", read_only = False)
                parameter = updated_params.hover_override
                self.node_.declare_parameter(self.prefix_ + "hover_override", parameter, descriptor)
christophfroehlich commented 7 months ago

I had a similar issue with generated c++ code and implemented a jinja filter for this, see #164 Maybe you can use it (or implement something similar) for the python templates.

wouterio commented 7 months ago

I could easily avoid the problem skipping the newlines. But I'd say it's still something to be fixed.

wouterio commented 6 months ago

Ha that was quick, thank you! On 26 Feb 2024 at 21:11 +0100, Paul Gesel @.***>, wrote:

Closed #170 as completed. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>