M2doc access self items

Hello, I am new to M2doc, I am having a question on how to access the self items (self.eAllContents()). First of all, i have created a for loop to iterate the items:
{m:for package | self.eAllContents()}
{m:package}
{m:endfor}

The above expression lists all class, attribute, and reference implementations.
org.eclipse.emf.ecore.impl.EClassImpl@73c1a2a1 (name: Employee) (instanceClassName: null) (abstract: false, interface: false)
org.eclipse.emf.ecore.impl.EAttributeImpl@4201c991 (name: name) (ordered: true, unique: true, lowerBound: 1, upperBound: 1) (changeable: true, volatile: false, transient: false, defaultValueLiteral: null, unsettable: false, derived: false) (iD: false)

org.eclipse.emf.ecore.impl.EReferenceImpl@59c892a0 (name: Has) (ordered: true, unique: true, lowerBound: 1, upperBound: -1) (changeable: true, volatile: false, transient: false, defaultValueLiteral: null, unsettable: false, derived: false) (containment: true, resolveProxies: true)

but I don’t list all these details i only want to access the items when i want them, E.g: class name, with one or two attributes and the reference how is it possible to achieve this using M2doc?

The expression:

self.eAllContents()

lists all elements contained directly and indirectly by the self variable. I’m not sure what you are trying to achieve, but if you want to list all contained Class, you can add a filter:

self.eAllContents(information::Class)

and then access the Class name:

myClass.name

I have all the details using self.eAllContents() but i didn’t want it to be displayed at once, I would like to call each class from the self

I thought you were using Capella, but you are listing the content of an EPackage, so maybe:

{m:for package | self.eAllContents()}
  {m:if package.oclIsKindOf(ecore::EClass)}
    {m:package.name}
    {m:package.abstract}
    {m:package.interface}
    ...
  {m:if package.oclIsKindOf(ecore::EAttribute)}
    {m:package.name}
    {m:package.ordered}
    ...
  {m:endif}
{m:endfor}

To find avaliable features from an object you can use the M2Doc interpreter view if you are using M2Doc 3.2.0 or above. Otherwise, you can use the Sirius interpreter view.

Copyright © Eclipse Capella, the Eclipse Capella logo, Eclipse and the Eclipse logo are Trademarks of The Eclipse Foundation.