-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 19a5edc
Showing
17 changed files
with
706 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bin/ | ||
obj/ | ||
lib/packages/ | ||
.vs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) .NET Foundation and Contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# cake.asciidoctorj | ||
|
||
makes [asciidoctorj](https://github.com/asciidoctor/asciidoctorj) available as a tool in [cake](https://cakebuild.net/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<config> | ||
<add key="repositoryPath" value="lib/packages" /> | ||
</config> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.29102.190 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.AsciiDoctorJ", "Cake.AsciiDoctorJ\Cake.AsciiDoctorJ.csproj", "{5B65B4ED-0902-48A4-8FF6-C3E6D0954BC6}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{5B65B4ED-0902-48A4-8FF6-C3E6D0954BC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{5B65B4ED-0902-48A4-8FF6-C3E6D0954BC6}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{5B65B4ED-0902-48A4-8FF6-C3E6D0954BC6}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{5B65B4ED-0902-48A4-8FF6-C3E6D0954BC6}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {E5328D05-8D19-4D0D-B440-17BA1A2DD9DD} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Cake.Core; | ||
using Cake.Core.Annotations; | ||
using System; | ||
|
||
namespace Cake.AsciiDoctorJ | ||
{ | ||
public static class AsciiDoctorJAliases | ||
{ | ||
[CakeMethodAlias] | ||
public static IAsciiDoctorJRunner AsciiDoctorJ( | ||
this ICakeContext context, | ||
Action<AsciiDoctorJRunnerSettings> configure) | ||
{ | ||
if (context == null) | ||
throw new ArgumentNullException(nameof(context)); | ||
var runner = new AsciiDoctorJRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); | ||
return runner.Run(configure); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Cake.Core; | ||
using Cake.Core.IO; | ||
using Cake.Core.Tooling; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Cake.AsciiDoctorJ | ||
{ | ||
public class AsciiDoctorJRunner : Tool<AsciiDoctorJRunnerSettings>, IAsciiDoctorJRunner | ||
{ | ||
private ICakeEnvironment environment; | ||
|
||
public AsciiDoctorJRunner(IFileSystem fileSystem, ICakeEnvironment environment, IProcessRunner processRunner, IToolLocator tools) | ||
: base(fileSystem, environment, processRunner, tools) | ||
{ | ||
this.environment = environment; | ||
} | ||
|
||
protected override string GetToolName() => "AsciiDoctorJ Runner"; | ||
|
||
protected override IEnumerable<string> GetToolExecutableNames() => new[] { "asciidoctorj.exe", "asciidoctorj" }; | ||
|
||
internal AsciiDoctorJRunner Run(Action<AsciiDoctorJRunnerSettings> configure = null) | ||
{ | ||
var settings = new AsciiDoctorJRunnerSettings(); | ||
configure?.Invoke(settings); | ||
return Run(settings); | ||
} | ||
|
||
protected AsciiDoctorJRunner Run(AsciiDoctorJRunnerSettings settings) | ||
{ | ||
var args = new ProcessArgumentBuilder(); | ||
settings?.Evaluate(args, environment); | ||
Run(settings, args); | ||
return this; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,261 @@ | ||
using Cake.Core; | ||
using Cake.Core.IO; | ||
using Cake.Core.Tooling; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
|
||
namespace Cake.AsciiDoctorJ | ||
{ | ||
/* | ||
Options: | ||
-h, --help | ||
show this message | ||
Default: false | ||
--trace | ||
include backtrace information on errors (default: false) | ||
Default: false | ||
*/ | ||
|
||
public class AsciiDoctorJRunnerSettings : ToolSettings | ||
{ | ||
public AsciiDoctorJRunnerSettings() | ||
{ | ||
InputFiles = new List<FilePath>(); | ||
LoadPath = new List<DirectoryPath>(); | ||
ClassPath = new List<DirectoryPath>(); | ||
Attributes = new Dictionary<string, string>(); | ||
} | ||
|
||
/// <summary> | ||
/// -V, --version | ||
/// display the version and runtime environment | ||
/// Default: false | ||
/// </summary> | ||
public bool Version { get; set; } | ||
|
||
/// <summary> | ||
/// -v, --verbose | ||
/// enable verbose mode(default: false) | ||
/// Default: false | ||
/// </summary> | ||
public bool Verbose { get; set; } | ||
|
||
/// <summary> | ||
/// -t, --timings | ||
/// enable timings mode(default: false) | ||
/// Default: false | ||
/// </summary> | ||
public bool TimingsMode { get; set; } | ||
|
||
/// <summary> | ||
/// -E, --template-engine | ||
/// template engine to use for the custom render templates(loads gem on demand) | ||
/// </summary> | ||
public string TemplateEngine { get; set; } | ||
|
||
/// <summary> | ||
/// -T, --template-dir | ||
/// directory containing custom render templates the override the built-in set | ||
/// </summary> | ||
public DirectoryPath TemplateDir { get; set; } | ||
|
||
/// <summary> | ||
/// -n, --section-numbers | ||
/// auto-number section titles in the HTML backend; disabled by default | ||
/// Default: false | ||
/// </summary> | ||
public bool SectionNumbers { get; set; } | ||
|
||
/// <summary> | ||
/// -S, --safe-mode | ||
/// set safe mode level explicitly: [unsafe, safe, server, secure] (default: | ||
/// unsafe) | ||
/// Default: UNSAFE | ||
/// </summary> | ||
public SafeMode? SafeMode { get; set; } | ||
|
||
/// <summary> | ||
/// -r, --require | ||
/// require the specified library before executing the processor(using | ||
/// require) | ||
/// </summary> | ||
public bool Require { get; set; } | ||
|
||
/// <summary> | ||
/// -q, --quiet | ||
/// suppress warnings(default: false) | ||
/// Default: false | ||
/// </summary> | ||
public bool Quiet { get; set; } | ||
|
||
/// <summary> | ||
/// -o, --out-file | ||
/// output file(default: based on input file path); use - to output to | ||
/// STDOUT | ||
/// </summary> | ||
public FilePath Output { get; set; } | ||
|
||
/// <summary> | ||
/// -s, --no-header-footer | ||
/// suppress output of header and footer(default: false) | ||
/// Default: false | ||
/// </summary> | ||
public bool SuppressHeaderAndFooter { get; set; } | ||
|
||
public IList<FilePath> InputFiles { get; private set; } | ||
|
||
/// <summary> | ||
/// -I, --load-path | ||
/// add a directory to the $LOAD_PATH may be specified more than once | ||
/// </summary> | ||
public IList<DirectoryPath> LoadPath { get; private set; } | ||
|
||
/// <summary> | ||
/// -e, --eruby | ||
/// specify eRuby implementation to render built-in templates: [erb, erubis] | ||
/// (default: erb) | ||
/// Default: erb | ||
/// </summary> | ||
public ERuby? ERuby { get; set; } | ||
|
||
/// <summary> | ||
/// -d, --doctype | ||
/// document type to use when rendering output: [article, book, inline] | ||
/// (default: article) | ||
/// </summary> | ||
public DocType? DocType { get; set; } | ||
|
||
/// <summary> | ||
/// -D, --destination-dir | ||
/// destination output directory(default: directory of source file) | ||
/// </summary> | ||
public DirectoryPath DestinationDir { get; set; } | ||
|
||
/// <summary> | ||
/// -C, --compact | ||
/// compact the output by removing blank lines(default: false) | ||
/// Default: false | ||
/// </summary> | ||
public bool Compact { get; set; } | ||
|
||
/// <summary> | ||
/// -cp, -classpath, --classpath | ||
/// add a directory to the classpath may be specified more than once | ||
/// </summary> | ||
public IList<DirectoryPath> ClassPath { get; private set; } | ||
|
||
/// <summary> | ||
/// -B, --base-dir | ||
/// base directory containing the document and resources(default: directory | ||
/// of source file) | ||
/// </summary> | ||
public DirectoryPath BaseDir { get; set; } | ||
|
||
/// <summary> | ||
/// -b, --backend | ||
/// set output format backend(default: html5) | ||
/// Default: html5 | ||
/// </summary> | ||
public string Backend { get; set; } | ||
|
||
/// <summary> | ||
/// -a, --attribute | ||
/// a list of attributes, in the form key or key=value pair, to set on the | ||
/// document | ||
/// Default: [] | ||
/// </summary> | ||
public IDictionary<string, string> Attributes { get; private set; } | ||
|
||
internal void Evaluate(ProcessArgumentBuilder args, ICakeEnvironment environment) | ||
{ | ||
if (Version) | ||
{ args.Append("--version"); } | ||
|
||
if (Verbose) | ||
{ args.Append("--verbose"); } | ||
|
||
if (TimingsMode) | ||
{ args.Append("--timings"); } | ||
|
||
if (!string.IsNullOrEmpty(TemplateEngine)) | ||
{ | ||
args.Append("--template-engine " + TemplateEngine); | ||
} | ||
|
||
if (TemplateDir != null) | ||
{ | ||
args.Append("--template-dir " + TemplateDir.MakeAbsolute(environment).FullPath.Quote()); | ||
} | ||
|
||
if (SectionNumbers) | ||
{ args.Append("--section-numbers"); } | ||
|
||
if (SafeMode.HasValue) | ||
{ | ||
args.Append("--safe-mode " + Enum.GetName(typeof(SafeMode), SafeMode.Value).ToLower(CultureInfo.InvariantCulture)); | ||
} | ||
|
||
if (Require) | ||
{ args.Append("--require"); } | ||
|
||
if (Quiet) | ||
{ args.Append("--quiet"); } | ||
|
||
if (Output != null) | ||
{ | ||
args.Append("--out-file " + Output.MakeAbsolute(environment).FullPath.Quote()); | ||
} | ||
|
||
if (SuppressHeaderAndFooter) | ||
{ args.Append("--no-header-footer"); } | ||
|
||
foreach (var p in LoadPath) | ||
{ args.Append("--load-path " + p.MakeAbsolute(environment).FullPath.Quote()); } | ||
|
||
if (ERuby.HasValue) | ||
{ | ||
{ args.Append("--eruby " + Enum.GetName(typeof(ERuby), ERuby.Value).ToLower(CultureInfo.InvariantCulture)); } | ||
} | ||
|
||
if (DocType.HasValue) | ||
{ | ||
{ args.Append("--doctype " + Enum.GetName(typeof(DocType), DocType.Value).ToLower(CultureInfo.InvariantCulture)); } | ||
} | ||
|
||
if (DestinationDir != null) | ||
{ | ||
args.Append("--destination-dir " + DestinationDir.MakeAbsolute(environment).FullPath.Quote()); | ||
} | ||
|
||
if (Compact) | ||
{ args.Append("--compact"); } | ||
|
||
foreach (var p in ClassPath) | ||
{ | ||
args.Append("--classpath " + p.MakeAbsolute(environment).FullPath.Quote()); | ||
} | ||
|
||
if (BaseDir != null) | ||
{ | ||
args.Append("--base-dir " + BaseDir.MakeAbsolute(environment).FullPath.Quote()); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(Backend)) | ||
{ args.Append("--backend " + Backend); } | ||
|
||
foreach (var kvp in Attributes) | ||
{ | ||
args.Append($"--attribute {kvp.Key}={kvp.Value}"); | ||
} | ||
|
||
// input is last! | ||
foreach (var f in InputFiles) | ||
{ | ||
args.Append(f.MakeAbsolute(environment).FullPath.Quote()); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.