Skip to content

Commit

Permalink
Revert "Release Preparation"
Browse files Browse the repository at this point in the history
This reverts commit e17011c.
  • Loading branch information
jason-fox committed Jul 6, 2023
1 parent c1ae578 commit a4aaad3
Show file tree
Hide file tree
Showing 344 changed files with 6,349 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sample/* linguist-vendored
test/* linguist-vendored
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CI
'on':
push:
branches:
- master
pull_request:
branches:
- master
jobs:
sonarcloud:
name: SonarCloud Scan
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Use Java 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu'
- name: SonarCloud Scan
uses: jason-fox/sonarcloud-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_CLOUD_LOGIN: ${{ secrets.SONAR_CLOUD_LOGIN }}

unit-test:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Run DITA-OT Unit Test
uses: jason-fox/dita-unit-test-action@master
with:
dita-ot-version: '4.0'
plugin: 'com.here.validate.svrl'
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
- uses: actions/upload-artifact@v3
if: always()
with:
name: test-results
path: test-results.html
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
**/out/**
**/temp/**
**/tmp/**
build_dita2svrl.xml

target/
classes/
lib/ant-*.jar
lib/ant-launcher-*.jar
.scannerwork/


*~
.fuse_hidden*
.directory
.Trash-*
.nfs*
*.DS_Store
.AppleDouble
.LSOverride
Icon
._*
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

101 changes: 101 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>
<groupId>com.here</groupId>
<artifactId>validate</artifactId>
<version>1.1</version>

<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>[1.10.9,)</version>
</dependency>
</dependencies>

<properties>
<sonar.projectKey>com.here.validate.svrl</sonar.projectKey>
<sonar.organization>dita-ot-plugins</sonar.organization>
<sonar.sources>cfg,src,xsl,Customization</sonar.sources>
<sonar.coverage.exclusions>src</sonar.coverage.exclusions>
<sonar.java.binaries>target/classes/com/here/validate/tasks,target/classes/com/here/validate/markdown</sonar.java.binaries>
<sonar.java.libraries>lib/ant-*.jar</sonar.java.libraries>
<sonar.test.exclusions>test,sample</sonar.test.exclusions>
<sonar.cpd.exclusions>src/com/here/validate/tasks/**,src/com/here/validate/markdown</sonar.cpd.exclusions>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.flex.cobertura.reportPaths>coverage.xml</sonar.flex.cobertura.reportPaths>
<sonar.exclusions>coverage.html,test-results.html,pom.xml,coverage.xml</sonar.exclusions>

</properties>

<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<filesets>
<fileset>
<directory>lib</directory>
</fileset>
</filesets>
</configuration>
</plugin>

<!-- Copy the runtime dependencies to the lib folder. -->
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/lib</outputDirectory>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgument>${compilerArgument}</compilerArgument>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<outputDirectory>${basedir}/lib</outputDirectory>
</configuration>
</plugin>

<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.9.1.2184</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sonar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
26 changes: 26 additions & 0 deletions src/com/here/validate/markdown/Analysis.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* This file is part of the DITA-OT Validation Plug-in project.
* See the accompanying LICENSE file for applicable licenses.
*/

package com.here.validate.markdown;

import java.util.List;

public class Analysis {
private List<Header> headers;
private List<Xref> xrefs;

public Analysis(List<Header> headers, List<Xref> xrefs) {
this.headers = headers;
this.xrefs = xrefs;
}

public List<Header> getHeaders() {
return this.headers;
}

public List<Xref> getXrefs() {
return this.xrefs;
}
}
73 changes: 73 additions & 0 deletions src/com/here/validate/markdown/Diagnostic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* This file is part of the DITA-OT Validation Plug-in project.
* See the accompanying LICENSE file for applicable licenses.
*/

package com.here.validate.markdown;

public enum Diagnostic {
TEXT_BEFORE_HEADER(
"text-before-header",
"Text was found before the first header",
Role.WARNING.getText()
),
HEADERS_NOT_FOUND("headers-not-found",
"No Headers found in file",
Role.ERROR.getText()),
HEADER_DEPTH_INVALID(
"header-depth-invalid",
"Header depth invalid - expected %1 but was %2",
Role.ERROR.getText()
),
HEADER_DEPTH_TOO_DEEP(
"header-depth-too-deep",
"Header depth too deep - level %1 is not allowed in MDITA",
Role.ERROR.getText()
);

private final String text;
private final String role;
private final String id;

Diagnostic(String id, String text, String role) {
this.id = id;
this.text = text;
this.role = role;
}

private String getErrorText(String arg1, String arg2) {
return this.text.replace("%1", arg1).replace("%2", arg2);
}

public String failedAssert(Header header) {
return this.failedAssert(
header.getLine(),
"h" + String.valueOf(header.getDepth()),
String.valueOf(header.getExpectedDepth()),
String.valueOf(header.getDepth())
);
}

public String failedAssert(int line, String element) {
return this.failedAssert(line, element, "", "");
}

private String failedAssert(
int line,
String element,
String arg1,
String arg2
) {
String failure =
"\t<failed-assert role=\"" + this.role + "\" location=\"\">\n";
failure =
failure + "\t\t<diagnostic-reference diagnostic=\"" + this.id + "\">";
failure =
failure + "Line " + line + ": " + element + " - [" + this.id + "]\n";
failure = failure + this.getErrorText(arg1, arg2);
failure = failure + "\t\t</diagnostic-reference>\n";
failure = failure + "\t</failed-assert>\n";

return failure;
}
}
92 changes: 92 additions & 0 deletions src/com/here/validate/markdown/Header.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* This file is part of the DITA-OT Validation Plug-in project.
* See the accompanying LICENSE file for applicable licenses.
*/

package com.here.validate.markdown;

public class Header {
private int line;
private String text;
private int depth;
private int expectedDepth;
private int parent;

public Header(
int line,
String text,
int depth,
int expectedDepth,
int parent
) {
this.line = line;
this.text = text;
this.depth = depth;
this.expectedDepth = expectedDepth;
this.parent = parent;
}

public int getLine() {
return this.line;
}

public String getText() {
return this.text;
}

public int getDepth() {
return this.depth;
}

public int getExpectedDepth() {
return this.expectedDepth;
}

public int getParent() {
return this.parent;
}

public void setLine(int line) {
this.line = line;
}

public void setText(String text) {
this.text = text;
}

public void setDepth(int depth) {
this.depth = depth;
}

public void setExpectedDepth(int expectedDepth) {
this.expectedDepth = expectedDepth;
}

public void setParent(int parent) {
this.parent = parent;
}

public boolean isInvalid() {
return this.depth != this.expectedDepth;
}

public boolean isTooDeep() {
return this.expectedDepth > 2;
}

@Override
public String toString() {
return (
" line: " +
line +
" text: " +
text +
" depth: " +
depth +
" expectedDepth: " +
expectedDepth +
" parent: " +
parent
);
}
}
Loading

0 comments on commit a4aaad3

Please sign in to comment.