Skip to content

Commit fba3023

Browse files
committed
Convert generated doc links to reStructuredText
1 parent 4bdf96d commit fba3023

67 files changed

Lines changed: 1201 additions & 1196 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

codegen/lib/layouts/resources.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { Blueprint, Property, Resource } from '@seamapi/blueprint'
66
import { pascalCase, snakeCase } from 'change-case'
77

88
import { convertCustomResourceName } from '../custom-resource-name-conversions.js'
9+
import { formatPythonDoc } from '../python-docstring.js'
910
import { mapPropertyToPythonType } from '../python-type.js'
1011

1112
// Python hard keywords cannot be used as identifiers. When a property name
@@ -65,25 +66,22 @@ export interface ResourceLayoutContext {
6566
}>
6667
}
6768

68-
const cleanDoc = (value: string): string =>
69-
value.trim().replaceAll('"""', '\\"\\"\\"')
70-
7169
const createResourceDocstring = (
7270
description: string,
7371
isDeprecated: boolean,
7472
deprecationMessage: string,
7573
properties: Property[],
7674
): string => {
77-
const lines = [cleanDoc(description)]
75+
const lines = [formatPythonDoc(description)]
7876
for (const property of properties) {
7977
const deprecated = property.isDeprecated
80-
? `Deprecated${property.deprecationMessage === '' ? '.' : `: ${cleanDoc(property.deprecationMessage)}`}`
78+
? `Deprecated${property.deprecationMessage === '' ? '.' : `: ${formatPythonDoc(property.deprecationMessage)}`}`
8179
: ''
8280
lines.push(
8381
'',
8482
`:ivar ${toSafeIdentifier(property.name)}: ${[
8583
deprecated,
86-
cleanDoc(property.description),
84+
formatPythonDoc(property.description),
8785
]
8886
.filter(Boolean)
8987
.join(' ')}`,
@@ -94,7 +92,7 @@ const createResourceDocstring = (
9492
lines.push(
9593
'',
9694
'.. deprecated::',
97-
` ${cleanDoc(deprecationMessage) || 'This resource is deprecated.'}`,
95+
` ${formatPythonDoc(deprecationMessage) || 'This resource is deprecated.'}`,
9896
)
9997
}
10098
return lines

codegen/lib/layouts/route.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
type ClassModel,
99
sortClassMethodParameters,
1010
} from '../class-model.js'
11+
import { formatPythonDoc } from '../python-docstring.js'
1112

1213
export interface MethodLayoutContext {
1314
name: string
@@ -57,23 +58,20 @@ export interface RouteLayoutContext {
5758
const waitForActionAttemptParameter =
5859
'wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = None'
5960

60-
const cleanDoc = (value: string): string =>
61-
value.trim().replaceAll('"""', '\\"\\"\\"')
62-
6361
const indentDoc = (value: string, spaces: number): string =>
6462
value.replaceAll('\n', `\n${' '.repeat(spaces)}`)
6563

6664
const methodDocstring = (
6765
method: ClassMethod,
6866
sortedParameters: ClassMethod['parameters'],
6967
): string => {
70-
const lines = [cleanDoc(method.description)]
68+
const lines = [formatPythonDoc(method.description)]
7169

7270
for (const parameter of sortedParameters) {
7371
const deprecated = parameter.isDeprecated
74-
? `Deprecated${parameter.deprecationMessage === '' ? '.' : `: ${cleanDoc(parameter.deprecationMessage)}`}`
72+
? `Deprecated${parameter.deprecationMessage === '' ? '.' : `: ${formatPythonDoc(parameter.deprecationMessage)}`}`
7573
: ''
76-
const description = cleanDoc(parameter.description)
74+
const description = formatPythonDoc(parameter.description)
7775
lines.push(
7876
'',
7977
`:param ${parameter.name}: ${[deprecated, description].filter(Boolean).join(' ')}`,
@@ -92,7 +90,7 @@ const methodDocstring = (
9290
if (method.returnResource !== 'None') {
9391
lines.push(
9492
'',
95-
`:returns: ${cleanDoc(method.responseDescription)}`,
93+
`:returns: ${formatPythonDoc(method.responseDescription)}`,
9694
`:rtype: ${method.returnResource}`,
9795
)
9896
}
@@ -101,7 +99,7 @@ const methodDocstring = (
10199
lines.push(
102100
'',
103101
'.. deprecated::',
104-
` ${cleanDoc(method.deprecationMessage) || 'This method is deprecated.'}`,
102+
` ${formatPythonDoc(method.deprecationMessage) || 'This method is deprecated.'}`,
105103
)
106104
}
107105

codegen/lib/python-docstring.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Blueprint descriptions use Markdown, while the generated Python docstrings
2+
// use Sphinx/reStructuredText fields. Normalize the Markdown constructs that
3+
// would otherwise be displayed literally (or interpreted as invalid roles).
4+
export const formatPythonDoc = (value: string): string =>
5+
value
6+
.trim()
7+
.replaceAll('"""', '\\"\\"\\"')
8+
.replaceAll(/(?<!`)`([^`\n]+)`(?!`)/g, '``$1``')
9+
.replaceAll(/\[([^\]]+)]\(([^)]+)\)/g, '`$1 <$2>`_')

seam/resources/access_code.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
@dataclass
77
class AccessCode:
8-
"""Represents a smart lock [access code](https://docs.seam.co/low-level-apis/smart-locks/access-codes).
8+
"""Represents a smart lock `access code <https://docs.seam.co/low-level-apis/smart-locks/access-codes>`_.
99
1010
An access code is a code used for a keypad or pinpad device. Unlike physical keys, which can easily be lost or duplicated, PIN codes can be customized, tracked, and altered on the fly. Using the Seam Access Code API, you can easily generate access codes on the hundreds of door lock models with which we integrate.
1111
12-
Seam supports programming two types of access codes: [ongoing](https://docs.seam.co/low-level-apis/smart-locks/access-codes#ongoing-access-codes) and [time-bound](https://docs.seam.co/low-level-apis/smart-locks/access-codes#time-bound-access-codes). To differentiate between the two, refer to the `type` property of the access code. Ongoing codes display as `ongoing`, whereas time-bound codes are labeled `time_bound`. An ongoing access code is active, until it has been removed from the device. To specify an ongoing access code, leave both `starts_at` and `ends_at` empty. A time-bound access code will be programmed at the `starts_at` time and removed at the `ends_at` time.
12+
Seam supports programming two types of access codes: `ongoing <https://docs.seam.co/low-level-apis/smart-locks/access-codes#ongoing-access-codes>`_ and `time-bound <https://docs.seam.co/low-level-apis/smart-locks/access-codes#time-bound-access-codes>`_. To differentiate between the two, refer to the ``type`` property of the access code. Ongoing codes display as ``ongoing``, whereas time-bound codes are labeled ``time_bound``. An ongoing access code is active, until it has been removed from the device. To specify an ongoing access code, leave both ``starts_at`` and ``ends_at`` empty. A time-bound access code will be programmed at the ``starts_at`` time and removed at the ``ends_at`` time.
1313
14-
In addition, for certain devices, Seam also supports [offline access codes](https://docs.seam.co/low-level-apis/smart-locks/access-codes#offline-access-codes). Offline access (PIN) codes are designed for door locks that might not always maintain an internet connection. For this type of access code, the device manufacturer uses encryption keys (tokens) to create server-based registries of algorithmically-generated offline PIN codes. Because the tokens remain synchronized with the managed devices, the locks do not require an active internet connection—and you do not need to be near the locks—to create an offline access code. Then, owners or managers can share these offline codes with users through a variety of mechanisms, such as messaging applications. That is, lock users do not need to install a smartphone application to receive an offline access code.
14+
In addition, for certain devices, Seam also supports `offline access codes <https://docs.seam.co/low-level-apis/smart-locks/access-codes#offline-access-codes>`_. Offline access (PIN) codes are designed for door locks that might not always maintain an internet connection. For this type of access code, the device manufacturer uses encryption keys (tokens) to create server-based registries of algorithmically-generated offline PIN codes. Because the tokens remain synchronized with the managed devices, the locks do not require an active internet connection—and you do not need to be near the locks—to create an offline access code. Then, owners or managers can share these offline codes with users through a variety of mechanisms, such as messaging applications. That is, lock users do not need to install a smartphone application to receive an offline access code.
1515
16-
For granting a person access to a space, [Access Grants](https://docs.seam.co/use-cases/granting-access) are the default and recommended approach and work across both standalone smart locks and access systems. Use the lower-level Access Codes API directly only when you specifically need to manage individual PIN codes.
16+
For granting a person access to a space, `Access Grants <https://docs.seam.co/use-cases/granting-access>`_ are the default and recommended approach and work across both standalone smart locks and access systems. Use the lower-level Access Codes API directly only when you specifically need to manage individual PIN codes.
1717
1818
:ivar access_code_id: Unique identifier for the access code.
1919
:vartype access_code_id: str
@@ -36,7 +36,7 @@ class AccessCode:
3636
:ivar ends_at: Date and time after which the time-bound access code becomes inactive.
3737
:vartype ends_at: str
3838
39-
:ivar errors: Errors associated with the [access code](https://docs.seam.co/low-level-apis/smart-locks/access-codes).
39+
:ivar errors: Errors associated with the `access code <https://docs.seam.co/low-level-apis/smart-locks/access-codes>`_.
4040
:vartype errors: List[Dict[str, Any]]
4141
4242
:ivar is_backup: Indicates whether the access code is a backup code.
@@ -51,10 +51,10 @@ class AccessCode:
5151
:ivar is_managed: Indicates whether Seam manages the access code.
5252
:vartype is_managed: bool
5353
54-
:ivar is_offline_access_code: Indicates whether the access code is intended for use in offline scenarios. If `true`, this code can be created on a device without a network connection.
54+
:ivar is_offline_access_code: Indicates whether the access code is intended for use in offline scenarios. If ``true``, this code can be created on a device without a network connection.
5555
:vartype is_offline_access_code: bool
5656
57-
:ivar is_one_time_use: Indicates whether the access code can only be used once. If `true`, the code becomes invalid after the first use.
57+
:ivar is_one_time_use: Indicates whether the access code can only be used once. If ``true``, the code becomes invalid after the first use.
5858
:vartype is_one_time_use: bool
5959
6060
:ivar is_scheduled_on_device: Indicates whether the code is set on the device according to a preconfigured schedule.
@@ -63,7 +63,7 @@ class AccessCode:
6363
:ivar is_waiting_for_code_assignment: Indicates whether the access code is waiting for a code assignment.
6464
:vartype is_waiting_for_code_assignment: bool
6565
66-
:ivar name: Name of the access code. Enables administrators and users to identify the access code easily, especially when there are numerous access codes. Note that the name provided on Seam is used to identify the code on Seam and is not necessarily the name that will appear in the lock provider's app or on the device. This is because lock providers may have constraints on names, such as length, uniqueness, or characters that can be used. In addition, some lock providers may break down names into components such as `first_name` and `last_name`. To provide a consistent experience, Seam identifies the code on Seam by its name but may modify the name that appears on the lock provider's app or on the device. For example, Seam may add additional characters or truncate the name to meet provider constraints. To help your users identify codes set by Seam, Seam provides the name exactly as it appears on the lock provider's app or on the device as a separate property called `appearance`. This is an object with a `name` property and, optionally, `first_name` and `last_name` properties (for providers that break down a name into components).
66+
:ivar name: Name of the access code. Enables administrators and users to identify the access code easily, especially when there are numerous access codes. Note that the name provided on Seam is used to identify the code on Seam and is not necessarily the name that will appear in the lock provider's app or on the device. This is because lock providers may have constraints on names, such as length, uniqueness, or characters that can be used. In addition, some lock providers may break down names into components such as ``first_name`` and ``last_name``. To provide a consistent experience, Seam identifies the code on Seam by its name but may modify the name that appears on the lock provider's app or on the device. For example, Seam may add additional characters or truncate the name to meet provider constraints. To help your users identify codes set by Seam, Seam provides the name exactly as it appears on the lock provider's app or on the device as a separate property called ``appearance``. This is an object with a ``name`` property and, optionally, ``first_name`` and ``last_name`` properties (for providers that break down a name into components).
6767
:vartype name: str
6868
6969
:ivar pending_mutations: Collection of pending mutations for the access code. Indicates changes that Seam is in the process of pushing to the device.
@@ -75,13 +75,13 @@ class AccessCode:
7575
:ivar starts_at: Date and time at which the time-bound access code becomes active.
7676
:vartype starts_at: str
7777
78-
:ivar status: Current status of the access code within the operational lifecycle. Values are `setting`, a transitional phase that indicates that the code is being configured or activated; `set`, which indicates that the code is active and operational; `unset`, which indicates a deactivated or unused state, either before activation or after deliberate deactivation; `removing`, which indicates a transitional period in which the code is being deleted or made inactive; and `unknown`, which indicates an indeterminate state, due to reasons such as system errors or incomplete data, that highlights a potential need for system review or troubleshooting. See also [Lifecycle of Access Codes](https://docs.seam.co/low-level-apis/smart-locks/access-codes/lifecycle-of-access-codes).
78+
:ivar status: Current status of the access code within the operational lifecycle. Values are ``setting``, a transitional phase that indicates that the code is being configured or activated; ``set``, which indicates that the code is active and operational; ``unset``, which indicates a deactivated or unused state, either before activation or after deliberate deactivation; ``removing``, which indicates a transitional period in which the code is being deleted or made inactive; and ``unknown``, which indicates an indeterminate state, due to reasons such as system errors or incomplete data, that highlights a potential need for system review or troubleshooting. See also `Lifecycle of Access Codes <https://docs.seam.co/low-level-apis/smart-locks/access-codes/lifecycle-of-access-codes>`_.
7979
:vartype status: str
8080
81-
:ivar type: Type of the access code. `ongoing` access codes are active continuously until deactivated manually. `time_bound` access codes have a specific duration.
81+
:ivar type: Type of the access code. ``ongoing`` access codes are active continuously until deactivated manually. ``time_bound`` access codes have a specific duration.
8282
:vartype type: str
8383
84-
:ivar warnings: Warnings associated with the [access code](https://docs.seam.co/low-level-apis/smart-locks/access-codes).
84+
:ivar warnings: Warnings associated with the `access code <https://docs.seam.co/low-level-apis/smart-locks/access-codes>`_.
8585
:vartype warnings: List[Dict[str, Any]]
8686
8787
:ivar workspace_id: Unique identifier for the Seam workspace associated with the access code.

seam/resources/access_grant.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ class AccessGrant:
3131
:ivar ends_at: Date and time at which the Access Grant ends.
3232
:vartype ends_at: str
3333
34-
:ivar errors: Errors associated with the [access grant](https://docs.seam.co/use-cases/granting-access).
34+
:ivar errors: Errors associated with the `access grant <https://docs.seam.co/use-cases/granting-access>`_.
3535
:vartype errors: List[Dict[str, Any]]
3636
3737
:ivar instant_key_url: Instant Key URL. Only returned if the Access Grant has a single mobile_key access_method.
3838
:vartype instant_key_url: str
3939
40-
:ivar location_ids: Deprecated: Use `space_ids`.
40+
:ivar location_ids: Deprecated: Use ``space_ids``.
4141
:vartype location_ids: List[str]
4242
4343
:ivar name: Name of the Access Grant. If not provided, the display name will be computed.
@@ -61,7 +61,7 @@ class AccessGrant:
6161
:ivar user_identity_id: ID of user identity to which the Access Grant gives access.
6262
:vartype user_identity_id: str
6363
64-
:ivar warnings: Warnings associated with the [access grant](https://docs.seam.co/use-cases/granting-access).
64+
:ivar warnings: Warnings associated with the `access grant <https://docs.seam.co/use-cases/granting-access>`_.
6565
:vartype warnings: List[Dict[str, Any]]
6666
6767
:ivar workspace_id: ID of the Seam workspace associated with the Access Grant.

seam/resources/access_method.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class AccessMethod:
2525
:ivar display_name: Display name of the access method.
2626
:vartype display_name: str
2727
28-
:ivar errors: Errors associated with the [access method](https://docs.seam.co/use-cases/granting-access/creating-an-access-grant).
28+
:ivar errors: Errors associated with the `access method <https://docs.seam.co/use-cases/granting-access/creating-an-access-grant>`_.
2929
:vartype errors: List[Dict[str, Any]]
3030
3131
:ivar instant_key_url: URL of the Instant Key for mobile key access methods.
@@ -49,13 +49,13 @@ class AccessMethod:
4949
:ivar issued_at: Date and time at which the access method was issued.
5050
:vartype issued_at: str
5151
52-
:ivar mode: Access method mode. Supported values: `code`, `card`, `mobile_key`, `cloud_key`.
52+
:ivar mode: Access method mode. Supported values: ``code``, ``card``, ``mobile_key``, ``cloud_key``.
5353
:vartype mode: str
5454
55-
:ivar pending_mutations: Pending mutations for the [access method](https://docs.seam.co/use-cases/granting-access/creating-an-access-grant). Indicates operations that are in progress.
55+
:ivar pending_mutations: Pending mutations for the `access method <https://docs.seam.co/use-cases/granting-access/creating-an-access-grant>`_. Indicates operations that are in progress.
5656
:vartype pending_mutations: List[Dict[str, Any]]
5757
58-
:ivar warnings: Warnings associated with the [access method](https://docs.seam.co/use-cases/granting-access/creating-an-access-grant).
58+
:ivar warnings: Warnings associated with the `access method <https://docs.seam.co/use-cases/granting-access/creating-an-access-grant>`_.
5959
:vartype warnings: List[Dict[str, Any]]
6060
6161
:ivar workspace_id: ID of the Seam workspace associated with the access method.

0 commit comments

Comments
 (0)