Skip to content

Commit 46d6a11

Browse files
tausbnCopilot
andcommitted
yeast: Clarify Ast::with_schema registration doc
The doc claimed the schema passed to `Ast::with_schema` must already have every node kind and field name registered, contradicting the registration methods just below and the swift-syntax adapter, which starts from `Schema::new()` and registers names on demand during construction. Document that up-front registration is optional. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3eb353e commit 46d6a11

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

shared/yeast/src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,14 @@ impl Ast {
358358
/// programmatically from a source other than a tree-sitter parse (e.g. an
359359
/// external parser's output). Populate it with [`Ast::create_node`] /
360360
/// [`Ast::create_node_with_range`] and then designate the root with
361-
/// [`Ast::set_root`]. The `schema` must already have every node kind and
362-
/// field name registered (see [`schema::Schema`]).
361+
/// [`Ast::set_root`].
362+
///
363+
/// Node kind and field names may be registered in `schema` up front, or on
364+
/// demand while building via [`Ast::register_kind`],
365+
/// [`Ast::register_unnamed_kind`], and [`Ast::register_field`] (which return
366+
/// the ids to pass to [`Ast::create_node_with_range`]). Passing a fresh
367+
/// [`schema::Schema::new`] and registering names during construction is
368+
/// therefore fine — see the swift-syntax adapter for an example.
363369
pub fn with_schema(schema: schema::Schema) -> Self {
364370
Self {
365371
root: Id(0),

0 commit comments

Comments
 (0)