Skip to content

Commit

Permalink
Revert "Release preparation"
Browse files Browse the repository at this point in the history
This reverts commit 6309a61.
  • Loading branch information
actions-user committed Nov 14, 2022
1 parent 9c2000d commit e1f01ea
Show file tree
Hide file tree
Showing 35 changed files with 4,892 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test/** linguist-vendored
sample/** linguist-documentation

process_prismjs.xml linguist-language=Ant-Build-System
resource/antlib.xml linguist-language=Ant-Build-System
53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI
'on':
push:
branches:
- master
pull_request:
branches:
- master

env:
MAVEN_OPTS: >-
-Dhttp.keepAlive=false
-Dmaven.wagon.http.pool=false
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120
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: 'fox.jason.prismjs'
prerequisites: fox.jason.extend.css
setup-script: 'test/setup.sh'
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
- uses: actions/upload-artifact@v3
if: always()
with:
name: test-results
path: test-results.html
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
**/out/**
**/temp/**
**/tmp/**
target/
classes/
lib/ant-*.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

87 changes: 87 additions & 0 deletions src/fox/jason/prismjs/tasks/IterateDitaFilesTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* This file is part of the DITA-OT Pretty DITA Plug-in project.
* See the accompanying LICENSE file for applicable licenses.
*/

package fox.jason.prismjs.tasks;

import java.util.ArrayList;
import java.util.List;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.MacroInstance;
import org.apache.tools.ant.types.FileSet;

//
// Iterator function to run a given macro against a set of files
//

public class IterateDitaFilesTask extends Task {

/**
* Field list.
*/
private String list;
/**
* Field macro.
*/
private String macro;

/**
* Creates a new <code>IterateDitaFilesTask</code> instance.
*/
public IterateDitaFilesTask() {
super();
this.list = null;
this.macro = null;
}

/**
* Method setList.
*
* @param list String
*/
public void setList(String list) {
this.list = list;
}

/**
* Method setMacro.
*
* @param macro String
*/
public void setMacro(String macro) {
this.macro = macro;
}

/**
* Method execute.
*
* @throws BuildException if something goes wrong
*/
@Override
public void execute() {
// @param list - The list of files to annotate
if (this.list == null) {
throw new BuildException("You must supply a list of files to annotate");
}
if (this.macro == null) {
throw new BuildException("You must supply a macro");
}

String[] filenames = list.split(";", 0);

for (String file : filenames) {

MacroInstance task = (MacroInstance) getProject()
.createTask(this.macro);
try {
task.setDynamicAttribute("file", file);
task.execute();
} catch (Exception err) {
throw new BuildException(err);
}
}
}
}
126 changes: 126 additions & 0 deletions src/fox/jason/prismjs/tasks/IterateFilesetTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
* This file is part of the DITA-OT Pretty DITA Plug-in project.
* See the accompanying LICENSE file for applicable licenses.
*/

package fox.jason.prismjs.tasks;

import java.util.ArrayList;
import java.util.List;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.MacroInstance;
import org.apache.tools.ant.types.FileSet;

//
// Iterator function to run a given macro against a set of files
//

public class IterateFilesetTask extends Task {
/**
* Field filesets.
*/
private List<FileSet> filesets;
/**
* Field macro.
*/
private String macro;
/**
* Field file.
*/
private String file;

/**
* Field dir.
*/
private String dir;

/**
* Creates a new <code>IterateFilesetTask</code> instance.
*/
public IterateFilesetTask() {
super();
this.dir = null;
this.file = null;
this.macro = null;
this.filesets = new ArrayList<>();
}

/**
* Method setDir.
*
* @param dir String
*/
public void setDir(String dir) {
this.dir = dir;
}

/**
* Method setfile.
*
* @param file String
*/
public void setFile(String file) {
this.file = file;
}

/**
* Method setMacro.
*
* @param macro String
*/
public void setMacro(String macro) {
this.macro = macro;
}

/**
* @param set FileSet
*/
public void addFileset(FileSet set) {
this.filesets.add(set);
}

/**
* Method execute.
*
* @throws BuildException if something goes wrong
*/
@Override
public void execute() {
// @param file - The output location of the files
// @param dir - The location of the files to process
// @param macro - A macro to run.
// @param fileset - A set of files
if (this.dir == null) {
throw new BuildException("You must supply a source directory");
}
if (this.file == null) {
throw new BuildException("You must supply a destination file");
}
if (this.macro == null) {
throw new BuildException("You must supply a macro");
}
if (this.filesets.isEmpty()) {
throw new BuildException("You must supply a set of files");
}

for (FileSet fileset : this.filesets) {
DirectoryScanner scanner = fileset.getDirectoryScanner(getProject());
scanner.scan();

for (String src : scanner.getIncludedFiles()) {
MacroInstance task = (MacroInstance) getProject()
.createTask(this.macro);
try {
task.setDynamicAttribute("src", src);
task.setDynamicAttribute("dir", this.dir);
task.setDynamicAttribute("file", this.file);
task.execute();
} catch (Exception err) {
throw new BuildException(err);
}
}
}
}
}
88 changes: 88 additions & 0 deletions src/fox/jason/prismjs/tasks/ShortLangTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* This file is part of the DITA-OT Prism-JS Plug-in project
* See the accompanying LICENSE file for applicable licenses.
*/

package fox.jason.prismjs.tasks;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

//
// Obtains the corrected highlighting language from the outputclass
//

public class ShortLangTask extends Task {

/**
* Field outputclass.
*/
private String outputclass;

/**
* Field property.
*/
private String property;

/**
* Field regex.
*/
private Pattern regex;

/**
* Creates a new <code>ShortLangTask</code> instance.
*/
public ShortLangTask() {
super();
this.outputclass = null;
this.property = null;
this.regex = Pattern.compile("\\blang(?:uage)?-([\\w-]+)\\b", Pattern.CASE_INSENSITIVE);
}

/**
* Method setOutputclass.
*
* @param outputclass String
*/
public void setOutputclass(String outputclass) {
this.outputclass = outputclass;
}

/**
* Method setProperty.
*
* @param property String
*/
public void setProperty(String property) {
this.property = property;
}

/**
* Method execute.
*
* @throws BuildException if something goes wrong
*/
@Override
public void execute() {
// @param outputclass - The outputclass of the codeblock
// @param property - The property to set with the corrected
// highighting language
if (outputclass == null) {
throw new BuildException("You must supply an outputclass");
}
if (property == null) {
throw new BuildException("You must supply a property to set");
}


String language = outputclass.toLowerCase();
Matcher matcher = regex.matcher(outputclass);
if (matcher.find()) {
language = matcher.group();
language = language.substring(language.indexOf('-') + 1, language.length());
}
getProject().setProperty(property, language);
}
}
Loading

0 comments on commit e1f01ea

Please sign in to comment.