Right now, it is possible to collapse/fold certain types of sections, plots and tables, but not others, especially normal text sections. Other sections like hyperparams are always folded with no way to disable that. It would be nice if all types of sections could be folded in a consistent manner.
To achieve this, all Section classes should have a folded parameter and all add_* methods should expose it. It might be useful to change the Section's format methods to _format and to add a format method that adds the folding:
@dataclass
class Section:
...
folded: bool = False
...
def _format(self) -> str: # <= used to be format
return self.content
def format(self) -> str: # <= new format takes care of folding
return wrap_as_details(self._format(), folded=self.folded)
This would be a small deviation from current behavior. Right now, if I add, say, a table with a description and with folded=True, only the table is folded, not the description. With the proposed change, everything would be folded, but I think that's actually better.
With #310 being merged, it would also be possible to change the folding after the fact:
model_card.add_plot(..., folded=False)
# nah, let's fold it
model_card.select(<fig section name>).folded = True
If users add multiple contents with a single add call, then the folded parameter would be the same for all of them. If they want to have some folded and some non-folded contents, they would need to call add multiple times.
An open question to me is what to do with the subsections if a section is folded.
Right now, it is possible to collapse/fold certain types of sections, plots and tables, but not others, especially normal text sections. Other sections like hyperparams are always folded with no way to disable that. It would be nice if all types of sections could be folded in a consistent manner.
To achieve this, all
Sectionclasses should have afoldedparameter and alladd_*methods should expose it. It might be useful to change theSection'sformatmethods to_formatand to add aformatmethod that adds the folding:This would be a small deviation from current behavior. Right now, if I add, say, a table with a
descriptionand withfolded=True, only the table is folded, not the description. With the proposed change, everything would be folded, but I think that's actually better.With #310 being merged, it would also be possible to change the folding after the fact:
If users add multiple contents with a single
addcall, then thefoldedparameter would be the same for all of them. If they want to have some folded and some non-folded contents, they would need to calladdmultiple times.An open question to me is what to do with the subsections if a section is folded.