Property definitions

nitc $ CardInheritance :: defaultinit
# A card about the inheritance of a MEntity
class CardInheritance
	super CardMEntity

	# Ancestors list
	var ancestors: nullable Array[MEntity] is writable

	# Parents list
	var parents: nullable Array[MEntity] is writable

	# Children list
	var children: nullable Array[MEntity] is writable

	# Descendants list
	var descendants: nullable Array[MEntity] is writable

	redef var id = "inh_{super}" is lazy
	redef var title = "Inheritance" is lazy

	redef fun rendering do
		var ancestors = self.ancestors
		var descendants = self.descendants
		if ancestors == null and parents == null and
			children == null and descendants == null then return

		addn "<div id='{id}' class='card'>"
		addn " <div class='card-body'>"
		if ancestors != null and ancestors.length <= 10 then
			render_list("Ancestors", ancestors)
		else
			render_list("Parents", parents)
		end
		if descendants != null and descendants.length <= 10 then
			render_list("Descendants", descendants)
		else
			render_list("Children", children)
		end
		addn " </div>"
		addn "</div>"
	end

	private fun render_list(title: String, mentities: nullable Array[MEntity]) do
		if mentities == null or mentities.is_empty then return
		addn "<h4 id='{id}'>{title}</h4>"
		addn "<ul class='list-unstyled'>"
		for mentity in mentities do
			addn html_list_item(mentity)
		end
		addn "</ul>"
	end

	private fun html_list_item(mentity: MEntity): ListItem do
		var tpl = new Template
		tpl.add mentity.html_namespace
		var comment = mentity.mdoc_or_fallback
		if comment != null then
			tpl.add ": "
			tpl.add comment.html_synopsis
		end
		return new ListItem(tpl)
	end
end
src/doc/static/static_cards.nit:236,1--297,3