Przeglądaj źródła

YSCT-1766: Added permalinks to documentation. (#1883)

* YSCT-1766: Added permalinks to documentation.

* YSCT-1766: Cleanup
Rainer Klute 8 lat temu
rodzic
commit
ba480f8b12

+ 2 - 2
plugins/org.yakindu.sct.doc.user/.classpath

@@ -3,8 +3,8 @@
 	<classpathentry kind="src" path="src/main/java"/>
 	<classpathentry kind="src" path="src/main/java"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="lib" path="lib/bin/com.google.guava/guava-15.0.jar"/>
 	<classpathentry kind="lib" path="lib/bin/com.google.guava/guava-15.0.jar"/>
-	<classpathentry kind="lib" path="lib/bin/org.eclipse.mylyn.docs/org.eclipse.mylyn.wikitext-3.0.18.jar"/>
-	<classpathentry kind="lib" path="lib/bin/org.eclipse.mylyn.docs/org.eclipse.mylyn.wikitext.textile-3.0.18.jar"/>
 	<classpathentry kind="lib" path="lib/bin/org.jsoup/jsoup-1.7.2.jar"/>
 	<classpathentry kind="lib" path="lib/bin/org.jsoup/jsoup-1.7.2.jar"/>
+	<classpathentry kind="lib" path="lib/bin/org.eclipse.mylyn.docs/org.eclipse.mylyn.wikitext-3.0.20.jar" sourcepath="lib/src/org.eclipse.mylyn.docs/org.eclipse.mylyn.wikitext-3.0.20-sources.jar"/>
+	<classpathentry kind="lib" path="lib/bin/org.eclipse.mylyn.docs/org.eclipse.mylyn.wikitext.textile-3.0.20.jar"/>
 	<classpathentry kind="output" path="bin"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
 </classpath>

+ 41 - 0
plugins/org.yakindu.sct.doc.user/css/yakindu.css

@@ -278,3 +278,44 @@ body.eclipsehelp {
     padding-left: 0em;
     padding-left: 0em;
     margin-bottom: 0ex;
     margin-bottom: 0ex;
 }
 }
+
+.body-container .primary .web-link {
+    background: #4178f0;
+    color: #fff;
+    padding: 10px 10px 10px 50px;
+    display: block;
+    position: relative;
+}
+
+.body-container .primary .web-link::before {
+    content: "";
+    position: absolute;
+    left: 10px;
+    height: 20px;
+    width: 30px;
+    border-right: 1px solid #fff;
+    background: url(http://info.itemis.com/hubfs/Corporate_Website/itemis-cta-iconset.png?t=1504179064344) no-repeat -660px -46px transparent;
+    background-size: 800px 600px;
+}
+
+.body-container .primary .web-link a {
+    color: inherit;
+    text-decoration: underline;
+}
+
+/* Add permalinks to headlines: */
+.permalink:after {
+    content: " 🔗 ";
+    font-size-adjust: 0.3;
+}
+
+.permalink {
+    visibility: hidden;
+    text-decoration: none;
+}
+
+h1:hover .permalink, h2:hover .permalink, h3:hover .permalink, h4:hover .permalink, h5:hover .permalink, h6:hover .permalink
+    {
+    visibility: visible;
+    text-decoration: none;
+}

+ 11 - 3
plugins/org.yakindu.sct.doc.user/src/main/java/org/yakindu/sct/doc/user/wikitext/HubspotDocumentBuilder.java

@@ -13,6 +13,7 @@ import java.util.Map;
 import org.eclipse.mylyn.wikitext.parser.Attributes;
 import org.eclipse.mylyn.wikitext.parser.Attributes;
 import org.eclipse.mylyn.wikitext.parser.LinkAttributes;
 import org.eclipse.mylyn.wikitext.parser.LinkAttributes;
 import org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder;
 import org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder;
+import org.eclipse.mylyn.wikitext.util.XmlStreamWriter;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -277,7 +278,6 @@ public class HubspotDocumentBuilder extends HtmlDocumentBuilder {
 		} else {
 		} else {
 			if (SpanType.LINK == type && attributes instanceof LinkAttributes) {
 			if (SpanType.LINK == type && attributes instanceof LinkAttributes) {
 				final LinkAttributes linkAttributes = (LinkAttributes) attributes;
 				final LinkAttributes linkAttributes = (LinkAttributes) attributes;
-
 				final String hrefOrHashName = linkAttributes.getHref();
 				final String hrefOrHashName = linkAttributes.getHref();
 
 
 				if (hrefOrHashName.startsWith("http")) {
 				if (hrefOrHashName.startsWith("http")) {
@@ -411,6 +411,15 @@ public class HubspotDocumentBuilder extends HtmlDocumentBuilder {
 		if (!isEarlySeparator) {
 		if (!isEarlySeparator) {
 			headings.add(currentHeading);
 			headings.add(currentHeading);
 			isProcessingHeading = false;
 			isProcessingHeading = false;
+
+			/* Write the permalink: */
+			final XmlStreamWriter w = super.getWriter();
+			w.writeStartElement("a");
+			w.writeAttribute("href", '#' + currentHeading.getId());
+			w.writeAttribute("class", "permalink");
+			w.writeAttribute("title", "Permalink to \"" + currentHeading.getTitle() + "\"");
+			w.writeEndElement();
+
 			super.endHeading();
 			super.endHeading();
 		}
 		}
 	}
 	}
@@ -450,9 +459,8 @@ public class HubspotDocumentBuilder extends HtmlDocumentBuilder {
 	public void link(final Attributes attributes, final String hrefOrHashName, final String text) {
 	public void link(final Attributes attributes, final String hrefOrHashName, final String text) {
 		if (isEarlySeparator)
 		if (isEarlySeparator)
 			h2.link(attributes, hrefOrHashName, text);
 			h2.link(attributes, hrefOrHashName, text);
-		else {
+		else
 			super.link(attributes, hrefOrHashName, text);
 			super.link(attributes, hrefOrHashName, text);
-		}
 	}
 	}
 
 
 	@Override
 	@Override