Commit 97b727cb authored by Ralf Habacker's avatar Ralf Habacker
Browse files

Improve documentation fetch from petal nodes.

- Add PetalNode::documention() to fetch documentation
  from petal files, which converts petal documentation
  format to umbrello.

- Fetch documentation attribute from petal file for actor,
  class, use case, component, module and root view uml object types.

CCBUG:81364
parent c9a7d77c
......@@ -97,6 +97,23 @@ QString PetalNode::name() const
return m_initialArgs.first();
}
/**
* Return the documentation from a petal node with carriage
* return handling and removed surrounding quotation marks
* if present.
*/
QString PetalNode::documentation() const
{
QString s = findAttribute("documentation").string.trimmed();
if (s.isEmpty())
return s;
s.replace("\\n", "\n");
if (s.startsWith('\"') && s.endsWith('\"'))
return s.mid(1 ,s.length()-2);
else
return s;
}
PetalNode::NameValueList PetalNode::attributes() const
{
return m_attributes;
......
......@@ -64,6 +64,7 @@ public:
NodeType type() const;
QStringList initialArgs() const; // name and other initial args
QString name() const; // convenience function: equal to initialArgs().first()
QString documentation() const;
NameValueList attributes() const;
// setters
......
......@@ -247,9 +247,7 @@ public:
QString type = clean(attNode->findAttribute(m_itemTypeDesignator).string);
setTypeReferences(item, quidref, type);
transferVisibility(attNode, item);
QString doc = attNode->findAttribute("documentation").string;
if (! doc.isEmpty())
item->setDoc(doc);
item->setDoc(attNode->documentation());
insertAtParent(attNode, item);
}
}
......@@ -644,16 +642,19 @@ bool umbrellify(PetalNode *node, UMLPackage *parentPkg)
RealizationsReader realReader(c);
realReader.read(node, c->name());
}
o->setDoc(node->documentation());
parentPkg->addObject(o);
} else if (objType == "UseCase") {
UMLObject *o = Object_Factory::createUMLObject(UMLObject::ot_UseCase, name, parentPkg, false);
o->setID(id);
o->setDoc(node->documentation());
parentPkg->addObject(o);
} else if (objType == "Component" || objType == "module") {
UMLObject *o = Object_Factory::createUMLObject(UMLObject::ot_Component, name, parentPkg, false);
o->setID(id);
o->setDoc(node->documentation());
parentPkg->addObject(o);
} else if (objType == "Association") {
......@@ -713,9 +714,7 @@ bool umbrellify(PetalNode *node, UMLPackage *parentPkg)
if (containment == "By Value") {
assoc->setAssociationType(Uml::AssociationType::Composition);
}
QString doc = roleNode->findAttribute("documentation").string;
if (! doc.isEmpty())
role->setDoc(doc);
role->setDoc(roleNode->documentation());
}
assoc->setUMLPackage(parentPkg);
UMLApp::app()->document()->addAssociation(assoc);
......@@ -896,6 +895,7 @@ bool importView(PetalNode *root,
uError() << "cannot find " << modelsName << " of " << rootName;
return false;
}
parent->setDoc(viewRoot->documentation());
PetalNode::NameValueList atts = models->attributes();
bool status = true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment