diff --git a/language-server/src/Geowerkstatt.Interlis.LanguageServer.Test/Visitors/MarkdownDocumentationVisitorTest.cs b/language-server/src/Geowerkstatt.Interlis.LanguageServer.Test/Visitors/MarkdownDocumentationVisitorTest.cs
index 66deaeb..7415f9d 100644
--- a/language-server/src/Geowerkstatt.Interlis.LanguageServer.Test/Visitors/MarkdownDocumentationVisitorTest.cs
+++ b/language-server/src/Geowerkstatt.Interlis.LanguageServer.Test/Visitors/MarkdownDocumentationVisitorTest.cs
@@ -15,7 +15,7 @@ MODEL TestModel (de) AT "http://models.geow.cloud" VERSION "1" =
attr2: MANDATORY BOOLEAN;
END TestClass;
END TestTopic;
- END TestModel;
+ END TestModel.
""";
private const string TestModelAssociation = """
@@ -36,7 +36,7 @@ MODEL TestModel (de) AT "http://models.geow.cloud" VERSION "1" =
AssocB -<> {1} ClassB;
END Assoc1;
END TestTopic;
- END TestModel;
+ END TestModel.
""";
private const string TestModelEnumeration = """
@@ -52,7 +52,48 @@ MODEL TestModel (de) AT "http://models.geow.cloud" VERSION "1" =
);
END TestClass;
END TestTopic;
- END TestModel;
+ END TestModel.
+ """;
+
+ private const string TestModelNestedStruct = """
+ INTERLIS 2.4;
+
+ MODEL TestModel (de) AT "http://models.geow.cloud" VERSION "1" =
+ TOPIC TestTopic =
+ CLASS TestClass =
+ attr1: MANDATORY TestStruct;
+ attr2: 10..20;
+ END TestClass;
+
+ STRUCTURE TestStruct =
+ attr1: TEXT*10;
+ attr2: MANDATORY (value1, value2);
+ END TestStruct;
+ END TestTopic;
+ END TestModel.
+ """;
+
+ private const string TestModelDoubleNestedStruct = """
+ INTERLIS 2.4;
+
+ MODEL TestModel (de) AT "http://models.geow.cloud" VERSION "1" =
+ TOPIC TestTopic =
+ STRUCTURE TestStructLevel1 =
+ attr1: TestStructLevel2;
+ attr2: MANDATORY (value1, value2);
+ END TestStructLevel1;
+
+ STRUCTURE TestStructLevel2 =
+ attr1: MANDATORY TEXT*50;
+ attr2: 0..30;
+ END TestStructLevel2;
+
+ CLASS TestClass =
+ attr1: MANDATORY TestStructLevel1;
+ attr2: 10..20;
+ END TestClass;
+ END TestTopic;
+ END TestModel.
""";
[TestMethod]
@@ -127,7 +168,108 @@ public void TestInterlisFileEnumeration()
### TestClass
| Attributname | Kardinalität | Typ |
| --- | --- | --- |
- | attr1 | 0..1 | (**topValue1**, **topValue2** (subValue1, subValue2, subValue3 (*subSubValue1*, *subSubValue2*)), **topValue3**) |
+ | attr1 | 0..1 | (topValue1, topValue2 (subValue1, subValue2, subValue3 (subSubValue1, subSubValue2)), topValue3) |
+
+
+ """;
+
+ Assert.AreEqual(expected.ReplaceLineEndings(), documentation.ReplaceLineEndings());
+ }
+
+ [TestMethod]
+ public void TestInterlisFileNestedStruct()
+ {
+ var reader = new InterlisReader();
+ var interlisFile = reader.ReadFile(new StringReader(TestModelNestedStruct));
+
+ var visitor = new MarkdownDocumentationVisitor();
+ visitor.VisitInterlisFile(interlisFile);
+ var documentation = visitor.GetDocumentation();
+
+ const string structInlineTable =
+ "
" +
+ "" +
+ "Attributname | Kardinalität | Typ |
" +
+ "" +
+ "" +
+ "attr1 | 0..1 | Text [10] |
" +
+ "attr2 | 1 | (value1, value2) |
" +
+ "" +
+ "
";
+
+ var expected = $"""
+ # TestModel
+ ## TestTopic
+ ### TestClass
+ | Attributname | Kardinalität | Typ |
+ | --- | --- | --- |
+ | attr1 | 1 | TestStruct
{structInlineTable} |
+ | attr2 | 0..1 | 10..20 |
+
+ ### TestStruct
+ | Attributname | Kardinalität | Typ |
+ | --- | --- | --- |
+ | attr1 | 0..1 | Text [10] |
+ | attr2 | 1 | (value1, value2) |
+
+
+ """;
+
+ Assert.AreEqual(expected.ReplaceLineEndings(), documentation.ReplaceLineEndings());
+ }
+
+ [TestMethod]
+ public void TestInterlisFileDoubleNestedStruct()
+ {
+ var reader = new InterlisReader();
+ var interlisFile = reader.ReadFile(new StringReader(TestModelDoubleNestedStruct));
+
+ var visitor = new MarkdownDocumentationVisitor();
+ visitor.VisitInterlisFile(interlisFile);
+ var documentation = visitor.GetDocumentation();
+
+ const string structLevel2InlineTable =
+ "" +
+ "" +
+ "Attributname | Kardinalität | Typ |
" +
+ "" +
+ "" +
+ "attr1 | 1 | Text [50] |
" +
+ "attr2 | 0..1 | 0..30 |
" +
+ "" +
+ "
";
+
+ const string structLevel1InlineTable =
+ "" +
+ "" +
+ "Attributname | Kardinalität | Typ |
" +
+ "" +
+ "" +
+ "attr1 | 0..1 | TestStructLevel2 " + structLevel2InlineTable + " |
" +
+ "attr2 | 1 | (value1, value2) |
" +
+ "" +
+ "
";
+
+ var expected = $"""
+ # TestModel
+ ## TestTopic
+ ### TestStructLevel1
+ | Attributname | Kardinalität | Typ |
+ | --- | --- | --- |
+ | attr1 | 0..1 | TestStructLevel2
{structLevel2InlineTable} |
+ | attr2 | 1 | (value1, value2) |
+
+ ### TestStructLevel2
+ | Attributname | Kardinalität | Typ |
+ | --- | --- | --- |
+ | attr1 | 1 | Text [50] |
+ | attr2 | 0..1 | 0..30 |
+
+ ### TestClass
+ | Attributname | Kardinalität | Typ |
+ | --- | --- | --- |
+ | attr1 | 1 | TestStructLevel1
{structLevel1InlineTable} |
+ | attr2 | 0..1 | 10..20 |
""";
diff --git a/language-server/src/Geowerkstatt.Interlis.LanguageServer/Visitors/MarkdownDocumentationVisitor.cs b/language-server/src/Geowerkstatt.Interlis.LanguageServer/Visitors/MarkdownDocumentationVisitor.cs
index d9b4e0d..f786b88 100644
--- a/language-server/src/Geowerkstatt.Interlis.LanguageServer/Visitors/MarkdownDocumentationVisitor.cs
+++ b/language-server/src/Geowerkstatt.Interlis.LanguageServer/Visitors/MarkdownDocumentationVisitor.cs
@@ -11,6 +11,7 @@ namespace Geowerkstatt.Interlis.LanguageServer.Visitors;
public class MarkdownDocumentationVisitor : Interlis24AstBaseVisitor