Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schuetz2012-02-02 11:20:05 +0000
committerThomas Schuetz2012-02-02 11:20:05 +0000
commit36fbd952aec9525e41a266c64644c740ebcb9344 (patch)
treec277094322c6eec60b4f13ddf26c2ac9ebd2a89d
parentcfe46b9799947e484ed42a2eefded0db55d43904 (diff)
downloadorg.eclipse.etrice-36fbd952aec9525e41a266c64644c740ebcb9344.tar.gz
org.eclipse.etrice-36fbd952aec9525e41a266c64644c740ebcb9344.tar.xz
org.eclipse.etrice-36fbd952aec9525e41a266c64644c740ebcb9344.zip
[generator.doc] first version DocGen
-rw-r--r--plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/gen/DocGen.xtend77
-rw-r--r--plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/gen/MainGen.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/DocGen.java120
-rw-r--r--plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java4
-rw-r--r--plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/MainGen.java7
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java5
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/extensions/RoomExtensions.xtend8
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java11
-rw-r--r--runtime/org.eclipse.etrice.modellib/doc-gen/room.basic.types.java.tex3
-rw-r--r--tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.SendingDataByValueTest.room6
11 files changed, 236 insertions, 9 deletions
diff --git a/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/gen/DocGen.xtend b/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/gen/DocGen.xtend
new file mode 100644
index 000000000..5376e0a2c
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/gen/DocGen.xtend
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Jung, Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.doc.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.etrice.core.room.RoomModel
+import org.eclipse.etrice.core.room.Documentation
+import org.eclipse.etrice.core.room.ActorClass
+import org.eclipse.etrice.generator.base.ILogger
+import org.eclipse.etrice.generator.base.IRoomGenerator
+import org.eclipse.etrice.generator.etricegen.Root
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+import org.eclipse.etrice.generator.extensions.RoomExtensions
+
+@Singleton
+class DocGen implements IRoomGenerator {
+
+ @Inject extension JavaIoFileSystemAccess fileAccess
+ @Inject extension RoomExtensions roomExt
+ @Inject ILogger logger
+
+ override doGenerate(Root root) {
+ for (model: root.models) {
+ var path = model.docGenerationTargetPath
+ var file = model.name+".tex"
+ logger.logInfo("generating LaTeX documentation: '"+file+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(file, root.generateModelDoc(model))
+ }
+ }
+
+ def generateModelDoc(Root root, RoomModel model) {'''
+ \documentationclass[titlepage]{article}
+ «model.name»
+ «root.generateAllActorClassDocs(model)»
+ \end{document}
+ '''
+ }
+
+ def generateAllActorClassDocs(Root root, RoomModel model) {'''
+ «FOR ac : model.actorClasses»
+ «root.generateActorClassDoc(ac)»
+ «ENDFOR»
+ '''
+ }
+
+ def generateActorClassDoc(Root root, ActorClass ac) {'''
+ \subsection{«ac.name»}
+ «root.irgendwas(ac)»
+ «ac.docu.generateDocText»
+ «ac.name»
+ '''
+ }
+
+ def generateDocText(Documentation doc){'''
+ «IF doc!=null»
+ Documentation: «doc.text.join(" ///// ")»
+ «ENDIF»
+ '''
+ }
+
+ def irgendwas(Root root, ActorClass ac){
+ return ac.name + ".bla"
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.xtend b/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.xtend
index c0a803214..25b1a6727 100644
--- a/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.xtend
@@ -33,7 +33,7 @@ class InstanceDiagramGen implements IRoomGenerator {
override doGenerate(Root root) {
for (sc: root.subSystemInstances) {
- var path = sc.subSystemClass.generationTargetPath+sc.subSystemClass.getPath
+ var path = sc.subSystemClass.getDocGenerationTargetPath+sc.subSystemClass.getPath
var file = sc.subSystemClass.name+".dot"
logger.logInfo("generating instance diagram: '"+file+"' in '"+path+"'")
fileAccess.setOutputPath(path)
diff --git a/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/gen/MainGen.xtend b/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/gen/MainGen.xtend
index 2c0f23ad2..73174892b 100644
--- a/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/gen/MainGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/gen/MainGen.xtend
@@ -26,6 +26,7 @@ class MainGen implements IGenerator {
@Inject InstanceDiagramGen instanceDiagramGen
@Inject PrepareFileSystem prepFS
+ @Inject DocGen docGen
override void doGenerate(Resource resource, IFileSystemAccess fsa) {
prepFS.prepare(resource)
@@ -38,5 +39,6 @@ class MainGen implements IGenerator {
def void doGenerate(Root e) {
instanceDiagramGen.doGenerate(e);
+ docGen.doGenerate(e);
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/DocGen.java b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/DocGen.java
new file mode 100644
index 000000000..cdb1d08bb
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/DocGen.java
@@ -0,0 +1,120 @@
+package org.eclipse.etrice.generator.doc.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Documentation;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.generator.base.ILogger;
+import org.eclipse.etrice.generator.base.IRoomGenerator;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class DocGen implements IRoomGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<RoomModel> _models = root.getModels();
+ for (final RoomModel model : _models) {
+ {
+ String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
+ String path = _docGenerationTargetPath;
+ String _name = model.getName();
+ String _operator_plus = StringExtensions.operator_plus(_name, ".tex");
+ String file = _operator_plus;
+ String _operator_plus_1 = StringExtensions.operator_plus("generating LaTeX documentation: \'", file);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
+ this.logger.logInfo(_operator_plus_4);
+ this.fileAccess.setOutputPath(path);
+ StringConcatenation _generateModelDoc = this.generateModelDoc(root, model);
+ this.fileAccess.generateFile(file, _generateModelDoc);
+ }
+ }
+ }
+
+ public StringConcatenation generateModelDoc(final Root root, final RoomModel model) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("\\documentationclass[titlepage]{article}");
+ _builder.newLine();
+ String _name = model.getName();
+ _builder.append(_name, "");
+ _builder.newLineIfNotEmpty();
+ StringConcatenation _generateAllActorClassDocs = this.generateAllActorClassDocs(root, model);
+ _builder.append(_generateAllActorClassDocs, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\\end{document}");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public StringConcatenation generateAllActorClassDocs(final Root root, final RoomModel model) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ EList<ActorClass> _actorClasses = model.getActorClasses();
+ for(final ActorClass ac : _actorClasses) {
+ StringConcatenation _generateActorClassDoc = this.generateActorClassDoc(root, ac);
+ _builder.append(_generateActorClassDoc, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ public StringConcatenation generateActorClassDoc(final Root root, final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("\\subsection{");
+ String _name = ac.getName();
+ _builder.append(_name, "");
+ _builder.append("}");
+ _builder.newLineIfNotEmpty();
+ String _irgendwas = this.irgendwas(root, ac);
+ _builder.append(_irgendwas, "");
+ _builder.newLineIfNotEmpty();
+ Documentation _docu = ac.getDocu();
+ StringConcatenation _generateDocText = this.generateDocText(_docu);
+ _builder.append(_generateDocText, "");
+ _builder.newLineIfNotEmpty();
+ String _name_1 = ac.getName();
+ _builder.append(_name_1, "");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public StringConcatenation generateDocText(final Documentation doc) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(doc, null);
+ if (_operator_notEquals) {
+ _builder.append("Documentation: ");
+ EList<String> _text = doc.getText();
+ String _join = IterableExtensions.join(_text, " ///// ");
+ _builder.append(_join, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ public String irgendwas(final Root root, final ActorClass ac) {
+ String _name = ac.getName();
+ String _operator_plus = StringExtensions.operator_plus(_name, ".bla");
+ return _operator_plus;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java
index daa9a39f1..af69e658b 100644
--- a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java
+++ b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java
@@ -34,10 +34,10 @@ public class InstanceDiagramGen implements IRoomGenerator {
for (final SubSystemInstance sc : _subSystemInstances) {
{
SubSystemClass _subSystemClass = sc.getSubSystemClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
+ String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(_subSystemClass);
SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
String _path = this.roomExt.getPath(_subSystemClass_1);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ String _operator_plus = StringExtensions.operator_plus(_docGenerationTargetPath, _path);
String path = _operator_plus;
SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
String _name = _subSystemClass_2.getName();
diff --git a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/MainGen.java b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/MainGen.java
index 013714a80..c903e01ce 100644
--- a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/MainGen.java
+++ b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/MainGen.java
@@ -5,6 +5,7 @@ import com.google.inject.Singleton;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.etrice.generator.doc.gen.DocGen;
import org.eclipse.etrice.generator.doc.gen.InstanceDiagramGen;
import org.eclipse.etrice.generator.etricegen.Root;
import org.eclipse.etrice.generator.extensions.PrepareFileSystem;
@@ -20,6 +21,9 @@ public class MainGen implements IGenerator {
@Inject
private PrepareFileSystem prepFS;
+ @Inject
+ private DocGen docGen;
+
public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
this.prepFS.prepare(resource);
EList<EObject> _contents = resource.getContents();
@@ -31,6 +35,7 @@ public class MainGen implements IGenerator {
}
public void doGenerate(final Root e) {
- this.instanceDiagramGen.doGenerate(e);
+ this.instanceDiagramGen.doGenerate(e);
+ this.docGen.doGenerate(e);
}
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java
index d38665e07..a2262ca97 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java
@@ -51,7 +51,8 @@ public class Main extends AbstractGenerator {
private IGenerator mainGenerator;
@Inject
- protected InstanceDiagramGen instanceDiagramGenerator;
+ protected org.eclipse.etrice.generator.doc.gen.MainGen mainDocGenerator;
+
@Inject
private Validator validator;
@@ -110,7 +111,7 @@ public class Main extends AbstractGenerator {
mainGenerator.doGenerate(genModel.eResource(), fileAccess);
if (genInstDiag) {
- instanceDiagramGenerator.doGenerate(genModel);
+ mainDocGenerator.doGenerate(genModel);
}
logger.logInfo("-- finished code generation");
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/extensions/RoomExtensions.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/extensions/RoomExtensions.xtend
index 6d6e95213..b3627952f 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/extensions/RoomExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/extensions/RoomExtensions.xtend
@@ -78,6 +78,10 @@ class RoomExtensions {
return "/src-gen/"
}
+ def String getDocGenerationPathSegment() {
+ return "/doc-gen/"
+ }
+
def String getModelPath(EObject e) {
var res = e.eResource;
if (res==null) {
@@ -134,6 +138,10 @@ class RoomExtensions {
return getProjectPath(e)+getGenerationPathSegment();
}
+ def String getDocGenerationTargetPath(EObject e){
+ return getProjectPath(e)+getDocGenerationPathSegment();
+ }
+
def List<Port> getEndPorts(ActorClass ac) {
ac.intPorts.punion(ac.extPorts)
}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java
index d9fba0a08..06d196964 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java
@@ -76,6 +76,10 @@ public class RoomExtensions {
return "/src-gen/";
}
+ public String getDocGenerationPathSegment() {
+ return "/doc-gen/";
+ }
+
public String getModelPath(final EObject e) {
Resource _eResource = e.eResource();
Resource res = _eResource;
@@ -165,6 +169,13 @@ public class RoomExtensions {
return _operator_plus;
}
+ public String getDocGenerationTargetPath(final EObject e) {
+ String _projectPath = this.getProjectPath(e);
+ String _docGenerationPathSegment = this.getDocGenerationPathSegment();
+ String _operator_plus = StringExtensions.operator_plus(_projectPath, _docGenerationPathSegment);
+ return _operator_plus;
+ }
+
public List<Port> getEndPorts(final ActorClass ac) {
EList<Port> _intPorts = ac.getIntPorts();
EList<ExternalPort> _extPorts = ac.getExtPorts();
diff --git a/runtime/org.eclipse.etrice.modellib/doc-gen/room.basic.types.java.tex b/runtime/org.eclipse.etrice.modellib/doc-gen/room.basic.types.java.tex
new file mode 100644
index 000000000..e93ed60e6
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/doc-gen/room.basic.types.java.tex
@@ -0,0 +1,3 @@
+\documentationclass[titlepage]{article}
+room.basic.types.java
+\end{document}
diff --git a/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.SendingDataByValueTest.room b/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.SendingDataByValueTest.room
index ccd65d311..26eb9b68c 100644
--- a/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.SendingDataByValueTest.room
+++ b/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.SendingDataByValueTest.room
@@ -78,7 +78,7 @@ RoomModel org.eclipse.etrice.integration.SendingDataByValueTest {
"private CRC16Generator crcGen = new CRC16Generator();"
}
external Port PingPongPort
- Attribute i32Array [10]: int32
+ Attribute i32Array[ 10 ] : int32
Attribute data : PingPongData
}
Behavior {
@@ -291,7 +291,7 @@ RoomModel org.eclipse.etrice.integration.SendingDataByValueTest {
Attribute f32Val: float32 = "4711.0815f"
Attribute f64Val: float64 = "47114711.08150815"
Attribute stringVal: string = "\"Du alter Depp !\""
- Attribute arrayFromInt32 [5]: int32 = "{1,2,3,4,5}"
+ Attribute arrayFromInt32[ 5 ]: int32 = "{1,2,3,4,5}"
Attribute ownType: PingPongDataDeep
}
@@ -303,7 +303,7 @@ RoomModel org.eclipse.etrice.integration.SendingDataByValueTest {
Attribute f32Val: float32
Attribute f64Val: float64
Attribute stringVal: string
- Attribute arrayFromInt32 [10]: int32
+ Attribute arrayFromInt32[ 10 ]: int32
}
} \ No newline at end of file

Back to the top