robotpy / pynetworktables

Pure python implementation of the FRC NetworkTables protocol
Other
60 stars 30 forks source link

ntproperty: Allow setting docstring #44

Closed auscompgeek closed 7 years ago

auscompgeek commented 7 years ago

This adds a doc argument to ntproperty, allowing the user to specify a docstring for an ntproperty.

This was previously possible (at least on Python 3.5+), but required setting __doc__ manually:

class Foo:
  x = ntproperty('/vision/x', 0.0)
  x.__doc__ = 'Some number set by vision code.'

With this commit, such code would look like this instead:

class Foo:
  x = ntproperty('/vision/x', 0.0, doc='Some number set by vision code.')
virtuald commented 7 years ago

I feel like you should publish the docstring to NT.

auscompgeek commented 7 years ago

That's probably be a good idea. We'd have to work out a convention for that. Is there any precedent set in the community already for help strings?

virtuald commented 7 years ago

I don't think so. The StatefulAutonomous stuff did a little bit of that, but it was terrible and constrained by SmartDashboard. I would do either _xxx suffix or descriptions/KEY if we wanted to put it in a separate table.