// Contract for the `doc` package. Types are defined in model.mbt / decls.mbt /
// file.mbt; this file declares the functional API.

///|
/// Build a doc comment from raw lines (no `///` prefixes; `""` for blank
/// lines).
declare pub fn DocComment::new(lines : Array[String]) -> DocComment

///|
/// An empty doc comment.
declare pub fn DocComment::empty() -> DocComment

///|
/// True when the comment has no lines.
declare pub fn DocComment::is_empty(self : DocComment) -> Bool

///|
/// Copy of the lines of a doc comment.
declare pub fn DocComment::copy_lines(self : DocComment) -> Array[String]

///|
/// A bare attribute (`#deprecated`).
declare pub fn Attribute::bare(name : String) -> Attribute

///|
/// An attribute with a parenthesised payload (`#derive(Debug, Eq)`).
declare pub fn Attribute::with_payload(
  name : String,
  payload : String,
) -> Attribute

///|
/// `#derive(...)` from trait names (`["Debug", "Eq"]` -> `#derive(Debug, Eq)`).
/// Empty input yields no attribute (`None`).
declare pub fn Attribute::derive_from(traits : Array[String]) -> Attribute?

///|
/// An unconstrained type parameter (`T`).
declare pub fn TypeParam::plain(name : String) -> TypeParam

///|
/// A trait-bounded type parameter (`T : A + B`).
declare pub fn TypeParam::bounded(
  name : String,
  constraints : Array[TypeExpr],
) -> TypeParam

///|
/// `@pkg.Type` style reference.
declare pub fn TypeExpr::qualified(pkg : String, name : String) -> TypeExpr

///|
/// `Array[T]`.
declare pub fn TypeExpr::array(inner : TypeExpr) -> TypeExpr

///|
/// `Map[String, T]`.
declare pub fn TypeExpr::map(value : TypeExpr) -> TypeExpr

///|
/// `T?`.
declare pub fn TypeExpr::optional(inner : TypeExpr) -> TypeExpr

///|
/// `&Trait` trait object type.
declare pub fn TypeExpr::object(trait_ : TypeExpr) -> TypeExpr

///|
/// Positional parameter `name : T`.
declare pub fn FnParam::positional(name : String, ty : TypeExpr) -> FnParam

///|
/// Discarded positional parameter `_ : T`.
declare pub fn FnParam::discard(ty : TypeExpr) -> FnParam

///|
/// Labelled parameter `name~ : T`.
declare pub fn FnParam::labelled(name : String, ty : TypeExpr) -> FnParam

///|
/// Question-optional parameter `name? : T`.
declare pub fn FnParam::optional(name : String, ty : TypeExpr) -> FnParam

///|
/// Defaulted parameter `name~ : T = `.
declare pub fn FnParam::defaulted(
  name : String,
  ty : TypeExpr,
  default_src : String,
) -> FnParam

///|
/// Construct a top-level item with optional doc comment and attributes.
declare pub fn Item::new(
  doc? : DocComment,
  attrs? : Array[Attribute],
  decl : Decl,
) -> Item

///|
/// Copy of the attributes attached to this item.
declare pub fn Item::copy_attrs(self : Item) -> Array[Attribute]

///|
/// A new, empty source file with no header comments.
declare pub fn SourceFile::new() -> SourceFile

///|
/// A new, empty source file with the given header comment lines (rendered as
/// leading `//` comments).
declare pub fn SourceFile::with_header(header : Array[String]) -> SourceFile

///|
/// Append an item to the file.
declare pub fn SourceFile::push(self : SourceFile, item : Item) -> Unit

///|
/// Number of items in the file.
declare pub fn SourceFile::length(self : SourceFile) -> Int32

///|
/// Copy of the leading header lines.
declare pub fn SourceFile::header_lines(self : SourceFile) -> Array[String]

///|
/// Copy of the items in the file.
declare pub fn SourceFile::copy_items(self : SourceFile) -> Array[Item]

///|
/// Shorthand: struct item.
declare pub fn struct_item(doc : DocComment, decl : StructDecl) -> Item

///|
/// Shorthand: enum item.
declare pub fn enum_item(doc : DocComment, decl : EnumDecl) -> Item

///|
/// Shorthand: suberror item.
declare pub fn suberror_item(doc : DocComment, decl : SuberrorDecl) -> Item

///|
/// Shorthand: plain item with a doc comment.
declare pub fn item(doc : DocComment, decl : Decl) -> Item

///|
/// Shorthand: item with a doc comment and explicit attributes.
declare pub fn item_with_attrs(
  doc : DocComment,
  attrs : Array[Attribute],
  decl : Decl,
) -> Item