# The starting `#` and first space are stripped.
# The trailing `\n` are chomped.
var content = new Array[String]
+
+ # The entity where the documentation is originally attached to.
+ # This gives some context to resolve identifiers or to run examples.
+ var original_mentity: nullable MEntity writable = null
end
redef class MEntity
if decl != null then
var ndoc = decl.n_doc
- if ndoc != null then mmodule.mdoc = ndoc.to_mdoc
+ if ndoc != null then
+ var mdoc = ndoc.to_mdoc
+ mmodule.mdoc = mdoc
+ mdoc.original_mentity = mmodule
+ end
end
return mmodule
if nclassdef isa AStdClassdef then
var ndoc = nclassdef.n_doc
- if ndoc != null then mclassdef.mdoc = ndoc.to_mdoc
+ if ndoc != null then
+ var mdoc = ndoc.to_mdoc
+ mclassdef.mdoc = mdoc
+ mdoc.original_mentity = mclassdef
+ end
end
if mclassdef.is_intro then
private fun set_doc(mpropdef: MPropDef)
do
var ndoc = self.n_doc
- if ndoc != null then mpropdef.mdoc = ndoc.to_mdoc
+ if ndoc != null then
+ var mdoc = ndoc.to_mdoc
+ mpropdef.mdoc = mdoc
+ mdoc.original_mentity = mpropdef
+ end
end
private fun check_redef_property_visibility(modelbuilder: ModelBuilder, nclassdef: AClassdef, nvisibility: nullable AVisibility, mprop: MProperty)