-
-
Notifications
You must be signed in to change notification settings - Fork 435
CDDL
ReSpec parses, syntax-highlights, and auto-links CDDL (Concise Data Definition Language, RFC 8610) inside <pre class="cddl"> blocks.
CDDL describes the shape of data: which fields a message carries, their types, and which are optional. Specs use it the way browser specs use WebIDL, but for wire formats and JSON or CBOR payloads rather than for JavaScript APIs. If your spec defines messages rather than interfaces, CDDL is probably what you want. RFC 8610 teaches the language itself; this page covers only what ReSpec does with it.
You get CDDL support automatically if your spec loads respec-w3c.js, which almost every
W3C spec does.
<pre class="cddl">
delivery = {
address: tstr,
zip: uint,
}
</pre>
<p>Each {^delivery^} has an {^delivery/address^} and a {^delivery/zip^}.</p>delivery becomes a definition you can link to. address and zip become member-key definitions scoped to delivery. tstr and uint auto-link to RFC 8610.
Wrap CDDL in <pre class="cddl">. References resolve across all blocks — a type used in one block can be defined in a later one.
To skip processing for a single block, add a data-no-cddl attribute to its <pre>.
Group blocks with data-cddl-module="<name>". Useful for protocols with distinct ends (for example, WebDriver BiDi's "local end" and "remote end"). The module name appears in the CDDL Index.
<pre class="cddl" data-cddl-module="local end">
Command = { id: uint, method: tstr, params: any }
</pre>
<pre class="cddl" data-cddl-module="remote end">
CommandResponse = { id: uint, result: any }
</pre>| Pattern in your CDDL | Becomes |
|---|---|
Rule LHS — name = …
|
A linkable type |
Rule extension — name /= … or //= …
|
Links to the existing definition (no duplicate) |
Bareword map key — key:
|
A linkable key, scoped to its enclosing rule |
String literal in a type choice — "value"
|
A linkable value, scoped to its enclosing rule |
All definitions are exported, so other specs can reference them via xref.
The standard RFC 8610 prelude types (tstr, uint, int, bool, bytes, etc.) are recognised and auto-link to RFC 8610 Appendix D. No setup needed.
Use {^…^} to link to a CDDL definition from the prose of your spec.
| Shorthand | Links to | Example |
|---|---|---|
{^name^} |
A type | {^delivery^} |
{^type/key^} |
A key on a type | {^delivery/address^} |
{^type/"value"^} |
A literal value on a type | {^attire/"bow tie"^} |
The quotes are significant — they distinguish a key name from a literal value.
If a {^…^} reference can't be resolved, ReSpec emits a warning and renders the link as plain text.
Add <section id="cddl-index"> and ReSpec fills it with every CDDL definition in the document.
<section id="cddl-index"></section>To exclude a block from the index, add class="exclude" to it. Blocks inside informative sections are excluded automatically. When you use data-cddl-module, the index groups by module.
- Invalid CDDL syntax — error. Fix the syntax in the offending block.
- Type referenced but never defined — warning. Likely a typo.
-
{^…^}with no matching definition — warning. Check spelling, theforscope, or that the definition exists in some<pre class="cddl">.
-
Shorthands-Guide — ReSpec's full inline shorthand reference (including
{^…^}) - WebIDL-Guide — the WebIDL equivalent for browser API surfaces
💖 Support ReSpec by becoming a sponsor via Open Collective. 💖
✨ View rendered version of this documentation at https://respec.org/docs/ ✨
- Getting Started
- How Do I…
- Spec Editor's Guide
- Writing Algorithms
- WebIDL Guide
- CDDL
- Configuring ReSpec
- Developers Guide
- Localizing ReSpec
- Shorthands
- addSectionLinks
- authors
- caniuse
- edDraftURI
- editors
- format (markdown)
- formerEditors
- github
- highlightVars
- implementationStatus
- isPreview
- license
- lint
- localBiblio
- logos
- maxTocLevel
- mdn
- modificationDate
- monetization
- noTOC
- otherLinks
- pluralize
- postProcess
- preProcess
- previousDiffURI
- previousMaturity
- previousPublishDate
- prevRecShortname
- prevRecURI
-
processVersion(Removed) - publishDate
- shortName
- specStatus
- subjectPrefix
- subtitle
- testSuiteURI
- xref
- additionalCopyrightHolders
-
addPatentNote(Removed) - alternateFormats
- canonicalURI
- charterDisclosureURI
- copyrightStart
- crEnd
- dark mode
- doJsonLd
- errata
- group
- implementationReportURI
- level
- noRecTrack
- prevED
- prEnd
- submissionCommentNumber
-
wg(Deprecated — usegroup) -
wgId(Deprecated — usegroup) -
wgPatentURI(Deprecated — usegroup) -
wgPublicList(Deprecated — usegroup) -
wgURI(Deprecated — usegroup)
a11ycheck-charsetcheck-internal-slotscheck-punctuationinformative-dfnlocal-refs-existno-captionless-tablesno-headingless-sectionsno-http-propsno-link-warningsno-unused-dfnsno-unused-varsprivsec-sectionwpt-tests-exist
Handled by ReSpec for you.
- conformance
- idl-index
- index
- issue-summary
- references
- tof (Table of Figures)
- data-abbr
- data-cite
- data-dfn-for
- data-dfn-type
- data-export
- data-format
- data-include
- data-include-format
- data-include-replace
- data-link-for
- data-link-type
- data-local-lt
- data-lt
- data-lt-no-plural
- data-lt-noDefault
- data-max-toc
- data-number
- data-oninclude
- data-sort
- data-tests
-
data-transform(Deprecated) - data-type
- dir
- lang