Property definitions

nitc $ CmdSummary :: defaultinit
# Retrieve the MDoc summary
#
# List all MarkdownHeading found and their ids.
class CmdSummary
	super CmdComment

	# Markdown processor used to parse the headlines
	var markdown_processor: MarkdownProcessor is writable

	# Resulting summary
	#
	# Associates each headline to its id.
	var summary: nullable ArrayMap[String, HeadLine] = null is optional, writable

	redef fun init_command do
		var res = super
		if not res isa CmdSuccess then return res
		var mentity = self.mentity.as(not null)

		var mdoc = self.mdoc
		if mdoc == null then
			mdoc = if fallback then mentity.mdoc_or_fallback else mentity.mdoc
			self.mdoc = mdoc
		end
		if mdoc == null then return new WarningNoMDoc(mentity)

		markdown_processor.process(mdoc.md_documentation.write_to_string)

		var summary = new ArrayMap[String, HeadLine]
		summary.add_all markdown_processor.decorator.headlines
		self.summary = summary
		return res
	end
end
src/doc/commands/commands_docdown.nit:21,1--54,3