Regenerates the SchemaOrg.* type modules from the official Schema.org JSON-LD graph.
This task is for library maintainers only. It is not part of the runtime
and is not shipped in the Hex package. It reads the vendored graph, maps every
Property onto the Classes in its domainIncludes (plus inherited Classes via
subClassOf), and renders one Elixir module per Class through an EEx template.
mix schema_org.build_types
mix schema_org.build_types --file priv/schemaorg-current-https.jsonld --out lib/schema_org/typesOptions
--file- path to the Schema.org JSON-LD graph (default:priv/schemaorg-current-https.jsonld)--out- output directory for generated modules (default:lib/schema_org/types)
Download the graph with:
curl -L https://schema.org/version/latest/schemaorg-current-https.jsonld \
-o priv/schemaorg-current-https.jsonld
Summary
Functions
Transitive ancestor class ids of class_id, cycle-safe.
Turns a decoded JSON-LD graph into a sorted list of module specs, each ready to
render: %{module_name, schema_type, moduledoc, filename, properties}.
Normalises an rdfs:comment (string, list, or @value map) to plain text.
Builds the render descriptor for a single property node.
Builds %{class_id => [property_id, ...]} from each property's domainIncludes.
Maps a Schema.org property local name to a snakecase field name, suffixing any
Elixir keyword with `(e.g."dateModified"→:datemodified,"in"→:in`).
Strips the schema: prefix from an @id (e.g. "schema:Product" → "Product").
Maps a Schema.org local name to a valid Elixir module alias.
Normalises a polymorphic Schema.org field into a flat list of id strings.
Builds %{class_id => [parent_class_id, ...]} from each class's subClassOf.
Splits the graph's @graph into {classes, properties}.
All property ids valid on a class: its own (via domainIncludes) plus every
property inherited from a transitive subClassOf ancestor. Deduplicated.
Renders a module spec to formatted Elixir source via the EEx template.
Functions
Transitive ancestor class ids of class_id, cycle-safe.
Turns a decoded JSON-LD graph into a sorted list of module specs, each ready to
render: %{module_name, schema_type, moduledoc, filename, properties}.
Normalises an rdfs:comment (string, list, or @value map) to plain text.
Builds the render descriptor for a single property node.
Builds %{class_id => [property_id, ...]} from each property's domainIncludes.
Maps a Schema.org property local name to a snakecase field name, suffixing any
Elixir keyword with `(e.g."dateModified"→:datemodified,"in"→:in`).
Strips the schema: prefix from an @id (e.g. "schema:Product" → "Product").
Maps a Schema.org local name to a valid Elixir module alias.
PascalCase names pass through. A leading-lowercase name is capitalised. Names
that are not valid aliases (e.g. "3DModel", which starts with a digit) are
prefixed with Type and stripped of non-alphanumerics — while schema_type
keeps the exact original, so the emitted JSON-LD @type stays correct.
Normalises a polymorphic Schema.org field into a flat list of id strings.
Handles all four shapes the spec uses interchangeably: nil (absent), a bare
string (e.g. an @type value), a single %{"@id" => id} object, and a list of
any of the above.
Builds %{class_id => [parent_class_id, ...]} from each class's subClassOf.
Splits the graph's @graph into {classes, properties}.
All property ids valid on a class: its own (via domainIncludes) plus every
property inherited from a transitive subClassOf ancestor. Deduplicated.
Renders a module spec to formatted Elixir source via the EEx template.
Raises if the generated code is not valid Elixir (the format pass parses it), which surfaces template/sanitiser bugs immediately instead of writing junk.