diff --git a/.project b/.project
new file mode 100644
index 0000000..d41e75b
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+
+
+ xtext-docs-gen
+
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.m2e.core.maven2Nature
+
+
diff --git a/README.md b/README.md
index b86798f..16f5a5f 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ To get the gist of it, have a look at the example below, illustrating the docume
To check a more comprehensive example, see the [documentation](docs/ExampleDomainmodelDocs.md) generated for the [Domainmodel example grammar](examples/org.example.domainmodel/src/org/example/domainmodel/Domainmodel.xtext), using [this workflow file](examples/org.example.domainmodel/src/org/example/domainmodel/GenerateDomainmodel.mwe2).
### Usage
-1. Add `com.github.darvasd.xtextdocs.xtext` as depencency to the `MANIFEST.MF` of your plug-in project containing the Xtext grammar.
+1. Add `com.epistimis.xtextdocs.xtext` as depencency to the `MANIFEST.MF` of your plug-in project containing the Xtext grammar.
* You can use the http://darvasd.github.io/xtext-docs-gen/release/ update site to fetch it.
1. Add the documentation generation to your workflow description (`.mwe2` file next to your grammar), as a fragment for your language configuration (`XtextGeneratorLanguage` instance). For example:
```
@@ -30,8 +30,8 @@ To check a more comprehensive example, see the [documentation](docs/ExampleDomai
You will need some imports:
```
- import com.github.darvasd.xtextdocs.xtext.fragment.DocsGeneratorFragment
- import com.github.darvasd.xtextdocs.xtext.formatter.MarkdownDocsFormatter
+ import com.epistimis.xtextdocs.xtext.fragment.DocsGeneratorFragment
+ import com.epistimis.xtextdocs.xtext.formatter.MarkdownDocsFormatter
```
1. If you execute your workflow, the grammar documentation should be generated. You can see it in the log as well:
```
@@ -50,7 +50,7 @@ To get the gist of it, have a look at the example below, illustrating the docume
To check a more comprehensive example, see the [documentation](docs/ExampleXcoreDocs.md) generated for the [Library example metamodel](examples/org.example.xcore/model/Library.xcore), using [this workflow file](examples/org.example.xcore/src/org/example/xcore/library/GenerateXcoreDocs.mwe2).
### Usage
-1. Add `com.github.darvasd.xtextdocs.xcore` as depencency to the `MANIFEST.MF` of your plug-in project containing the Xcore metamodel(s).
+1. Add `com.epistimis.xtextdocs.xcore` as depencency to the `MANIFEST.MF` of your plug-in project containing the Xcore metamodel(s).
* You can use the http://darvasd.github.io/xtext-docs-gen/release/ update site to fetch it.
1. You may need in addition the following dependencies (you can make them optional if they are only required for the documentation generation): `org.eclipse.core.runtime`, `org.eclipse.emf.ecore`, `org.eclipse.emf.ecore.xcore.lib`, `org.eclipse.emf.mwe2.launch`, `org.eclipse.emf.mwe2.lib`, `org.eclipse.emf.ecore.xcore`, `org.eclipse.emf.codegen.ecore`, `org.apache.commons.logging`.
1. Create an MWE2 workflow description (`.mwe2` file) that will generate the Xcore documentation. Take [this](https://github.com/darvasd/xtext-docs-gen/tree/master/examples/org.example.xcore/src/org/example/xcore/library/GenerateXcoreDocs.mwe2) as an example for the Xcore metamodel loading. For the documentation generation configuration, here is an example:
@@ -74,8 +74,8 @@ To check a more comprehensive example, see the [documentation](docs/ExampleXcore
You will need some imports:
```
- import com.github.darvasd.xtextdocs.xcore.fragment.DocsGeneratorFragment
- import com.github.darvasd.xtextdocs.xcore.formatter.MarkdownXcoreDocsFormatter
+ import com.epistimis.xtextdocs.xcore.fragment.DocsGeneratorFragment
+ import com.epistimis.xtextdocs.xcore.formatter.MarkdownXcoreDocsFormatter
```
1. If you execute your workflow, the grammar documentation should be generated. You can see it in the log as well:
```
@@ -92,9 +92,10 @@ Use `https://darvasd.github.io/xtext-docs-gen/release/` as update site and insta
## License
Copyright (c) 2018, 2019 Daniel Darvas
+Copyright (c) 2024 Epistimis LLC
This program and the accompanying materials are made available under the terms of the **Eclipse Public License 2.0** which is available at https://www.eclipse.org/legal/epl-2.0/ .
The Domainmodel grammar is a commented version of the one available in the Xtext documentation, located at https://www.eclipse.org/Xtext/documentation/102_domainmodelwalkthrough.html. See its [GitHub page](https://github.com/eclipse/xtext/edit/website-published/xtext-website/documentation/102_domainmodelwalkthrough.md) for the list of contributors. Used for demonstration purposes only.
-The Library metamodel is an extended version of the one available in the Xcore documentation, located at https://wiki.eclipse.org/Xcore. See [this page](https://wiki.eclipse.org/index.php?title=Xcore&action=credits) for the list of contributors. Used for demonstration purposes only.
\ No newline at end of file
+The Library metamodel is an extended version of the one available in the Xcore documentation, located at https://wiki.eclipse.org/Xcore. See [this page](https://wiki.eclipse.org/index.php?title=Xcore&action=credits) for the list of contributors. Used for demonstration purposes only.
diff --git a/com.epistimis.xtextdocs.common.test/.classpath b/com.epistimis.xtextdocs.common.test/.classpath
new file mode 100644
index 0000000..ea0dca2
--- /dev/null
+++ b/com.epistimis.xtextdocs.common.test/.classpath
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.github.darvasd.xtextdocs.common/.project b/com.epistimis.xtextdocs.common.test/.project
similarity index 94%
rename from com.github.darvasd.xtextdocs.common/.project
rename to com.epistimis.xtextdocs.common.test/.project
index 4a2a42f..3c4c3a2 100644
--- a/com.github.darvasd.xtextdocs.common/.project
+++ b/com.epistimis.xtextdocs.common.test/.project
@@ -1,6 +1,6 @@
- com.github.darvasd.xtextdocs.common
+ com.epistimis.xtextdocs.common.test
diff --git a/com.epistimis.xtextdocs.common.test/META-INF/MANIFEST.MF b/com.epistimis.xtextdocs.common.test/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..22f800e
--- /dev/null
+++ b/com.epistimis.xtextdocs.common.test/META-INF/MANIFEST.MF
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Automatic-Module-Name: com.epistimis.xtextdocs.common.test
+Bundle-Name: Test
+Bundle-SymbolicName: com.epistimis.xtextdocs.common.test
+Bundle-Version: 1.1.0.qualifier
+Bundle-Vendor: Daniel Darvas
+Fragment-Host: com.epistimis.xtextdocs.common
+Bundle-RequiredExecutionEnvironment: JavaSE-17
+Import-Package: org.junit;version="4.12.0"
diff --git a/com.github.darvasd.xtextdocs.common.test/build.properties b/com.epistimis.xtextdocs.common.test/build.properties
similarity index 100%
rename from com.github.darvasd.xtextdocs.common.test/build.properties
rename to com.epistimis.xtextdocs.common.test/build.properties
diff --git a/com.github.darvasd.xtextdocs.xtext.test/pom.xml b/com.epistimis.xtextdocs.common.test/pom.xml
similarity index 80%
rename from com.github.darvasd.xtextdocs.xtext.test/pom.xml
rename to com.epistimis.xtextdocs.common.test/pom.xml
index 5231f3b..f5503d4 100644
--- a/com.github.darvasd.xtextdocs.xtext.test/pom.xml
+++ b/com.epistimis.xtextdocs.common.test/pom.xml
@@ -2,11 +2,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- com.github.darvasd.xtextdocs
- com.github.darvasd.xtextdocs.parent
+ com.epistimis.xtextdocs
+ com.epistimis.xtextdocs.parent1.1.0-SNAPSHOT
- com.github.darvasd.xtextdocs.xtext.test
+ com.epistimis.xtextdocs.common.testeclipse-test-plugin
diff --git a/com.github.darvasd.xtextdocs.common.test/src/com/github/darvasd/xtextdocs/common/formatter/DocCommentTextUtilTest.xtend b/com.epistimis.xtextdocs.common.test/src/com/epistimis/xtextdocs/common/formatter/DocCommentTextUtilTest.xtend
similarity index 92%
rename from com.github.darvasd.xtextdocs.common.test/src/com/github/darvasd/xtextdocs/common/formatter/DocCommentTextUtilTest.xtend
rename to com.epistimis.xtextdocs.common.test/src/com/epistimis/xtextdocs/common/formatter/DocCommentTextUtilTest.xtend
index 31d846a..811fdb9 100644
--- a/com.github.darvasd.xtextdocs.common.test/src/com/github/darvasd/xtextdocs/common/formatter/DocCommentTextUtilTest.xtend
+++ b/com.epistimis.xtextdocs.common.test/src/com/epistimis/xtextdocs/common/formatter/DocCommentTextUtilTest.xtend
@@ -1,5 +1,6 @@
/*********************************************************************
* Copyright (c) 2018 Daniel Darvas
+ * Copyright (c) 2024 Epistimis LLC
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
@@ -8,11 +9,11 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
-package com.github.darvasd.xtextdocs.common.formatter
+package com.epistimis.xtextdocs.common.formatter
import org.junit.Test
import org.junit.Assert
-import com.github.darvasd.xtextdocs.common.formatter.MarkdownTextFormatter
+import com.epistimis.xtextdocs.common.formatter.MarkdownTextFormatter
class DocCommentTextUtilTest {
@Test
diff --git a/com.github.darvasd.xtextdocs.common.test/src/com/github/darvasd/xtextdocs/common/formatter/MarkdownTextFormatterTest.xtend b/com.epistimis.xtextdocs.common.test/src/com/epistimis/xtextdocs/common/formatter/MarkdownTextFormatterTest.xtend
similarity index 91%
rename from com.github.darvasd.xtextdocs.common.test/src/com/github/darvasd/xtextdocs/common/formatter/MarkdownTextFormatterTest.xtend
rename to com.epistimis.xtextdocs.common.test/src/com/epistimis/xtextdocs/common/formatter/MarkdownTextFormatterTest.xtend
index c0cbc93..0a277d4 100644
--- a/com.github.darvasd.xtextdocs.common.test/src/com/github/darvasd/xtextdocs/common/formatter/MarkdownTextFormatterTest.xtend
+++ b/com.epistimis.xtextdocs.common.test/src/com/epistimis/xtextdocs/common/formatter/MarkdownTextFormatterTest.xtend
@@ -1,5 +1,6 @@
/*********************************************************************
* Copyright (c) 2018 Daniel Darvas
+ * Copyright (c) 2024 Epistimis LLC
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
@@ -8,11 +9,11 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
-package com.github.darvasd.xtextdocs.common.formatter
+package com.epistimis.xtextdocs.common.formatter
import org.junit.Assert
import org.junit.Test
-import com.github.darvasd.xtextdocs.common.formatter.MarkdownTextFormatter
+import com.epistimis.xtextdocs.common.formatter.MarkdownTextFormatter
class MarkdownTextFormatterTest {
@Test
diff --git a/com.github.darvasd.xtextdocs.common.test/.classpath b/com.epistimis.xtextdocs.common/.classpath
similarity index 95%
rename from com.github.darvasd.xtextdocs.common.test/.classpath
rename to com.epistimis.xtextdocs.common/.classpath
index 428337e..bde7c66 100644
--- a/com.github.darvasd.xtextdocs.common.test/.classpath
+++ b/com.epistimis.xtextdocs.common/.classpath
@@ -1,8 +1,8 @@
-
+
diff --git a/com.github.darvasd.xtextdocs.xtext/.project b/com.epistimis.xtextdocs.common/.project
similarity index 94%
rename from com.github.darvasd.xtextdocs.xtext/.project
rename to com.epistimis.xtextdocs.common/.project
index 95417f8..b165b42 100644
--- a/com.github.darvasd.xtextdocs.xtext/.project
+++ b/com.epistimis.xtextdocs.common/.project
@@ -1,6 +1,6 @@
- com.github.darvasd.xtextdocs.xtext
+ com.epistimis.xtextdocs.common
diff --git a/com.github.darvasd.xtextdocs.common/META-INF/MANIFEST.MF b/com.epistimis.xtextdocs.common/META-INF/MANIFEST.MF
similarity index 54%
rename from com.github.darvasd.xtextdocs.common/META-INF/MANIFEST.MF
rename to com.epistimis.xtextdocs.common/META-INF/MANIFEST.MF
index d1d733c..1a2ecc8 100644
--- a/com.github.darvasd.xtextdocs.common/META-INF/MANIFEST.MF
+++ b/com.epistimis.xtextdocs.common/META-INF/MANIFEST.MF
@@ -1,15 +1,16 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
+Automatic-Module-Name: com.epistimis.xtextdocs.common
Bundle-Name: Commons for documentation generation
-Bundle-SymbolicName: com.github.darvasd.xtextdocs.common
+Bundle-SymbolicName: com.epistimis.xtextdocs.common
Bundle-Version: 1.1.0.qualifier
Bundle-Vendor: Daniel Darvas
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: com.google.guava,
org.eclipse.xtext.xbase.lib,
org.eclipse.xtend.lib,
org.eclipse.xtend.lib.macro,
org.eclipse.xtext
-Export-Package: com.github.darvasd.xtextdocs.common.formatter,
- com.github.darvasd.xtextdocs.common.xtext
+Export-Package: com.epistimis.xtextdocs.common.formatter,
+ com.epistimis.xtextdocs.common.xtext
diff --git a/com.github.darvasd.xtextdocs.common/build.properties b/com.epistimis.xtextdocs.common/build.properties
similarity index 100%
rename from com.github.darvasd.xtextdocs.common/build.properties
rename to com.epistimis.xtextdocs.common/build.properties
diff --git a/com.github.darvasd.xtextdocs.xcore/pom.xml b/com.epistimis.xtextdocs.common/pom.xml
similarity index 74%
rename from com.github.darvasd.xtextdocs.xcore/pom.xml
rename to com.epistimis.xtextdocs.common/pom.xml
index 1bc4467..172b01e 100644
--- a/com.github.darvasd.xtextdocs.xcore/pom.xml
+++ b/com.epistimis.xtextdocs.common/pom.xml
@@ -2,11 +2,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- com.github.darvasd.xtextdocs
- com.github.darvasd.xtextdocs.parent
+ com.epistimis.xtextdocs
+ com.epistimis.xtextdocs.parent1.1.0-SNAPSHOT
- com.github.darvasd.xtextdocs.xcore
+ com.epistimis.xtextdocs.commoneclipse-plugin
diff --git a/com.github.darvasd.xtextdocs.common/src/com/github/darvasd/xtextdocs/common/formatter/DocCommentTextUtil.java b/com.epistimis.xtextdocs.common/src/com/epistimis/xtextdocs/common/formatter/DocCommentTextUtil.java
similarity index 95%
rename from com.github.darvasd.xtextdocs.common/src/com/github/darvasd/xtextdocs/common/formatter/DocCommentTextUtil.java
rename to com.epistimis.xtextdocs.common/src/com/epistimis/xtextdocs/common/formatter/DocCommentTextUtil.java
index 431d0e9..3e86bae 100644
--- a/com.github.darvasd.xtextdocs.common/src/com/github/darvasd/xtextdocs/common/formatter/DocCommentTextUtil.java
+++ b/com.epistimis.xtextdocs.common/src/com/epistimis/xtextdocs/common/formatter/DocCommentTextUtil.java
@@ -1,6 +1,7 @@
/*********************************************************************
* Copyright (c) 2018 Daniel Darvas
-*
+* Copyright (c) 2024 Epistimis LLC
+*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
@@ -8,7 +9,7 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
-package com.github.darvasd.xtextdocs.common.formatter;
+package com.epistimis.xtextdocs.common.formatter;
import java.util.List;
import java.util.function.Function;
diff --git a/com.epistimis.xtextdocs.common/src/com/epistimis/xtextdocs/common/formatter/HTMLTextFormatter.xtend b/com.epistimis.xtextdocs.common/src/com/epistimis/xtextdocs/common/formatter/HTMLTextFormatter.xtend
new file mode 100644
index 0000000..50e77b9
--- /dev/null
+++ b/com.epistimis.xtextdocs.common/src/com/epistimis/xtextdocs/common/formatter/HTMLTextFormatter.xtend
@@ -0,0 +1,72 @@
+package com.epistimis.xtextdocs.common.formatter
+
+import java.util.List
+
+class HTMLTextFormatter implements ITextFormatter {
+ public static final HTMLTextFormatter INSTANCE = new HTMLTextFormatter();
+
+ private new() {
+ }
+
+ override escape(String original) {
+ // FIXME do not escape inside "`"
+ var ret = original;
+ if (!original.contains("@code") && !original.contains("`")) { // quickfix
+ ret = "
"+ original + "
";
+ }
+ return ret;
+ }
+
+ override bold(String original) {
+ if (original.isNullOrEmpty) {
+ return "";
+ }
+
+ // The '**' does not support multiline!
+ return '''«original»''';
+ }
+
+ override codeBlock(String original) {
+ return '''
+
+ '''
+ }
+}
diff --git a/com.github.darvasd.xtextdocs.common/src/com/github/darvasd/xtextdocs/common/formatter/ITextFormatter.java b/com.epistimis.xtextdocs.common/src/com/epistimis/xtextdocs/common/formatter/ITextFormatter.java
similarity index 93%
rename from com.github.darvasd.xtextdocs.common/src/com/github/darvasd/xtextdocs/common/formatter/ITextFormatter.java
rename to com.epistimis.xtextdocs.common/src/com/epistimis/xtextdocs/common/formatter/ITextFormatter.java
index 1c59962..10cd931 100644
--- a/com.github.darvasd.xtextdocs.common/src/com/github/darvasd/xtextdocs/common/formatter/ITextFormatter.java
+++ b/com.epistimis.xtextdocs.common/src/com/epistimis/xtextdocs/common/formatter/ITextFormatter.java
@@ -1,6 +1,7 @@
/*********************************************************************
* Copyright (c) 2018 Daniel Darvas
-*
+* Copyright (c) 2024 Epistimis LLC
+*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
@@ -8,7 +9,7 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
-package com.github.darvasd.xtextdocs.common.formatter;
+package com.epistimis.xtextdocs.common.formatter;
import java.util.List;
diff --git a/com.github.darvasd.xtextdocs.common/src/com/github/darvasd/xtextdocs/common/formatter/MarkdownTextFormatter.xtend b/com.epistimis.xtextdocs.common/src/com/epistimis/xtextdocs/common/formatter/MarkdownTextFormatter.xtend
similarity index 91%
rename from com.github.darvasd.xtextdocs.common/src/com/github/darvasd/xtextdocs/common/formatter/MarkdownTextFormatter.xtend
rename to com.epistimis.xtextdocs.common/src/com/epistimis/xtextdocs/common/formatter/MarkdownTextFormatter.xtend
index fe1d75a..3179f91 100644
--- a/com.github.darvasd.xtextdocs.common/src/com/github/darvasd/xtextdocs/common/formatter/MarkdownTextFormatter.xtend
+++ b/com.epistimis.xtextdocs.common/src/com/epistimis/xtextdocs/common/formatter/MarkdownTextFormatter.xtend
@@ -1,4 +1,4 @@
-package com.github.darvasd.xtextdocs.common.formatter
+package com.epistimis.xtextdocs.common.formatter
import java.util.List
diff --git a/com.github.darvasd.xtextdocs.common/src/com/github/darvasd/xtextdocs/common/xtext/XtextTokenUtil.xtend b/com.epistimis.xtextdocs.common/src/com/epistimis/xtextdocs/common/xtext/XtextTokenUtil.xtend
similarity index 96%
rename from com.github.darvasd.xtextdocs.common/src/com/github/darvasd/xtextdocs/common/xtext/XtextTokenUtil.xtend
rename to com.epistimis.xtextdocs.common/src/com/epistimis/xtextdocs/common/xtext/XtextTokenUtil.xtend
index 0e0e820..ec1c14c 100644
--- a/com.github.darvasd.xtextdocs.common/src/com/github/darvasd/xtextdocs/common/xtext/XtextTokenUtil.xtend
+++ b/com.epistimis.xtextdocs.common/src/com/epistimis/xtextdocs/common/xtext/XtextTokenUtil.xtend
@@ -1,4 +1,4 @@
-package com.github.darvasd.xtextdocs.common.xtext
+package com.epistimis.xtextdocs.common.xtext
import org.eclipse.emf.ecore.EObject
import org.eclipse.xtext.TerminalRule
diff --git a/com.github.darvasd.xtextdocs.p2/.project b/com.epistimis.xtextdocs.p2/.project
similarity index 79%
rename from com.github.darvasd.xtextdocs.p2/.project
rename to com.epistimis.xtextdocs.p2/.project
index 40ad38a..461c206 100644
--- a/com.github.darvasd.xtextdocs.p2/.project
+++ b/com.epistimis.xtextdocs.p2/.project
@@ -1,6 +1,6 @@
- com.github.darvasd.xtextdocs.p2
+ com.epistimis.xtextdocs.p2
diff --git a/com.epistimis.xtextdocs.p2/category.xml b/com.epistimis.xtextdocs.p2/category.xml
new file mode 100644
index 0000000..39f1ae5
--- /dev/null
+++ b/com.epistimis.xtextdocs.p2/category.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+ Visit http://github.com/darvasd/xtext-docs-gen for more details.
+
+
+
+
+ Visit http://github.com/darvasd/xtext-docs-gen for more details.
+
+
+
+
diff --git a/com.github.darvasd.xtextdocs.p2/pom.xml b/com.epistimis.xtextdocs.p2/pom.xml
similarity index 52%
rename from com.github.darvasd.xtextdocs.p2/pom.xml
rename to com.epistimis.xtextdocs.p2/pom.xml
index 9bc2116..11a83f8 100644
--- a/com.github.darvasd.xtextdocs.p2/pom.xml
+++ b/com.epistimis.xtextdocs.p2/pom.xml
@@ -1,11 +1,11 @@
4.0.0
- com.github.darvasd.xtextdocs
- com.github.darvasd.xtextdocs.parent
+ com.epistimis.xtextdocs
+ com.epistimis.xtextdocs.parent1.1.0-SNAPSHOT
- com.github.darvasd.xtextdocs.p2
+ com.epistimis.xtextdocs.p21.1.0-SNAPSHOTeclipse-repository
\ No newline at end of file
diff --git a/com.github.darvasd.xtextdocs.target/.project b/com.epistimis.xtextdocs.target/.project
similarity index 100%
rename from com.github.darvasd.xtextdocs.target/.project
rename to com.epistimis.xtextdocs.target/.project
diff --git a/com.github.darvasd.xtextdocs.target/com.github.darvasd.xtextdocs.target.target b/com.epistimis.xtextdocs.target/com.github.darvasd.xtextdocs.target.target
similarity index 100%
rename from com.github.darvasd.xtextdocs.target/com.github.darvasd.xtextdocs.target.target
rename to com.epistimis.xtextdocs.target/com.github.darvasd.xtextdocs.target.target
diff --git a/com.github.darvasd.xtextdocs.target/pom.xml b/com.epistimis.xtextdocs.target/pom.xml
similarity index 69%
rename from com.github.darvasd.xtextdocs.target/pom.xml
rename to com.epistimis.xtextdocs.target/pom.xml
index 2d8d7bf..d7689f8 100644
--- a/com.github.darvasd.xtextdocs.target/pom.xml
+++ b/com.epistimis.xtextdocs.target/pom.xml
@@ -2,11 +2,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- com.github.darvasd.xtextdocs
- com.github.darvasd.xtextdocs.parent
+ com.epistimis.xtextdocs
+ com.epistimis.xtextdocs.parent1.1.0-SNAPSHOT
- com.github.darvasd.xtextdocs.target
+ com.epistimis.xtextdocs.targeteclipse-target-definition
diff --git a/com.github.darvasd.xtextdocs.common/.classpath b/com.epistimis.xtextdocs.xcore/.classpath
similarity index 95%
rename from com.github.darvasd.xtextdocs.common/.classpath
rename to com.epistimis.xtextdocs.xcore/.classpath
index 428337e..4301eb3 100644
--- a/com.github.darvasd.xtextdocs.common/.classpath
+++ b/com.epistimis.xtextdocs.xcore/.classpath
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/com.epistimis.xtextdocs.xcore/.project b/com.epistimis.xtextdocs.xcore/.project
new file mode 100644
index 0000000..f1d624e
--- /dev/null
+++ b/com.epistimis.xtextdocs.xcore/.project
@@ -0,0 +1,34 @@
+
+
+ com.epistimis.xtextdocs.xcore
+
+
+
+
+
+ org.eclipse.xtext.ui.shared.xtextBuilder
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+ org.eclipse.xtext.ui.shared.xtextNature
+
+
diff --git a/com.github.darvasd.xtextdocs.xcore/META-INF/MANIFEST.MF b/com.epistimis.xtextdocs.xcore/META-INF/MANIFEST.MF
similarity index 62%
rename from com.github.darvasd.xtextdocs.xcore/META-INF/MANIFEST.MF
rename to com.epistimis.xtextdocs.xcore/META-INF/MANIFEST.MF
index c126aa3..ffc054e 100644
--- a/com.github.darvasd.xtextdocs.xcore/META-INF/MANIFEST.MF
+++ b/com.epistimis.xtextdocs.xcore/META-INF/MANIFEST.MF
@@ -1,10 +1,12 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
+Automatic-Module-Name: com.epistimis.xtextdocs.xcore
Bundle-Name: Xcore metamodel documentation generator
-Bundle-SymbolicName: com.github.darvasd.xtextdocs.xcore
+Bundle-SymbolicName: com.epistimis.xtextdocs.xcore
Bundle-Version: 1.1.0.qualifier
+Import-Package: org.apache.log4j;version="1.2.24"
Bundle-Vendor: Daniel Darvas
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: com.google.guava,
org.eclipse.xtext.xbase.lib,
org.eclipse.xtend.lib,
@@ -15,5 +17,5 @@ Require-Bundle: com.google.guava,
org.eclipse.emf.ecore.xcore.lib,
org.eclipse.emf.ecore.xcore,
org.eclipse.emf.codegen.ecore,
- com.github.darvasd.xtextdocs.common;bundle-version="1.1.0";visibility:=reexport
+ com.epistimis.xtextdocs.common;bundle-version="1.1.0";visibility:=reexport
diff --git a/com.github.darvasd.xtextdocs.xcore/build.properties b/com.epistimis.xtextdocs.xcore/build.properties
similarity index 100%
rename from com.github.darvasd.xtextdocs.xcore/build.properties
rename to com.epistimis.xtextdocs.xcore/build.properties
diff --git a/com.github.darvasd.xtextdocs.xtext/pom.xml b/com.epistimis.xtextdocs.xcore/pom.xml
similarity index 74%
rename from com.github.darvasd.xtextdocs.xtext/pom.xml
rename to com.epistimis.xtextdocs.xcore/pom.xml
index 98f37f1..bb7996f 100644
--- a/com.github.darvasd.xtextdocs.xtext/pom.xml
+++ b/com.epistimis.xtextdocs.xcore/pom.xml
@@ -2,11 +2,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- com.github.darvasd.xtextdocs
- com.github.darvasd.xtextdocs.parent
+ com.epistimis.xtextdocs
+ com.epistimis.xtextdocs.parent1.1.0-SNAPSHOT
- com.github.darvasd.xtextdocs.xtext
+ com.epistimis.xtextdocs.xcoreeclipse-plugin
diff --git a/com.github.darvasd.xtextdocs.xcore/src/com/github/darvasd/xtextdocs/xcore/formatter/IXcoreDocsFormatter.java b/com.epistimis.xtextdocs.xcore/src/com/epistimis/xtextdocs/xcore/formatter/IXcoreDocsFormatter.java
similarity index 86%
rename from com.github.darvasd.xtextdocs.xcore/src/com/github/darvasd/xtextdocs/xcore/formatter/IXcoreDocsFormatter.java
rename to com.epistimis.xtextdocs.xcore/src/com/epistimis/xtextdocs/xcore/formatter/IXcoreDocsFormatter.java
index 14f5995..c178f7f 100644
--- a/com.github.darvasd.xtextdocs.xcore/src/com/github/darvasd/xtextdocs/xcore/formatter/IXcoreDocsFormatter.java
+++ b/com.epistimis.xtextdocs.xcore/src/com/epistimis/xtextdocs/xcore/formatter/IXcoreDocsFormatter.java
@@ -1,4 +1,4 @@
-package com.github.darvasd.xtextdocs.xcore.formatter;
+package com.epistimis.xtextdocs.xcore.formatter;
import org.eclipse.emf.ecore.xcore.resource.XcoreResource;
diff --git a/com.github.darvasd.xtextdocs.xcore/src/com/github/darvasd/xtextdocs/xcore/formatter/MarkdownXcoreDocsFormatter.xtend b/com.epistimis.xtextdocs.xcore/src/com/epistimis/xtextdocs/xcore/formatter/MarkdownXcoreDocsFormatter.xtend
similarity index 92%
rename from com.github.darvasd.xtextdocs.xcore/src/com/github/darvasd/xtextdocs/xcore/formatter/MarkdownXcoreDocsFormatter.xtend
rename to com.epistimis.xtextdocs.xcore/src/com/epistimis/xtextdocs/xcore/formatter/MarkdownXcoreDocsFormatter.xtend
index cce1033..9198a62 100644
--- a/com.github.darvasd.xtextdocs.xcore/src/com/github/darvasd/xtextdocs/xcore/formatter/MarkdownXcoreDocsFormatter.xtend
+++ b/com.epistimis.xtextdocs.xcore/src/com/epistimis/xtextdocs/xcore/formatter/MarkdownXcoreDocsFormatter.xtend
@@ -1,4 +1,4 @@
-package com.github.darvasd.xtextdocs.xcore.formatter
+package com.epistimis.xtextdocs.xcore.formatter
import org.eclipse.emf.codegen.ecore.genmodel.GenBase
import org.eclipse.emf.codegen.ecore.genmodel.GenClass
@@ -25,24 +25,24 @@ import org.eclipse.xtext.nodemodel.util.NodeModelUtils
import com.google.common.base.Strings
import java.util.TreeMap
import java.util.SortedMap
-import com.github.darvasd.xtextdocs.common.xtext.XtextTokenUtil
-import com.github.darvasd.xtextdocs.common.formatter.MarkdownTextFormatter
-import com.github.darvasd.xtextdocs.common.formatter.DocCommentTextUtil
+import com.epistimis.xtextdocs.common.xtext.XtextTokenUtil
+import com.epistimis.xtextdocs.common.formatter.MarkdownTextFormatter
+import com.epistimis.xtextdocs.common.formatter.DocCommentTextUtil
/**
* Class to be used for generating a Markdown documentation for an Xcore metamodel description.
*/
class MarkdownXcoreDocsFormatter implements IXcoreDocsFormatter {
- private static val DOCUMENTATION_ANNOTATION_KEY = "documentation";
+ static val DOCUMENTATION_ANNOTATION_KEY = "documentation";
- private static val extension MarkdownTextFormatter mdFormatter = MarkdownTextFormatter.INSTANCE;
+ static val extension MarkdownTextFormatter mdFormatter = MarkdownTextFormatter.INSTANCE;
/**
* The main title text of the documentation to be generated.
* If not set ({@code null}), the title will be the URI of the metamodel.
*/
- @Accessors private String mainTitle = null;
+ @Accessors String mainTitle = null;
@Accessors boolean gitbookLinkStyle = true;
@@ -56,7 +56,7 @@ class MarkdownXcoreDocsFormatter implements IXcoreDocsFormatter {
* If it is greater than zero, the number of {@code #} characters will be increased
* with this number at each title.
*/
- private int titleLevelOffset = 0;
+ int titleLevelOffset = 0;
/**
* Sets the title depth offset. If set to 0, the main title will be prefixed with {@code #},
@@ -68,15 +68,15 @@ class MarkdownXcoreDocsFormatter implements IXcoreDocsFormatter {
* as MWE2 does not support integer properties.
* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=377068 .
*/
- public def void setTitleLevelOffset(String value) {
+ def void setTitleLevelOffset(String value) {
this.titleLevelOffset = Integer.parseInt(value);
}
/**
* Map that stores (name, id) pairs. The stored 'id' is the anchor that is used for the definition of the class 'name'.
*/
- private SortedMap anchors = new TreeMap();
- private int anchorCounter = 1;
+ SortedMap anchors = new TreeMap();
+ int anchorCounter = 1;
override generateDocs(XcoreResource resource) {
fillAnchors(resource);
diff --git a/com.github.darvasd.xtextdocs.xcore/src/com/github/darvasd/xtextdocs/xcore/fragment/DocsGeneratorFragment.xtend b/com.epistimis.xtextdocs.xcore/src/com/epistimis/xtextdocs/xcore/fragment/DocsGeneratorFragment.xtend
similarity index 87%
rename from com.github.darvasd.xtextdocs.xcore/src/com/github/darvasd/xtextdocs/xcore/fragment/DocsGeneratorFragment.xtend
rename to com.epistimis.xtextdocs.xcore/src/com/epistimis/xtextdocs/xcore/fragment/DocsGeneratorFragment.xtend
index 0fa9adb..30d069e 100644
--- a/com.github.darvasd.xtextdocs.xcore/src/com/github/darvasd/xtextdocs/xcore/fragment/DocsGeneratorFragment.xtend
+++ b/com.epistimis.xtextdocs.xcore/src/com/epistimis/xtextdocs/xcore/fragment/DocsGeneratorFragment.xtend
@@ -1,4 +1,4 @@
-package com.github.darvasd.xtextdocs.xcore.fragment
+package com.epistimis.xtextdocs.xcore.fragment
import org.eclipse.emf.common.util.URI
import org.eclipse.emf.ecore.resource.ResourceSet
@@ -9,14 +9,14 @@ import org.eclipse.emf.mwe2.runtime.workflow.IWorkflowContext
import org.eclipse.xtend.lib.annotations.Accessors
import java.nio.file.Paths
import java.io.FileWriter
-import com.github.darvasd.xtextdocs.xcore.formatter.IXcoreDocsFormatter
+import com.epistimis.xtextdocs.xcore.formatter.IXcoreDocsFormatter
import org.apache.log4j.Logger
/**
* Xcore documentation generation fragment to be used in MWE2 workflows.
*/
class DocsGeneratorFragment implements IWorkflowComponent {
- private final static Logger LOG = Logger.getLogger(DocsGeneratorFragment);
+ final static Logger LOG = Logger.getLogger(DocsGeneratorFragment);
/**
* The URI of the Xcore metamodel to be documented.
diff --git a/com.github.darvasd.xtextdocs.xtext.test/.classpath b/com.epistimis.xtextdocs.xtext.test/.classpath
similarity index 96%
rename from com.github.darvasd.xtextdocs.xtext.test/.classpath
rename to com.epistimis.xtextdocs.xtext.test/.classpath
index 3fe0962..51bc151 100644
--- a/com.github.darvasd.xtextdocs.xtext.test/.classpath
+++ b/com.epistimis.xtextdocs.xtext.test/.classpath
@@ -1,9 +1,9 @@
-
-
+
+
diff --git a/com.github.darvasd.xtextdocs.xtext.test/.project b/com.epistimis.xtextdocs.xtext.test/.project
similarity index 93%
rename from com.github.darvasd.xtextdocs.xtext.test/.project
rename to com.epistimis.xtextdocs.xtext.test/.project
index 332f1d4..a81a8a4 100644
--- a/com.github.darvasd.xtextdocs.xtext.test/.project
+++ b/com.epistimis.xtextdocs.xtext.test/.project
@@ -1,6 +1,6 @@
- com.github.darvasd.xtextdocs.xtext.test
+ com.epistimis.xtextdocs.xtext.test
diff --git a/com.epistimis.xtextdocs.xtext.test/META-INF/MANIFEST.MF b/com.epistimis.xtextdocs.xtext.test/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..011307d
--- /dev/null
+++ b/com.epistimis.xtextdocs.xtext.test/META-INF/MANIFEST.MF
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Automatic-Module-Name: com.epistimis.xtextdocs.xtext.test
+Bundle-Name: com.epistimis.xtextdocs.xtext.test
+Bundle-SymbolicName: com.epistimis.xtextdocs.xtext.test
+Bundle-Version: 1.1.0.qualifier
+Fragment-Host: com.epistimis.xtextdocs.xtext;bundle-version="1.1.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-17
diff --git a/com.github.darvasd.xtextdocs.xtext.test/build.properties b/com.epistimis.xtextdocs.xtext.test/build.properties
similarity index 100%
rename from com.github.darvasd.xtextdocs.xtext.test/build.properties
rename to com.epistimis.xtextdocs.xtext.test/build.properties
diff --git a/com.github.darvasd.xtextdocs.common.test/pom.xml b/com.epistimis.xtextdocs.xtext.test/pom.xml
similarity index 80%
rename from com.github.darvasd.xtextdocs.common.test/pom.xml
rename to com.epistimis.xtextdocs.xtext.test/pom.xml
index 63a0646..6b3bd61 100644
--- a/com.github.darvasd.xtextdocs.common.test/pom.xml
+++ b/com.epistimis.xtextdocs.xtext.test/pom.xml
@@ -2,11 +2,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- com.github.darvasd.xtextdocs
- com.github.darvasd.xtextdocs.parent
+ com.epistimis.xtextdocs
+ com.epistimis.xtextdocs.parent1.1.0-SNAPSHOT
- com.github.darvasd.xtextdocs.common.test
+ com.epistimis.xtextdocs.xtext.testeclipse-test-plugin
diff --git a/com.github.darvasd.xtextdocs.xtext.test/resources/DomainmodelGrammar.xmi b/com.epistimis.xtextdocs.xtext.test/resources/DomainmodelGrammar.xmi
similarity index 100%
rename from com.github.darvasd.xtextdocs.xtext.test/resources/DomainmodelGrammar.xmi
rename to com.epistimis.xtextdocs.xtext.test/resources/DomainmodelGrammar.xmi
diff --git a/com.github.darvasd.xtextdocs.xtext.test/src/com/github/darvasd/xtextdocs/xtext/doccomment/DocCommentTest.xtend b/com.epistimis.xtextdocs.xtext.test/src/com/epistimis/xtextdocs/xtext/doccomment/DocCommentTest.xtend
similarity index 95%
rename from com.github.darvasd.xtextdocs.xtext.test/src/com/github/darvasd/xtextdocs/xtext/doccomment/DocCommentTest.xtend
rename to com.epistimis.xtextdocs.xtext.test/src/com/epistimis/xtextdocs/xtext/doccomment/DocCommentTest.xtend
index 1a50960..3a607cc 100644
--- a/com.github.darvasd.xtextdocs.xtext.test/src/com/github/darvasd/xtextdocs/xtext/doccomment/DocCommentTest.xtend
+++ b/com.epistimis.xtextdocs.xtext.test/src/com/epistimis/xtextdocs/xtext/doccomment/DocCommentTest.xtend
@@ -1,5 +1,6 @@
/*********************************************************************
* Copyright (c) 2018 Daniel Darvas
+ * Copyright (c) 2024 Epistimis LLC
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
@@ -8,7 +9,7 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
-package com.github.darvasd.xtextdocs.xtext.doccomment
+package com.epistimis.xtextdocs.xtext.doccomment
import org.junit.Test
import org.junit.Assert
diff --git a/com.github.darvasd.xtextdocs.xtext.test/src/com/github/darvasd/xtextdocs/xtext/integrationtest/IntegrationTest.xtend b/com.epistimis.xtextdocs.xtext.test/src/com/epistimis/xtextdocs/xtext/integrationtest/IntegrationTest.xtend
similarity index 90%
rename from com.github.darvasd.xtextdocs.xtext.test/src/com/github/darvasd/xtextdocs/xtext/integrationtest/IntegrationTest.xtend
rename to com.epistimis.xtextdocs.xtext.test/src/com/epistimis/xtextdocs/xtext/integrationtest/IntegrationTest.xtend
index 7e4a89c..6d02bc3 100644
--- a/com.github.darvasd.xtextdocs.xtext.test/src/com/github/darvasd/xtextdocs/xtext/integrationtest/IntegrationTest.xtend
+++ b/com.epistimis.xtextdocs.xtext.test/src/com/epistimis/xtextdocs/xtext/integrationtest/IntegrationTest.xtend
@@ -1,5 +1,6 @@
/*********************************************************************
* Copyright (c) 2018 Daniel Darvas
+ * Copyright (c) 2024 Epistimis LLC
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
@@ -8,9 +9,9 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
-package com.github.darvasd.xtextdocs.xtext.integrationtest
+package com.epistimis.xtextdocs.xtext.integrationtest
-import com.github.darvasd.xtextdocs.xtext.DocsGenerator
+import com.epistimis.xtextdocs.xtext.DocsGenerator
import com.google.common.base.Preconditions
import org.eclipse.emf.common.util.URI
import org.eclipse.emf.ecore.util.EcoreUtil
@@ -20,10 +21,10 @@ import org.eclipse.xtext.Grammar
import org.junit.Assert
import org.junit.Before
import org.junit.Test
-import com.github.darvasd.xtextdocs.xtext.formatter.MarkdownDocsFormatter
+import com.epistimis.xtextdocs.xtext.formatter.MarkdownDocsFormatter
class IntegrationTest {
- private Grammar grammar;
+ Grammar grammar;
/**
* Loads the grammar metamodel for the integration tests.
diff --git a/com.github.darvasd.xtextdocs.xcore/.classpath b/com.epistimis.xtextdocs.xtext/.classpath
similarity index 78%
rename from com.github.darvasd.xtextdocs.xcore/.classpath
rename to com.epistimis.xtextdocs.xtext/.classpath
index 1c96fe2..28adbe3 100644
--- a/com.github.darvasd.xtextdocs.xcore/.classpath
+++ b/com.epistimis.xtextdocs.xtext/.classpath
@@ -1,8 +1,12 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.github.darvasd.xtextdocs.common.test/.project b/com.epistimis.xtextdocs.xtext/.project
similarity index 93%
rename from com.github.darvasd.xtextdocs.common.test/.project
rename to com.epistimis.xtextdocs.xtext/.project
index 6be8eaa..1a6b0ac 100644
--- a/com.github.darvasd.xtextdocs.common.test/.project
+++ b/com.epistimis.xtextdocs.xtext/.project
@@ -1,6 +1,6 @@
- com.github.darvasd.xtextdocs.common.test
+ com.epistimis.xtextdocs.xtext
diff --git a/com.github.darvasd.xtextdocs.xtext/META-INF/MANIFEST.MF b/com.epistimis.xtextdocs.xtext/META-INF/MANIFEST.MF
similarity index 54%
rename from com.github.darvasd.xtextdocs.xtext/META-INF/MANIFEST.MF
rename to com.epistimis.xtextdocs.xtext/META-INF/MANIFEST.MF
index 44b9359..547915e 100644
--- a/com.github.darvasd.xtextdocs.xtext/META-INF/MANIFEST.MF
+++ b/com.epistimis.xtextdocs.xtext/META-INF/MANIFEST.MF
@@ -1,19 +1,20 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
+Automatic-Module-Name: com.epistimis.xtextdocs.xtext
Bundle-Name: Xtext grammar documentation generator
-Bundle-SymbolicName: com.github.darvasd.xtextdocs.xtext
+Bundle-SymbolicName: com.epistimis.xtextdocs.xtext
Bundle-Version: 1.1.0.qualifier
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: org.eclipse.xtext;bundle-version="2.10.0",
com.google.guava;bundle-version="15.0.0",
org.junit;bundle-version="4.12.0",
org.eclipse.xtext.xbase.lib,
org.eclipse.xtend.lib,
org.eclipse.xtend.lib.macro,
- org.eclipse.xtext.generator;bundle-version="2.12.0",
- com.github.darvasd.xtextdocs.common;visibility:=reexport
-Export-Package: com.github.darvasd.xtextdocs.xtext.fragment,
- com.github.darvasd.xtextdocs.xtext
+ com.epistimis.xtextdocs.common;visibility:=reexport,
+ org.eclipse.xtext.xtext.generator;bundle-version="2.33.0"
+Export-Package: com.epistimis.xtextdocs.xtext.fragment,
+ com.epistimis.xtextdocs.xtext
Import-Package: org.apache.log4j
Bundle-Vendor: Daniel Darvas
diff --git a/com.github.darvasd.xtextdocs.xtext/build.properties b/com.epistimis.xtextdocs.xtext/build.properties
similarity index 100%
rename from com.github.darvasd.xtextdocs.xtext/build.properties
rename to com.epistimis.xtextdocs.xtext/build.properties
diff --git a/com.github.darvasd.xtextdocs.common/pom.xml b/com.epistimis.xtextdocs.xtext/pom.xml
similarity index 74%
rename from com.github.darvasd.xtextdocs.common/pom.xml
rename to com.epistimis.xtextdocs.xtext/pom.xml
index d2c2534..6452c2e 100644
--- a/com.github.darvasd.xtextdocs.common/pom.xml
+++ b/com.epistimis.xtextdocs.xtext/pom.xml
@@ -2,11 +2,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- com.github.darvasd.xtextdocs
- com.github.darvasd.xtextdocs.parent
+ com.epistimis.xtextdocs
+ com.epistimis.xtextdocs.parent1.1.0-SNAPSHOT
- com.github.darvasd.xtextdocs.common
+ com.epistimis.xtextdocs.xtexteclipse-plugin
diff --git a/com.github.darvasd.xtextdocs.xtext/src/com/github/darvasd/xtextdocs/xtext/DocsGenerator.java b/com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/DocsGenerator.java
similarity index 85%
rename from com.github.darvasd.xtextdocs.xtext/src/com/github/darvasd/xtextdocs/xtext/DocsGenerator.java
rename to com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/DocsGenerator.java
index 5e9999b..b59f145 100644
--- a/com.github.darvasd.xtextdocs.xtext/src/com/github/darvasd/xtextdocs/xtext/DocsGenerator.java
+++ b/com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/DocsGenerator.java
@@ -1,6 +1,7 @@
/*********************************************************************
* Copyright (c) 2018 Daniel Darvas
-*
+* Copyright (c) 2024 Epistimis LLC
+*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
@@ -8,7 +9,7 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
-package com.github.darvasd.xtextdocs.xtext;
+package com.epistimis.xtextdocs.xtext;
import java.util.ArrayList;
import java.util.List;
@@ -21,10 +22,10 @@
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
-import com.github.darvasd.xtextdocs.xtext.ruledoc.RuleDoc;
-import com.github.darvasd.xtextdocs.xtext.doccomment.DocComment;
-import com.github.darvasd.xtextdocs.xtext.formatter.IGrammarDocsFormatter;
-import com.github.darvasd.xtextdocs.xtext.ruledoc.GrammarDoc;
+import com.epistimis.xtextdocs.xtext.ruledoc.RuleDoc;
+import com.epistimis.xtextdocs.xtext.doccomment.DocComment;
+import com.epistimis.xtextdocs.xtext.formatter.IGrammarDocsFormatter;
+import com.epistimis.xtextdocs.xtext.ruledoc.GrammarDoc;
/**
* Utility class containing the entry points for the documentation generation
@@ -50,6 +51,20 @@ public static CharSequence generateFormattedDoc(Grammar grammar, IGrammarDocsFor
return formatter.formatGrammar(grammarDoc);
}
+ /**
+ * Generates a DOT graph textual documentation for the given grammar, using the
+ * given formatter.
+ *
+ * @param grammar
+ * The grammar to be represented.
+ * @param formatter
+ * The formatter to be used.
+ * @return DOT graph textual documentation.
+ */
+ public static CharSequence generateDOTGraph(Grammar grammar, IGrammarDocsFormatter formatter) {
+ GrammarDoc grammarDoc = createGrammarDocumentation(grammar);
+ return formatter.formatGraph(grammarDoc);
+ }
/**
* Creates and returns a documentation object for the grammar, including its
* rules.
diff --git a/com.github.darvasd.xtextdocs.xtext/src/com/github/darvasd/xtextdocs/xtext/doccomment/DocComment.java b/com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/doccomment/DocComment.java
similarity index 98%
rename from com.github.darvasd.xtextdocs.xtext/src/com/github/darvasd/xtextdocs/xtext/doccomment/DocComment.java
rename to com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/doccomment/DocComment.java
index ab9af4e..f134651 100644
--- a/com.github.darvasd.xtextdocs.xtext/src/com/github/darvasd/xtextdocs/xtext/doccomment/DocComment.java
+++ b/com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/doccomment/DocComment.java
@@ -1,6 +1,7 @@
/*********************************************************************
* Copyright (c) 2018 Daniel Darvas
-*
+* Copyright (c) 2024 Epistimis LLC
+*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
@@ -8,7 +9,7 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
-package com.github.darvasd.xtextdocs.xtext.doccomment;
+package com.epistimis.xtextdocs.xtext.doccomment;
import java.util.ArrayList;
import java.util.Arrays;
diff --git a/com.github.darvasd.xtextdocs.xtext/src/com/github/darvasd/xtextdocs/xtext/doccomment/DocCommentBlockTag.java b/com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/doccomment/DocCommentBlockTag.java
similarity index 94%
rename from com.github.darvasd.xtextdocs.xtext/src/com/github/darvasd/xtextdocs/xtext/doccomment/DocCommentBlockTag.java
rename to com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/doccomment/DocCommentBlockTag.java
index 9230342..6aa28a2 100644
--- a/com.github.darvasd.xtextdocs.xtext/src/com/github/darvasd/xtextdocs/xtext/doccomment/DocCommentBlockTag.java
+++ b/com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/doccomment/DocCommentBlockTag.java
@@ -1,6 +1,7 @@
/*********************************************************************
* Copyright (c) 2018 Daniel Darvas
-*
+* Copyright (c) 2024 Epistimis LLC
+*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
@@ -8,7 +9,7 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
-package com.github.darvasd.xtextdocs.xtext.doccomment;
+package com.epistimis.xtextdocs.xtext.doccomment;
import com.google.common.base.Preconditions;
diff --git a/com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/formatter/DotGraphBaseFormatter.xtend b/com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/formatter/DotGraphBaseFormatter.xtend
new file mode 100644
index 0000000..393f060
--- /dev/null
+++ b/com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/formatter/DotGraphBaseFormatter.xtend
@@ -0,0 +1,418 @@
+/*********************************************************************
+* Copyright (c) 2018 Daniel Darvas
+* Copyright (c) 2024 Epistimis LLC
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+**********************************************************************/
+
+package com.epistimis.xtextdocs.xtext.formatter
+
+import com.epistimis.xtextdocs.xtext.ruledoc.EnumRuleDoc
+import com.epistimis.xtextdocs.xtext.ruledoc.GrammarDoc
+import com.epistimis.xtextdocs.xtext.ruledoc.ParserRuleDoc
+import com.epistimis.xtextdocs.xtext.ruledoc.ReferenceRuleDoc
+import com.epistimis.xtextdocs.xtext.ruledoc.RuleDoc
+import com.epistimis.xtextdocs.xtext.ruledoc.TerminalRuleDoc
+import com.google.common.base.Preconditions
+import java.util.LinkedList
+import java.util.List
+import java.util.Map
+import java.util.Queue
+import org.eclipse.xtend.lib.annotations.Accessors
+import org.eclipse.xtext.AbstractElement
+import org.eclipse.xtext.AbstractRule
+import org.eclipse.xtext.Action
+import org.eclipse.xtext.Alternatives
+import org.eclipse.xtext.Assignment
+import org.eclipse.xtext.CharacterRange
+import org.eclipse.xtext.CrossReference
+import org.eclipse.xtext.EnumLiteralDeclaration
+import org.eclipse.xtext.Group
+import org.eclipse.xtext.Keyword
+import org.eclipse.xtext.NegatedToken
+import org.eclipse.xtext.RuleCall
+import org.eclipse.xtext.UnorderedGroup
+import org.eclipse.xtext.UntilToken
+import org.eclipse.xtext.Wildcard
+
+abstract class DotGraphBaseFormatter implements IGrammarDocsFormatter {
+ protected static final String EXAMPLE_TAG = "@example"
+ protected static final String VALIDATION_TAG = "@validation"
+
+ @Accessors boolean includeSimplifiedGrammar = true;
+ @Accessors boolean includeDotReferenceGraph = false;
+ @Accessors boolean includeToc = false;
+ @Accessors boolean gitbookLinkStyle = false;
+
+ /**
+ * The main title text of the documentation to be generated.
+ * If not set ({@code null}), the title will be the full name of the grammar.
+ */
+ @Accessors String mainTitle = null;
+
+ /**
+ * Title depth offset. If set to 0, the main title will be prefixed with {@code #},
+ * the second level titles with {@code ##}, etc.
+ * If it is greater than zero, the number of {@code #} characters will be increased
+ * with this number at each title.
+ */
+ protected int titleLevelOffset = 0;
+
+ /**
+ * Sets the title depth offset. If set to 0, the main title will be prefixed with {@code #},
+ * the second level titles with {@code ##}, etc.
+ * If it is greater than zero, the number of {@code #} characters will be increased
+ * with this number at each title.
+ *
+ * It is an ugly workaround to take a string as argument, but this is necessary
+ * as MWE2 does not support integer properties.
+ * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=377068 .
+ */
+ def void setTitleLevelOffset(String value) {
+ this.titleLevelOffset = Integer.parseInt(value);
+ }
+
+ /**
+ * Returns a Markdown-formatted document describing the given grammar,
+ * including all its rules.
+ *
+ * If the value of {@code includeSimplifiedGrammar} is true, the document
+ * will contain a simplified BNF description of the grammar.
+ * If the value of {@code includeDotReferenceGraph} is true, a
+ * GraphViz-style representation of the dependency between the grammar
+ * rules will also be included.
+ * If the value of {@code gitbookLinkStyle} is true, the document will
+ * use gitbook-style links and link anchors.
+ */
+ override CharSequence formatGraph(GrammarDoc grammarDoc) {
+ Preconditions.checkNotNull(grammarDoc, "grammarDoc");
+
+ val Map mapping = grammarDoc.rules.toMap([it|it.rule], [it|it]);
+
+ '''
+ «IF includeDotReferenceGraph»
+ «dotRefGraph(grammarDoc.rules, grammarDoc.rules.get(0), mapping)»
+ «ENDIF»
+ '''
+ }
+
+// /**
+// * Returns a Markdown-formatted document describing the given grammar rule.
+// *
+// * If the value of {@code gitbookLinkStyle} is true, the document will
+// * use gitbook-style links and link anchors.
+// */
+// dispatch def CharSequence formatRule(RuleDoc ruleDoc, Map mapping) {
+// }
+//
+// dispatch def CharSequence formatRule(ParserRuleDoc ruleDoc, Map mapping) '''
+// «ruleDocHeader(ruleDoc.ruleName, "")»
+// «ruleDoc.headComment.getMainDescription.docCommentFormattingToMd»
+//
+// «validationPartIfExists(ruleDoc.headComment)»
+// «examplePartIfExists(ruleDoc.headComment)»
+//
+// «ruleReferences(ruleDoc, mapping)»
+//
+// «returns(ruleDoc.rule)»
+//
+// «ruleToCodeSnippet(ruleDoc.rule)»
+// '''
+//
+//
+// dispatch def CharSequence formatRule(EnumRuleDoc ruleDoc, Map mapping) '''
+// «ruleDocHeader(ruleDoc.ruleName, "enum")»
+// «ruleDoc.headComment.getMainDescription.docCommentFormattingToMd»
+//
+// «validationPartIfExists(ruleDoc.headComment)»
+// «examplePartIfExists(ruleDoc.headComment)»
+//
+// Literals:
+// «FOR entry : getPerEnumLiteral(ruleDoc).entrySet.sortBy[it.key.name]»
+// - «entry.key.name» («FOR textLit : entry.value.map[it | it.literalText] SEPARATOR ', '»`«textLit»`«ENDFOR»)
+// «val firstCommentedLiteral = entry.value.findFirst[it | it.comment.isPresent && !it.comment.get.mainDescription.isNullOrEmpty]»«IF firstCommentedLiteral !== null» : «MarkdownTextFormatter.INSTANCE.italic(firstCommentedLiteral.comment.get.getMainDescription.docCommentFormattingToMd)»«ENDIF»
+// «ENDFOR»
+//
+// «ruleToCodeSnippet(ruleDoc.rule)»
+// '''
+//
+//
+// private def getPerEnumLiteral(EnumRuleDoc ruleDoc) {
+// val Map> ret = newHashMap();
+// for (enumLiteral : ruleDoc.literals.map[it | it.literalEnum].toSet) {
+// ret.put(enumLiteral, ruleDoc.literals.filter[it.literalEnum == enumLiteral].toList);
+// }
+// return ret;
+// }
+//
+// dispatch def CharSequence formatRule(TerminalRuleDoc ruleDoc, Map mapping) '''
+// «ruleDocHeader(ruleDoc.ruleName, '''terminal«IF ruleDoc.isTerminalFragment» fragment«ENDIF»''')»
+// «ruleDoc.headComment.getMainDescription.docCommentFormattingToMd»
+//
+// «validationPartIfExists(ruleDoc.headComment)»
+// «examplePartIfExists(ruleDoc.headComment)»
+//
+// «ruleReferences(ruleDoc, mapping)»
+//
+// «ruleToCodeSnippet(ruleDoc.rule)»
+// '''
+
+ // Private helpers
+
+ /**
+ * Returns all rules which are used from the given root rule (transitively),
+ * even if they are not in the current grammar.
+ */
+ protected def List allUsedRules(AbstractRule rootRule) {
+ val List ret = newArrayList();
+ val Queue toBeChecked = new LinkedList();
+ toBeChecked.add(rootRule);
+
+ while (!toBeChecked.isEmpty()) {
+ val current = toBeChecked.remove();
+ if (!ret.contains(current)) {
+ ret.add(current);
+ current.eAllContents.toIterable.filter(RuleCall).map[it | it.rule].forEach[it | toBeChecked.add(it)];
+ }
+ }
+
+ return ret;
+ }
+
+// private def ruleDocHeader(String ruleName, String ruleType) {
+// return '''«headerPrefix(3)» «ruleName» «IF !ruleType.nullOrEmpty»(«ruleType»)«ENDIF» «IF gitbookLinkStyle»{«toLink(ruleName)»}«ENDIF»'''
+// }
+//
+//
+// private def ruleToCodeSnippet(AbstractRule rule) '''
+// ```
+// «XtextTokenUtil.tokenTextOrUnknown(rule)»
+// ```
+// '''
+//
+// private def validationPartIfExists(DocComment headComment) '''
+// «IF headComment.getPartsWithTag(VALIDATION_TAG).isEmpty == false»
+// - **Validation:**
+// «FOR validationPart : headComment.getPartsWithTag(VALIDATION_TAG)»
+// * «validationPart.getArgument.docCommentFormattingToMd»
+// «ENDFOR»
+// «ENDIF»
+// '''
+//
+// private def examplePartIfExists(DocComment headComment) '''
+// «IF headComment.getPartsWithTag(EXAMPLE_TAG).isEmpty == false»
+// - **Examples:**
+// «FOR validationPart : headComment.getPartsWithTag(EXAMPLE_TAG)»
+// * «IF DocCommentTextUtil.containsCode(validationPart.getArgument)»«validationPart.getArgument.docCommentFormattingToMd»«ELSE»«'''`«validationPart.getArgument»`'''.toString.docCommentFormattingToMd»«ENDIF»
+// «ENDFOR»
+// «ENDIF»
+// '''
+//
+// private def ruleReferences(ReferenceRuleDoc ruleDoc, Map mapping) '''
+// «val refersTo = ruleDoc.refersTo.sortBy[it | it.name ?: ""]»
+// «IF ruleDoc.refersTo.empty == false»
+// **Refers to:**
+// «FOR ref : refersTo»
+// «IF mapping.containsKey(ref)»
+// - «mapping.get(ref).ruleName.ruleNameAsLink»
+// «ELSE»
+// - «ref.name»
+// «ENDIF»
+// «ENDFOR»
+//
+// «ENDIF»
+// «val referredBy = mapping.values.filter(ParserRuleDoc).filter[it | it.getRefersTo().contains(ruleDoc.rule)].toSet.sortBy[it.ruleName]»
+// «IF referredBy.empty == false»
+// **Referenced by:**
+// «FOR ref : referredBy»
+// - «ref.ruleName.ruleNameAsLink»
+// «ENDFOR»
+// «ENDIF»
+// '''
+//
+// private def returns(ParserRule rule) {
+// if (rule.type.metamodel.alias.nullOrEmpty) {
+// // it is in the generated metamodel, not so interesting
+// return "";
+// } else {
+// return '''**Returns:** `«rule.type.metamodel.alias»::«rule.type.classifier.name»`'''
+// }
+// }
+//
+// private def ruleNameAsLink(String ruleName) {
+// return MarkdownTextFormatter.INSTANCE.link(ruleName, toLink(ruleName));
+// }
+
+ /**
+ * The original code for generating the diagraph was Markdown specific in that it used [fenced code blocks](https://www.markdownguide.org/extended-syntax/#syntax-highlighting) - an approach similar to
+ * [this](https://oko.io/howto/graphviz-in-markdown/) to dynamically generate the graph in the page. This makes
+ * some assumptions about the browser being used to render the content.
+ * The more general approach is to simply create a .dot file and then use graphviz to generate a static file (possibly an image map) that is then
+ * referenced in the final page.
+ *
+ * So here we just generate the raw .dot file content without the fencing
+ */
+ protected def dotRefGraph(List rules, RuleDoc rootRule, Map mapping) '''
+
+
+ digraph G {
+ node[ shape="rectangle", style="filled" ];
+
+ // Highlight root rule
+ «rootRule.ruleName» [ color="red" ];
+
+ «FOR rule : rules»
+ «rule.ruleName» [ color="«ruleDotNodeColor(rule, rootRule)»", fillcolor="«ruleDotNodeFillColor(rule)»" ];
+ «IF rule instanceof ReferenceRuleDoc»
+ «FOR ref : rule.refersTo»
+««« external dependencies are skipped (e.g. ID)
+ «IF mapping.containsKey(ref)»
+««« internal dependendy
+ «rule.ruleName» -> «mapping.get(ref).ruleName»;
+ «ELSE»
+««« external dependency
+ «ref.name» [ color="«ruleDotNodeColor(rule, rootRule)»", fillcolor="«ruleDotNodeFillColor(rule)»", style="dashed" ];
+ «rule.ruleName» -> «ref.name» [ style="dashed" ];
+ «ENDIF»
+ «ENDFOR»
+ «ENDIF»
+ «ENDFOR»
+ }
+
+ '''
+
+ protected def ruleDotNodeColor(RuleDoc ruleDoc, RuleDoc rootRule) {
+ if (ruleDoc == rootRule) {
+ return "red";
+ } else {
+ return "black";
+ }
+ }
+
+ protected def ruleDotNodeFillColor(RuleDoc ruleDoc) {
+ switch (ruleDoc) {
+ EnumRuleDoc: return "#ffffcc"
+ ParserRuleDoc: return "#e6e6ff"
+ TerminalRuleDoc: return if (ruleDoc.isTerminalFragment) "#e6ffe6" else "#ccffcc"
+ default: return "white"
+ }
+ }
+
+ /**
+ * Returns a BNF-like simplified representation of the given rule
+ * definition, with Markdown formatting.
+ */
+ protected def CharSequence formattedRuleDef(AbstractElement element) {
+ return formattedRuleDef(element, false);
+ }
+
+ /**
+ * Returns a BNF-like simplified representation of the given rule
+ * definition, with Markdown formatting.
+ * @param element Element to be represented.
+ * @param parenNeeded If true and the represented element is not atomic,
+ * it will be surrounded with parentheses.
+ * @return Simplified textual representation of the given rule definition.
+ */
+ private def dispatch CharSequence formattedRuleDef(AbstractElement element, boolean parenNeeded) {
+ return '''??«element.class.simpleName»??'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(Void element, boolean parenNeeded) {
+ return '''(null)'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(Alternatives element, boolean parenNeeded) {
+ return '''«IF parenNeeded && element.elements.size > 1»(«ENDIF»«FOR it : element.elements SEPARATOR ' | '»«formattedRuleDef(it, element.elements.size > 1)»«ENDFOR»«IF parenNeeded && element.elements.size > 1»)«ENDIF»«element.cardinality»'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(UnorderedGroup element, boolean parenNeeded) {
+ return '''«IF parenNeeded && element.elements.size > 1»(«ENDIF»«FOR it : element.elements SEPARATOR ' & '»«formattedRuleDef(it, element.elements.size > 1)»«ENDFOR»«IF parenNeeded && element.elements.size > 1»)«ENDIF»«element.cardinality»'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(Group element, boolean parenNeeded) {
+ return '''«IF parenNeeded && element.elements.size > 1»(«ENDIF»«IF element.guardCondition !== null»<...>«ENDIF»«FOR it : element.elements SEPARATOR ' '»«formattedRuleDef(it, element.elements.size > 1)»«ENDFOR»«IF parenNeeded && element.elements.size > 1»)«ENDIF»«element.cardinality»'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(Assignment element, boolean parenNeeded) {
+ return '''«formattedRuleDef(element.terminal, true)»«element.cardinality»'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(CrossReference element, boolean parenNeeded) {
+ return '''«formattedRuleDef(element.terminal)»«element.cardinality»''';
+ }
+
+ private def dispatch CharSequence formattedRuleDef(Action element, boolean parenNeeded) {
+ return ''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(NegatedToken element, boolean parenNeeded) {
+ return '''!(«formattedRuleDef(element.terminal)»)«element.cardinality»'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(Wildcard element, boolean parenNeeded) {
+ return '''_._«element.cardinality»'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(UntilToken element, boolean parenNeeded) {
+ return ''' --> «formattedRuleDef(element.terminal)» «element.cardinality»'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(Keyword element, boolean parenNeeded) {
+ return '''`«keywordText(element.value)»`«element.cardinality»'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(RuleCall element, boolean parenNeeded) {
+ return '''_«element.rule.name»_«element.cardinality»'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(EnumLiteralDeclaration element, boolean parenNeeded) {
+ return formattedRuleDef(element.literal);
+ }
+
+ private def dispatch CharSequence formattedRuleDef(CharacterRange element, boolean parenNeeded) {
+ return '''[«formattedRuleDef(element.left)»..«formattedRuleDef(element.right)»]«element.cardinality»''';
+ }
+
+ private def String keywordText(String keywordValue) {
+ return keywordValue.replace("\t", "\\t").replace("\r", "\\r").replace("\n", "\\n");
+ }
+
+ /**
+ * Create a valid anchor string from the given text. This ensures
+ */
+ protected def String toAnchor(String text) {
+ // First, remove all non word text - in our case, we only need to check for parens
+ // And, compress all multiple spaces to singles
+ // Then replace spaces with dash
+ // This anchor style should work for both HTML and MD - and allows for mixed case which Gitbook MD uses
+ return text.replaceAll("\\(","").replaceAll("\\)","").replaceAll(" "," ").replaceAll("\\s", "-") //.toLowerCase;
+
+ }
+
+// private def String docCommentFormattingToMd(String text) {
+// val escaped = MarkdownTextFormatter.INSTANCE.escape(text);
+// val String resolved = DocCommentTextUtil.resolveLinks(escaped, MarkdownTextFormatter.INSTANCE, [it | toLink(it)]);
+// return DocCommentTextUtil.format(resolved, MarkdownTextFormatter.INSTANCE);
+// }
+
+// private def String toLink(String text) {
+// if (text.trim().matches("^https?://.*")) {
+// return text;
+// } else {
+// if (gitbookLinkStyle) {
+// return '''#«text.replaceAll("\\s", "-")»''';
+// } else {
+// return '''#«text.replaceAll("\\s", "-").toLowerCase»''';
+// }
+// }
+// }
+//
+// private def String headerPrefix(int level) {
+// return '''«Strings.repeat("#", level + titleLevelOffset)» ''';
+// }
+}
diff --git a/com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/formatter/HTMLDocsFormatter.xtend b/com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/formatter/HTMLDocsFormatter.xtend
new file mode 100644
index 0000000..5bef11e
--- /dev/null
+++ b/com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/formatter/HTMLDocsFormatter.xtend
@@ -0,0 +1,422 @@
+/*********************************************************************
+* Copyright (c) 2018 Daniel Darvas
+* Copyright (c) 2024 Epistimis LLC
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+**********************************************************************/
+
+package com.epistimis.xtextdocs.xtext.formatter
+
+import com.epistimis.xtextdocs.common.formatter.DocCommentTextUtil
+import com.epistimis.xtextdocs.common.formatter.MarkdownTextFormatter
+import com.epistimis.xtextdocs.common.xtext.XtextTokenUtil
+import com.epistimis.xtextdocs.xtext.doccomment.DocComment
+import com.epistimis.xtextdocs.xtext.ruledoc.EnumRuleDoc
+import com.epistimis.xtextdocs.xtext.ruledoc.EnumRuleDoc.EnumLiteralDoc
+import com.epistimis.xtextdocs.xtext.ruledoc.GrammarDoc
+import com.epistimis.xtextdocs.xtext.ruledoc.ParserRuleDoc
+import com.epistimis.xtextdocs.xtext.ruledoc.ReferenceRuleDoc
+import com.epistimis.xtextdocs.xtext.ruledoc.RuleDoc
+import com.epistimis.xtextdocs.xtext.ruledoc.TerminalRuleDoc
+import com.google.common.base.Preconditions
+import com.google.common.base.Strings
+import java.util.List
+import java.util.Map
+import org.eclipse.emf.ecore.EEnumLiteral
+import org.eclipse.xtext.AbstractElement
+import org.eclipse.xtext.AbstractRule
+import org.eclipse.xtext.Action
+import org.eclipse.xtext.Alternatives
+import org.eclipse.xtext.Assignment
+import org.eclipse.xtext.CharacterRange
+import org.eclipse.xtext.CrossReference
+import org.eclipse.xtext.EnumLiteralDeclaration
+import org.eclipse.xtext.Group
+import org.eclipse.xtext.Keyword
+import org.eclipse.xtext.NegatedToken
+import org.eclipse.xtext.ParserRule
+import org.eclipse.xtext.RuleCall
+import org.eclipse.xtext.UnorderedGroup
+import org.eclipse.xtext.UntilToken
+import org.eclipse.xtext.Wildcard
+import com.epistimis.xtextdocs.common.formatter.HTMLTextFormatter
+
+class HTMLDocsFormatter extends DotGraphBaseFormatter {
+
+ static val extension HTMLTextFormatter textFormatter = HTMLTextFormatter.INSTANCE;
+
+ override outputFileExtension() {
+ return ".html";
+ }
+
+ /**
+ * Generates a table of contents representation based on the stored anchors.
+ * For now, we only create a ToC of the Parser Rules - they are the key ones.
+ */
+ private def toc(GrammarDoc grammarDoc) {
+ return '''
+
+ ''';
+ }
+
+ /**
+ * Returns a Markdown-formatted document describing the given grammar,
+ * including all its rules.
+ *
+ * If the value of {@code includeSimplifiedGrammar} is true, the document
+ * will contain a simplified BNF description of the grammar.
+ * If the value of {@code includeDotReferenceGraph} is true, a
+ * GraphViz-style representation of the dependency between the grammar
+ * rules will also be included.
+ * If the value of {@code gitbookLinkStyle} is true, the document will
+ * use gitbook-style links and link anchors.
+ */
+ override CharSequence formatGrammar(GrammarDoc grammarDoc) {
+ Preconditions.checkNotNull(grammarDoc, "grammarDoc");
+
+ val Map mapping = grammarDoc.rules.toMap([it|it.rule], [it|it]);
+
+ '''
+
+
+
+
+
+ Table of Contents
+
+
+
+
+
+ «ENDIF»
+ '''
+
+ private def returns(ParserRule rule) {
+ if (rule.type.metamodel.alias.nullOrEmpty) {
+ // it is in the generated metamodel, not so interesting
+ return "";
+ } else {
+ return '''Returns: `«rule.type.metamodel.alias»::«rule.type.classifier.name»`'''
+ }
+ }
+
+ private def ruleNameAsLink(RuleDoc rule) {
+
+ return textFormatter.link(rule.ruleName, toLink(genRuleHeader(rule).toString.trim));
+ }
+
+ private def dotGraphRef(List rules, RuleDoc rootRule, Map mapping) '''
+
Rule dependencies
+
+ ```[graph_ref_goes_here]Graph Reference Goes Here
+ ```
+ '''
+
+
+ /**
+ * Returns a BNF-like simplified representation of the given rule
+ * definition, with HTML formatting.
+ * @param element Element to be represented.
+ * @param parenNeeded If true and the represented element is not atomic,
+ * it will be surrounded with parentheses.
+ * @return Simplified textual representation of the given rule definition.
+ */
+ private def dispatch CharSequence formattedRuleDef(AbstractElement element, boolean parenNeeded) {
+ return '''??«element.class.simpleName»??'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(Void element, boolean parenNeeded) {
+ return '''(null)'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(Alternatives element, boolean parenNeeded) {
+ return '''«IF parenNeeded && element.elements.size > 1»(«ENDIF»«FOR it : element.elements SEPARATOR ' | '»«formattedRuleDef(it, element.elements.size > 1)»«ENDFOR»«IF parenNeeded && element.elements.size > 1»)«ENDIF»«element.cardinality»'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(UnorderedGroup element, boolean parenNeeded) {
+ return '''«IF parenNeeded && element.elements.size > 1»(«ENDIF»«FOR it : element.elements SEPARATOR ' & '»«formattedRuleDef(it, element.elements.size > 1)»«ENDFOR»«IF parenNeeded && element.elements.size > 1»)«ENDIF»«element.cardinality»'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(Group element, boolean parenNeeded) {
+ return '''«IF parenNeeded && element.elements.size > 1»(«ENDIF»«IF element.guardCondition !== null»<...>«ENDIF»«FOR it : element.elements SEPARATOR ' '»«formattedRuleDef(it, element.elements.size > 1)»«ENDFOR»«IF parenNeeded && element.elements.size > 1»)«ENDIF»«element.cardinality»'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(Assignment element, boolean parenNeeded) {
+ return '''«formattedRuleDef(element.terminal, true)»«element.cardinality»'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(CrossReference element, boolean parenNeeded) {
+ return '''«formattedRuleDef(element.terminal)»«element.cardinality»''';
+ }
+
+ private def dispatch CharSequence formattedRuleDef(Action element, boolean parenNeeded) {
+ return ''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(NegatedToken element, boolean parenNeeded) {
+ return '''!(«formattedRuleDef(element.terminal)»)«element.cardinality»'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(Wildcard element, boolean parenNeeded) {
+ return '''_._«element.cardinality»'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(UntilToken element, boolean parenNeeded) {
+ return ''' --> «formattedRuleDef(element.terminal)» «element.cardinality»'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(Keyword element, boolean parenNeeded) {
+ return '''«keywordText(element.value)»«element.cardinality»'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(RuleCall element, boolean parenNeeded) {
+ return '''_«element.rule.name»_«element.cardinality»'''
+ }
+
+ private def dispatch CharSequence formattedRuleDef(EnumLiteralDeclaration element, boolean parenNeeded) {
+ return formattedRuleDef(element.literal);
+ }
+
+ private def dispatch CharSequence formattedRuleDef(CharacterRange element, boolean parenNeeded) {
+ return '''[«formattedRuleDef(element.left)»..«formattedRuleDef(element.right)»]«element.cardinality»''';
+ }
+
+ private def String keywordText(String keywordValue) {
+ return keywordValue.replace("\t", "\\t").replace("\r", "\\r").replace("\n", "\\n");
+ }
+
+ private def String docCommentFormattingToHtml(String text) {
+ val escaped = textFormatter.escape(text);
+ val String resolved = DocCommentTextUtil.resolveLinks(escaped, textFormatter, [it | toLink(it)]);
+ return DocCommentTextUtil.format(resolved, textFormatter);
+ }
+
+ private def String toLink(String text) {
+ if (text.trim().matches("^https?://.*")) {
+ return text;
+ } else {
+ // First, remove all non word text - in our case, we only need to check for parens
+ // And, compress all multiple spaces to singles
+ var temp = toAnchor(text)
+
+ if (gitbookLinkStyle) {
+ return temp;
+ } else {
+ return temp.toLowerCase;
+ }
+ }
+ }
+}
diff --git a/com.github.darvasd.xtextdocs.xtext/src/com/github/darvasd/xtextdocs/xtext/formatter/IGrammarDocsFormatter.java b/com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/formatter/IGrammarDocsFormatter.java
similarity index 69%
rename from com.github.darvasd.xtextdocs.xtext/src/com/github/darvasd/xtextdocs/xtext/formatter/IGrammarDocsFormatter.java
rename to com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/formatter/IGrammarDocsFormatter.java
index 98ce810..dc99dc6 100644
--- a/com.github.darvasd.xtextdocs.xtext/src/com/github/darvasd/xtextdocs/xtext/formatter/IGrammarDocsFormatter.java
+++ b/com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/formatter/IGrammarDocsFormatter.java
@@ -1,6 +1,7 @@
/*********************************************************************
* Copyright (c) 2018 Daniel Darvas
-*
+* Copyright (c) 2024 Epistimis LLC
+*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
@@ -8,14 +9,14 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
-package com.github.darvasd.xtextdocs.xtext.formatter;
+package com.epistimis.xtextdocs.xtext.formatter;
import java.util.Map;
import org.eclipse.xtext.AbstractRule;
-import com.github.darvasd.xtextdocs.xtext.ruledoc.RuleDoc;
-import com.github.darvasd.xtextdocs.xtext.ruledoc.GrammarDoc;
+import com.epistimis.xtextdocs.xtext.ruledoc.RuleDoc;
+import com.epistimis.xtextdocs.xtext.ruledoc.GrammarDoc;
/**
* Interface for grammar documentation generators. A class implementing this
@@ -33,6 +34,16 @@ public interface IGrammarDocsFormatter {
*/
CharSequence formatGrammar(GrammarDoc grammarDoc);
+ /**
+ * Returns a DOT graph textual representation of the given grammar
+ * documentation node, including the rules contained within.
+ *
+ * @param grammarDoc
+ * Grammar documentation.
+ * @return DOT graph textual representation of the grammar.
+ */
+ CharSequence formatGraph(GrammarDoc grammarDoc);
+
/**
* Returns a formatted, textual representation of the given single rule
* documentation node.
@@ -46,4 +57,10 @@ public interface IGrammarDocsFormatter {
* @return Formatted, textual representation of the rule.
*/
CharSequence formatRule(RuleDoc ruleDoc, Map mapping);
+
+ /**
+ * Returns the file extension for the output files created by this formatter.
+ * @return The file extension
+ */
+ String outputFileExtension();
}
diff --git a/com.github.darvasd.xtextdocs.xtext/src/com/github/darvasd/xtextdocs/xtext/formatter/MarkdownDocsFormatter.xtend b/com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/formatter/MarkdownDocsFormatter.xtend
similarity index 62%
rename from com.github.darvasd.xtextdocs.xtext/src/com/github/darvasd/xtextdocs/xtext/formatter/MarkdownDocsFormatter.xtend
rename to com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/formatter/MarkdownDocsFormatter.xtend
index 4a8add9..f131f4c 100644
--- a/com.github.darvasd.xtextdocs.xtext/src/com/github/darvasd/xtextdocs/xtext/formatter/MarkdownDocsFormatter.xtend
+++ b/com.epistimis.xtextdocs.xtext/src/com/epistimis/xtextdocs/xtext/formatter/MarkdownDocsFormatter.xtend
@@ -1,6 +1,7 @@
/*********************************************************************
* Copyright (c) 2018 Daniel Darvas
-*
+* Copyright (c) 2024 Epistimis LLC
+*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
@@ -8,26 +9,24 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
-package com.github.darvasd.xtextdocs.xtext.formatter
+package com.epistimis.xtextdocs.xtext.formatter
-import com.github.darvasd.xtextdocs.common.formatter.MarkdownTextFormatter
-import com.github.darvasd.xtextdocs.common.xtext.XtextTokenUtil
-import com.github.darvasd.xtextdocs.xtext.doccomment.DocComment
-import com.github.darvasd.xtextdocs.xtext.ruledoc.EnumRuleDoc
-import com.github.darvasd.xtextdocs.xtext.ruledoc.EnumRuleDoc.EnumLiteralDoc
-import com.github.darvasd.xtextdocs.xtext.ruledoc.GrammarDoc
-import com.github.darvasd.xtextdocs.xtext.ruledoc.ParserRuleDoc
-import com.github.darvasd.xtextdocs.xtext.ruledoc.ReferenceRuleDoc
-import com.github.darvasd.xtextdocs.xtext.ruledoc.RuleDoc
-import com.github.darvasd.xtextdocs.xtext.ruledoc.TerminalRuleDoc
+import com.epistimis.xtextdocs.common.formatter.DocCommentTextUtil
+import com.epistimis.xtextdocs.common.formatter.MarkdownTextFormatter
+import com.epistimis.xtextdocs.common.xtext.XtextTokenUtil
+import com.epistimis.xtextdocs.xtext.doccomment.DocComment
+import com.epistimis.xtextdocs.xtext.ruledoc.EnumRuleDoc
+import com.epistimis.xtextdocs.xtext.ruledoc.EnumRuleDoc.EnumLiteralDoc
+import com.epistimis.xtextdocs.xtext.ruledoc.GrammarDoc
+import com.epistimis.xtextdocs.xtext.ruledoc.ParserRuleDoc
+import com.epistimis.xtextdocs.xtext.ruledoc.ReferenceRuleDoc
+import com.epistimis.xtextdocs.xtext.ruledoc.RuleDoc
+import com.epistimis.xtextdocs.xtext.ruledoc.TerminalRuleDoc
import com.google.common.base.Preconditions
import com.google.common.base.Strings
-import java.util.LinkedList
import java.util.List
import java.util.Map
-import java.util.Queue
import org.eclipse.emf.ecore.EEnumLiteral
-import org.eclipse.xtend.lib.annotations.Accessors
import org.eclipse.xtext.AbstractElement
import org.eclipse.xtext.AbstractRule
import org.eclipse.xtext.Action
@@ -44,44 +43,46 @@ import org.eclipse.xtext.RuleCall
import org.eclipse.xtext.UnorderedGroup
import org.eclipse.xtext.UntilToken
import org.eclipse.xtext.Wildcard
-import com.github.darvasd.xtextdocs.common.formatter.DocCommentTextUtil
-class MarkdownDocsFormatter implements IGrammarDocsFormatter {
- private static final String EXAMPLE_TAG = "@example"
- private static final String VALIDATION_TAG = "@validation"
-
- @Accessors private boolean includeSimplifiedGrammar = true;
- @Accessors private boolean includeDotReferenceGraph = false;
- @Accessors private boolean gitbookLinkStyle = false;
-
- /**
- * The main title text of the documentation to be generated.
- * If not set ({@code null}), the title will be the full name of the grammar.
- */
- @Accessors private String mainTitle = null;
-
- /**
- * Title depth offset. If set to 0, the main title will be prefixed with {@code #},
- * the second level titles with {@code ##}, etc.
- * If it is greater than zero, the number of {@code #} characters will be increased
- * with this number at each title.
- */
- private int titleLevelOffset = 0;
-
+class MarkdownDocsFormatter extends DotGraphBaseFormatter {
+
+ static val extension MarkdownTextFormatter textFormatter = MarkdownTextFormatter.INSTANCE;
+
+ override outputFileExtension() {
+ return ".md";
+ }
+
+// /**
+// * Map that stores (name, id) pairs. The stored 'id' is the anchor that is used for the definition of the class 'name'.
+// */
+// SortedMap anchors = new TreeMap();
+// int anchorCounter = 1;
/**
- * Sets the title depth offset. If set to 0, the main title will be prefixed with {@code #},
- * the second level titles with {@code ##}, etc.
- * If it is greater than zero, the number of {@code #} characters will be increased
- * with this number at each title.
- *
- * It is an ugly workaround to take a string as argument, but this is necessary
- * as MWE2 does not support integer properties.
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=377068 .
+ * Generates a table of contents representation based on the stored anchors.
+ * For now, we only create a ToC of the Parser Rules - they are the key ones.
*/
- public def void setTitleLevelOffset(String value) {
- this.titleLevelOffset = Integer.parseInt(value);
+ private def toc(GrammarDoc grammarDoc) {
+ return '''
+ «headerPrefix(2)» Table of contents
+ «val tocContents = grammarDoc.rules.filter(ParserRuleDoc).toSet.sortBy[it.ruleName]»
+ «FOR ruleDoc : tocContents»
+ - «link(ruleDoc.getRuleName(), "#"+ruleDoc.getRuleName().toLowerCase())»
+ «ENDFOR»
+ ''';
}
+// /**
+// * Generates unique anchors for the classifiers in the given resource.
+// */
+// private def fillAnchors(XtextResource resource) {
+// for (EObject e : resource.allContents.toIterable) {
+// if (e instanceof XClassifier) {
+// anchors.put(e.name, "#anchor" + anchorCounter);
+// anchorCounter++;
+// }
+// }
+// }
+
/**
* Returns a Markdown-formatted document describing the given grammar,
* including all its rules.
@@ -94,18 +95,30 @@ class MarkdownDocsFormatter implements IGrammarDocsFormatter {
* If the value of {@code gitbookLinkStyle} is true, the document will
* use gitbook-style links and link anchors.
*/
- public override CharSequence formatGrammar(GrammarDoc grammarDoc) {
+ override CharSequence formatGrammar(GrammarDoc grammarDoc) {
Preconditions.checkNotNull(grammarDoc, "grammarDoc");
val Map mapping = grammarDoc.rules.toMap([it|it.rule], [it|it]);
'''
+
+
«headerPrefix(1)» «mainTitle ?: grammarDoc.grammarName»
«IF !grammarDoc.headComment.getMainDescription.nullOrEmpty»«grammarDoc.headComment.getMainDescription.docCommentFormattingToMd»«ENDIF»
+
+