Skip to content

Commit

Permalink
DOCS-2530: Update script for shorter param names (#3041)
Browse files Browse the repository at this point in the history
  • Loading branch information
npentrel authored Jun 20, 2024
1 parent b508799 commit dfb93b0
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/update_sdk_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,12 @@ def make_soup(url):
except urllib.error.HTTPError as err:
print(f'An HTTPError was thrown: {err.code} {err.reason} for URL: {url}')

def shorten_data_type(t):
if '.' in t:
return '.'.join(t.split('.')[-2:])
else:
return t

## Link any matching data types to their reference links, based on {sdk}_datatype_links[] array,
## used in parse() for both param and return data types. Handles data types syntax that includes
## multiple data types (and therefore requires multiple data type links), such as
Expand All @@ -579,7 +585,8 @@ def link_data_types(sdk, data_type_string):

## If the passed data_type_string matches exactly to a data type defined in python_datatype_links, use that:
if data_type_string in python_datatype_links.keys():
linked_data_type_string = '[' + data_type_string + '](' + python_datatype_links[data_type_string] + ')'
shorter_data_type = shorten_data_type(data_type_string)
linked_data_type_string = '[' + shorter_data_type + '](' + python_datatype_links[data_type_string] + ')'
else:

## Assemble all encountered data types that match to python_datatype_links keys into array.
Expand All @@ -597,7 +604,8 @@ def link_data_types(sdk, data_type_string):
## Discard string matches that are substrings of other data type strings:
if not regex.search(r'[A-Za-z0-9]' + data_type_found, data_type_string) and not regex.search(data_type_found + r'[A-Za-z0-9]', data_type_string):

data_type_linked = '[' + data_type_found + '](' + python_datatype_links[data_type_found] + ')'
shorter_data_type = shorten_data_type(data_type_found)
data_type_linked = '[' + shorter_data_type + '](' + python_datatype_links[data_type_found] + ')'
linked_data_type_string = regex.sub(data_type_found, data_type_linked, linked_data_type_string)
else:
## If we get here, this data_type is actually a substring of another data type. Take no action:
Expand Down
8 changes: 4 additions & 4 deletions static/include/app/apis/generated/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ List the members and invites of the {{< glossary_tooltip term_id="organization"

**Returns:**

- (Tuple[List[[viam.proto.app.OrganizationMember](https://python.viam.dev/autoapi/viam/proto/app/index.html#viam.proto.app.OrganizationMember)], List[[viam.proto.app.OrganizationInvite](https://python.viam.dev/autoapi/viam/proto/app/index.html#viam.proto.app.OrganizationInvite)]]): A tuple containing two lists; the first [0] of organization members, and the second [1] of organization invites.
- (Tuple[List[[app.OrganizationMember](https://python.viam.dev/autoapi/viam/proto/app/index.html#viam.proto.app.OrganizationMember)], List[[app.OrganizationInvite](https://python.viam.dev/autoapi/viam/proto/app/index.html#viam.proto.app.OrganizationInvite)]]): A tuple containing two lists; the first [0] of organization members, and the second [1] of organization invites.

**Example:**

Expand Down Expand Up @@ -149,7 +149,7 @@ Create an {{< glossary_tooltip term_id="organization" text="organization" >}} in

**Returns:**

- ([viam.proto.app.OrganizationInvite](https://python.viam.dev/autoapi/viam/proto/app/index.html#viam.proto.app.OrganizationInvite)): The organization invite.
- ([app.OrganizationInvite](https://python.viam.dev/autoapi/viam/proto/app/index.html#viam.proto.app.OrganizationInvite)): The organization invite.

**Raises:**

Expand Down Expand Up @@ -183,7 +183,7 @@ If an invitation has only one authorization and you want to remove it, delete th

**Returns:**

- ([viam.proto.app.OrganizationInvite](https://python.viam.dev/autoapi/viam/proto/app/index.html#viam.proto.app.OrganizationInvite)): The updated invite.
- ([app.OrganizationInvite](https://python.viam.dev/autoapi/viam/proto/app/index.html#viam.proto.app.OrganizationInvite)): The updated invite.

**Raises:**

Expand Down Expand Up @@ -290,7 +290,7 @@ Resend a pending organization invite email.

**Returns:**

- ([viam.proto.app.OrganizationInvite](https://python.viam.dev/autoapi/viam/proto/app/index.html#viam.proto.app.OrganizationInvite)): The organization invite sent.
- ([app.OrganizationInvite](https://python.viam.dev/autoapi/viam/proto/app/index.html#viam.proto.app.OrganizationInvite)): The organization invite sent.

**Raises:**

Expand Down
2 changes: 1 addition & 1 deletion static/include/components/apis/generated/arm.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ Get the kinematics information associated with the arm as the format and byte co

**Returns:**

- (Tuple[[viam.components.arm.KinematicsFileFormat.ValueType](https://python.viam.dev/autoapi/viam/components/arm/index.html#viam.components.arm.KinematicsFileFormat), [bytes](https://docs.python.org/3/library/stdtypes.html#bytes-objects)]): A tuple containing two values; the first [0] value represents the format of the file, either in URDF format or Viam’s kinematic parameter format (spatial vector algebra), and the second [1] value represents the byte contents of the file.
- (Tuple[[KinematicsFileFormat.ValueType](https://python.viam.dev/autoapi/viam/components/arm/index.html#viam.components.arm.KinematicsFileFormat), [bytes](https://docs.python.org/3/library/stdtypes.html#bytes-objects)]): A tuple containing two values; the first [0] value represents the format of the file, either in URDF format or Viam’s kinematic parameter format (spatial vector algebra), and the second [1] value represents the byte contents of the file.

**Example:**

Expand Down
2 changes: 1 addition & 1 deletion static/include/components/apis/generated/camera.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ The multiple images returned from `GetImages()` do not represent a time series o

**Returns:**

- (Tuple[List[[viam.media.video.NamedImage](https://python.viam.dev/autoapi/viam/media/video/index.html#viam.media.video.NamedImage)], [viam.proto.common.ResponseMetadata](https://python.viam.dev/autoapi/viam/gen/common/v1/common_pb2/index.html#viam.gen.common.v1.common_pb2.ResponseMetadata)]): A tuple containing two values; the first [0] a list of images returned from the camera system, and the second [1] the metadata associated with this response.
- (Tuple[List[[video.NamedImage](https://python.viam.dev/autoapi/viam/media/video/index.html#viam.media.video.NamedImage)], [common.ResponseMetadata](https://python.viam.dev/autoapi/viam/gen/common/v1/common_pb2/index.html#viam.gen.common.v1.common_pb2.ResponseMetadata)]): A tuple containing two values; the first [0] a list of images returned from the camera system, and the second [1] the metadata associated with this response.

**Example:**

Expand Down
4 changes: 2 additions & 2 deletions static/include/components/apis/generated/encoder.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ Absolute encoders return degrees.

**Parameters:**

- `position_type` ([viam.proto.component.encoder.PositionType.ValueType](https://python.viam.dev/autoapi/viam/gen/component/encoder/v1/encoder_pb2/index.html#viam.gen.component.encoder.v1.encoder_pb2.PositionType)) (optional): The desired output type of the position.
- `position_type` ([PositionType.ValueType](https://python.viam.dev/autoapi/viam/gen/component/encoder/v1/encoder_pb2/index.html#viam.gen.component.encoder.v1.encoder_pb2.PositionType)) (optional): The desired output type of the position.
- `extra` (Mapping[[str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), Any]) (optional): Extra options to pass to the underlying RPC call.
- `timeout` ([float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.

**Returns:**

- (Tuple[[float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex), [viam.proto.component.encoder.PositionType.ValueType](https://python.viam.dev/autoapi/viam/gen/component/encoder/v1/encoder_pb2/index.html#viam.gen.component.encoder.v1.encoder_pb2.PositionType)]): A tuple containing two values; the first [0] the Position of the encoder which can either be ticks since last zeroing for a relative encoder or degrees for an absolute encoder, and the second [1] the type of position the encoder returns (ticks or degrees).
- (Tuple[[float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex), [PositionType.ValueType](https://python.viam.dev/autoapi/viam/gen/component/encoder/v1/encoder_pb2/index.html#viam.gen.component.encoder.v1.encoder_pb2.PositionType)]): A tuple containing two values; the first [0] the Position of the encoder which can either be ticks since last zeroing for a relative encoder or degrees for an absolute encoder, and the second [1] the type of position the encoder returns (ticks or degrees).

**Example:**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ Supported by GPS models and `imu-wit`.

**Returns:**

- ([viam.components.movement_sensor.movement_sensor.MovementSensor.Accuracy](https://python.viam.dev/autoapi/viam/components/movement_sensor/movement_sensor/index.html#viam.components.movement_sensor.movement_sensor.MovementSensor.Accuracy)): The accuracies of the movement sensor.
- ([MovementSensor.Accuracy](https://python.viam.dev/autoapi/viam/components/movement_sensor/movement_sensor/index.html#viam.components.movement_sensor.movement_sensor.MovementSensor.Accuracy)): The accuracies of the movement sensor.

**Example:**

Expand Down

0 comments on commit dfb93b0

Please sign in to comment.