Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>xtext-docs-gen</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
```
Expand All @@ -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:
```
Expand All @@ -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:
Expand All @@ -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:
```
Expand All @@ -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.
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.
16 changes: 16 additions & 0 deletions com.epistimis.xtextdocs.common.test/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="xtend-gen">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.github.darvasd.xtextdocs.common</name>
<name>com.epistimis.xtextdocs.common.test</name>
<comment></comment>
<projects>
</projects>
Expand Down
10 changes: 10 additions & 0 deletions com.epistimis.xtextdocs.common.test/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.github.darvasd.xtextdocs</groupId>
<artifactId>com.github.darvasd.xtextdocs.parent</artifactId>
<groupId>com.epistimis.xtextdocs</groupId>
<artifactId>com.epistimis.xtextdocs.parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
</parent>
<artifactId>com.github.darvasd.xtextdocs.xtext.test</artifactId>
<artifactId>com.epistimis.xtextdocs.common.test</artifactId>
<packaging>eclipse-test-plugin</packaging>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="xtend-gen"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.github.darvasd.xtextdocs.xtext</name>
<name>com.epistimis.xtextdocs.common</name>
<comment></comment>
<projects>
</projects>
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.github.darvasd.xtextdocs</groupId>
<artifactId>com.github.darvasd.xtextdocs.parent</artifactId>
<groupId>com.epistimis.xtextdocs</groupId>
<artifactId>com.epistimis.xtextdocs.parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
</parent>
<artifactId>com.github.darvasd.xtextdocs.xcore</artifactId>
<artifactId>com.epistimis.xtextdocs.common</artifactId>
<packaging>eclipse-plugin</packaging>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/*********************************************************************
* 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.github.darvasd.xtextdocs.common.formatter;
package com.epistimis.xtextdocs.common.formatter;

import java.util.List;
import java.util.function.Function;
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = "<pre><code>"+ original + "</code></pre>";
}
return ret;
}

override bold(String original) {
if (original.isNullOrEmpty) {
return "";
}

// The '**' does not support multiline!
return '''<b>«original»</b>''';
}

override codeBlock(String original) {
return '''
<pre><code>
«original»
</code></pre>''';
}

override inlineCode(String original) {
if (original.isNullOrEmpty) {
return "";
}

return '''<pre><code>«original»</code></pre>''';
}

override italic(String original) {
if (original.isNullOrEmpty) {
return "";
}

// The '_' does not support multiline!
return '''<i>«original»</i>''';
}

override newLine() {
return '''

''';
}

override String link(String linkText, String target) {
return '''<a href="#«target»" onclick="scrollToSection('«target»')">«linkText»</a>''';
}

override unorderedList(List<String> originals) {
return '''
<ul>
«FOR line : originals»
<li>«line»</li>
«ENDFOR»
</ul>
'''
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/*********************************************************************
* 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.github.darvasd.xtextdocs.common.formatter;
package com.epistimis.xtextdocs.common.formatter;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.darvasd.xtextdocs.common.formatter
package com.epistimis.xtextdocs.common.formatter

import java.util.List

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.github.darvasd.xtextdocs.p2</name>
<name>com.epistimis.xtextdocs.p2</name>
<comment></comment>
<projects>
</projects>
Expand Down
21 changes: 21 additions & 0 deletions com.epistimis.xtextdocs.p2/category.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<site>
<bundle id="com.epistimis.xtextdocs.common" version="1.1.0.qualifier"/>
<bundle id="com.epistimis.xtextdocs.xtext" version="1.1.0.qualifier">
<category name="com.epistimis.xtextdocs.xtext"/>
</bundle>
<bundle id="com.epistimis.xtextdocs.xcore" version="1.1.0.qualifier">
<category name="com.epistimis.xtextdocs.xcore"/>
</bundle>
<category-def name="com.epistimis.xtextdocs.xtext" label="Xtext documentation generator">
<description>
Visit http://github.com/darvasd/xtext-docs-gen for more details.
</description>
</category-def>
<category-def name="com.epistimis.xtextdocs.xcore" label="Xcore documentation generator">
<description>
Visit http://github.com/darvasd/xtext-docs-gen for more details.
</description>
</category-def>
<repository-reference location="http://download.eclipse.org/releases/oxygen/" enabled="true" />
</site>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.github.darvasd.xtextdocs</groupId>
<artifactId>com.github.darvasd.xtextdocs.parent</artifactId>
<groupId>com.epistimis.xtextdocs</groupId>
<artifactId>com.epistimis.xtextdocs.parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
</parent>
<artifactId>com.github.darvasd.xtextdocs.p2</artifactId>
<artifactId>com.epistimis.xtextdocs.p2</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>eclipse-repository</packaging>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.github.darvasd.xtextdocs</groupId>
<artifactId>com.github.darvasd.xtextdocs.parent</artifactId>
<groupId>com.epistimis.xtextdocs</groupId>
<artifactId>com.epistimis.xtextdocs.parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
</parent>
<artifactId>com.github.darvasd.xtextdocs.target</artifactId>
<artifactId>com.epistimis.xtextdocs.target</artifactId>
<packaging>eclipse-target-definition</packaging>

<dependencies>
Expand Down
Loading