@@ -2619,6 +2619,11 @@ end
26192619 hierarchy(sys::AbstractSystem; describe = false, bold = describe, kwargs...)
26202620
26212621Print a tree of a system's hierarchy of subsystems.
2622+
2623+ # Keyword arguments
2624+
2625+ - `describe`: Whether to also print the description of each subsystem, if present.
2626+ - `bold`: Whether to print the name of the system in **bold** font.
26222627"""
26232628function hierarchy (sys:: AbstractSystem ; describe = false , bold = describe, kwargs... )
26242629 print_tree (sys; printnode_kw = (describe = describe, bold = bold), kwargs... )
@@ -2661,9 +2666,14 @@ end
26612666"""
26622667$(TYPEDSIGNATURES)
26632668
2664- Extend `basesys` with `sys`.
2669+ Extend `basesys` with `sys`. This can be thought of as the `merge` operation on systems.
2670+ Values in `sys` take priority over duplicates in `basesys` (for example, defaults).
2671+
26652672By default, the resulting system inherits `sys`'s name and description.
26662673
2674+ The `&` operator can also be used for this purpose. `sys & basesys` is equivalent to
2675+ `extend(sys, basesys)`.
2676+
26672677See also [`compose`](@ref).
26682678"""
26692679function extend (sys:: AbstractSystem , basesys:: AbstractSystem ;
@@ -2710,14 +2720,31 @@ function extend(sys::AbstractSystem, basesys::AbstractSystem;
27102720 return T (args... ; kwargs... )
27112721end
27122722
2723+ """
2724+ $(TYPEDSIGNATURES)
2725+
2726+ Extend `sys` with all systems in `basesys` in order.
2727+ """
27132728function extend (sys, basesys:: Vector{T} ) where {T <: AbstractSystem }
27142729 foldl (extend, basesys, init = sys)
27152730end
27162731
2732+ """
2733+ $(TYPEDSIGNATURES)
2734+
2735+ Syntactic sugar for `extend(sys, basesys)`.
2736+
2737+ See also: [`extend`](@ref).
2738+ """
27172739function Base.:(& )(sys:: AbstractSystem , basesys:: AbstractSystem ; kwargs... )
27182740 extend (sys, basesys; kwargs... )
27192741end
27202742
2743+ """
2744+ $(TYPEDSIGNATURES)
2745+
2746+ Syntactic sugar for `extend(sys, basesys)`.
2747+ """
27212748function Base.:(& )(
27222749 sys:: AbstractSystem , basesys:: Vector{T} ; kwargs... ) where {T <: AbstractSystem }
27232750 extend (sys, basesys; kwargs... )
@@ -2726,8 +2753,11 @@ end
27262753"""
27272754$(SIGNATURES)
27282755
2729- Compose multiple systems together. The resulting system would inherit the first
2730- system's name.
2756+ Compose multiple systems together. This adds all of `systems` as subsystems of `sys`.
2757+ The resulting system inherits the name of `sys` by default.
2758+
2759+ The `∘` operator can also be used for this purpose. `sys ∘ basesys` is equivalent to
2760+ `compose(sys, basesys)`.
27312761
27322762See also [`extend`](@ref).
27332763"""
@@ -2749,9 +2779,22 @@ function compose(sys::AbstractSystem, systems::AbstractArray; name = nameof(sys)
27492779 @set! sys. ps = unique! (vcat (get_ps (sys), collect (newparams)))
27502780 return sys
27512781end
2782+ """
2783+ $(TYPEDSIGNATURES)
2784+
2785+ Syntactic sugar for adding all systems in `syss` as the subsystems of `first(syss)`.
2786+ """
27522787function compose (syss... ; name = nameof (first (syss)))
27532788 compose (first (syss), collect (syss[2 : end ]); name = name)
27542789end
2790+
2791+ """
2792+ $(TYPEDSIGNATURES)
2793+
2794+ Syntactic sugar for `compose(sys1, sys2)`.
2795+
2796+ See also: [`compose`](@ref).
2797+ """
27552798Base.:(∘ )(sys1:: AbstractSystem , sys2:: AbstractSystem ) = compose (sys1, sys2)
27562799
27572800function UnPack. unpack (sys:: ModelingToolkit.AbstractSystem , :: Val{p} ) where {p}
0 commit comments