Skip to content

Commit

Permalink
Docs: Update model.md to be a guide on "Writing ASDF Pydantic Models …
Browse files Browse the repository at this point in the history
…to define tagged objects" (#15)

* Update model.md to be a guide on "Writing ASDF Models"

* docs: "ASDF Model" should be stylized as "ASDF Pydantic model"

* Fix lint
  • Loading branch information
ketozhang authored Jun 14, 2024
1 parent 5761218 commit 2e10ebc
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions docs/model.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
```{currentmodule} asdf_pydantic
```
# ASDF Pydantic Model

The {py:class}`AsdfPydanticModel` is a data model
[`pydantic.BaseModel`](https://docs.pydantic.dev/usage/models/) that is readily
serializable to ASDF.
# Writing ASDF Pydantic models to define tagged objects

The {py:class}`AsdfPydanticModel` is a class that combines the feature of
[`pydantic.BaseModel`](https://docs.pydantic.dev/usage/models/) and ASDF
to be readily serializable an tagged object in ASDF.

```py
class Rectangle(AsdfPydanticModel):
Expand All @@ -15,10 +14,11 @@ class Rectangle(AsdfPydanticModel):
height: float
```

`_tag` is a globally unique **ASDF tag** (see [naming best
This `Rectangle` model will be referenced in ASDF's YAML file as `!rectangle-1.0.0`
specified by the `_tag` field. `_tag` is a globally unique ASDF tag (see [naming best
practices](https://asdf.readthedocs.io/en/stable/asdf/extending/uris.html#tags))
that identifies the data model. This model contains two **fields**: `width` and
`height` and their **field type** are both `float`.
that identifies the ASDF Pydantic model. This model contains two fields: `width` and
`height` and their field type are both `float`.

## Field Types

Expand Down

0 comments on commit 2e10ebc

Please sign in to comment.