Skip to content

Commit 71b7552

Browse files
committed
Show system and subsystem descriptions
1 parent 7432e39 commit 71b7552

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/systems/abstractsystem.jl

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1888,15 +1888,26 @@ function Base.show(io::IO, mime::MIME"text/plain", sys::AbstractSystem; bold = t
18881888
limit = get(io, :limit, false) # if output should be limited,
18891889
rows = first(displaysize(io)) ÷ 5 # then allocate ≈1/5 of display height to each list
18901890

1891-
# Print name
1892-
printstyled(io, "Model $(nameof(sys))"; bold)
1891+
# Print name and description
1892+
desc = get_description(sys)
1893+
printstyled(io, "Model ", nameof(sys); bold)
1894+
!isempty(desc) && print(io, ": ", desc)
18931895

1894-
# Print subsystems # TODO: limit
1895-
subs = nameof.(ModelingToolkit.get_systems(sys))
1896+
# Print subsystems
1897+
subs = sys.systems
18961898
nsubs = length(subs)
18971899
nsubs > 0 && printstyled(io, "\nSubsystems ($(nsubs)): "; bold)
18981900
for sub in subs
1899-
print(io, "\n ", sub)
1901+
name = String(nameof(sub))
1902+
print(io, "\n ", name)
1903+
desc = get_description(sub)
1904+
if !isempty(desc)
1905+
maxlen = displaysize(io)[2] - length(name) - 6 # remaining length of line
1906+
if limit && length(desc) > maxlen
1907+
desc = chop(desc, tail = length(desc) - maxlen) * "" # too long
1908+
end
1909+
print(io, ": ", desc)
1910+
end
19001911
end
19011912

19021913
# Print equations

0 commit comments

Comments
 (0)