-
Notifications
You must be signed in to change notification settings - Fork 14
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
Showing
11 changed files
with
238 additions
and
4 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
### New in 0.1.0 | ||
### New in 0.1.1 | ||
- Initial release | ||
- Generate your documentation with DocFxBuild |
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
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,82 @@ | ||
using System.Collections.Generic; | ||
using Cake.Core; | ||
using Cake.Core.Annotations; | ||
using Cake.Core.IO; | ||
using Cake.DocFx.Build; | ||
using Cake.DocFx.Helper; | ||
using Cake.DocFx.Metadata; | ||
|
||
namespace Cake.DocFx | ||
{ | ||
/// <summary> | ||
/// Contains functionality related to <see href="http://dotnet.github.io/docfx/index.html">DocFx</see> | ||
/// </summary> | ||
[CakeAliasCategory("DocFx")] | ||
public static class DocFxAliases | ||
{ | ||
[CakeAliasCategory("Documentation")] | ||
[CakeMethodAlias] | ||
public static void DocFxBuild(this ICakeContext context) => context.DocFxBuild(null, null); | ||
|
||
[CakeAliasCategory("Documentation")] | ||
[CakeMethodAlias] | ||
public static void DocFxBuild(this ICakeContext context, FilePath configFile) | ||
=> context.DocFxBuild(configFile, null); | ||
|
||
[CakeAliasCategory("Documentation")] | ||
[CakeMethodAlias] | ||
public static void DocFxBuild(this ICakeContext context, DocFxBuildSettings settings) | ||
=> context.DocFxBuild(null, settings); | ||
|
||
[CakeAliasCategory("Documentation")] | ||
[CakeMethodAlias] | ||
public static void DocFxBuild(this ICakeContext context, FilePath configFile, DocFxBuildSettings settings) | ||
{ | ||
Contract.NotNull(context, nameof(context)); | ||
|
||
settings = settings ?? new DocFxBuildSettings(); | ||
|
||
var runner = new DocFxBuildRunner(context.FileSystem, context.Environment, context.ProcessRunner, | ||
context.Globber); | ||
runner.Run(configFile, settings); | ||
} | ||
|
||
[CakeAliasCategory("Documentation")] | ||
[CakeMethodAlias] | ||
public static void DocFxMetadata(this ICakeContext context) | ||
=> context.DocFxMetadata((DocFxMetadataSettings) null); | ||
|
||
[CakeAliasCategory("Documentation")] | ||
[CakeMethodAlias] | ||
public static void DocFxMetadata(this ICakeContext context, FilePath configFile) | ||
{ | ||
context.DocFxMetadata(new DocFxMetadataSettings | ||
{ | ||
Projects = new[] {configFile} | ||
}); | ||
} | ||
|
||
[CakeAliasCategory("Documentation")] | ||
[CakeMethodAlias] | ||
public static void DocFxMetadata(this ICakeContext context, IEnumerable<FilePath> files) | ||
{ | ||
context.DocFxMetadata(new DocFxMetadataSettings | ||
{ | ||
Projects = files | ||
}); | ||
} | ||
|
||
[CakeAliasCategory("Documentation")] | ||
[CakeMethodAlias] | ||
public static void DocFxMetadata(this ICakeContext context, DocFxMetadataSettings settings) | ||
{ | ||
Contract.NotNull(context, nameof(context)); | ||
|
||
settings = settings ?? new DocFxMetadataSettings(); | ||
|
||
var runner = new DocFxMetadataRunner(context.FileSystem, context.Environment, context.ProcessRunner, | ||
context.Globber); | ||
runner.Run(settings); | ||
} | ||
} | ||
} |
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,35 @@ | ||
using System.Collections.Generic; | ||
using Cake.Core; | ||
using Cake.Core.IO; | ||
using Cake.Core.Tooling; | ||
|
||
namespace Cake.DocFx | ||
{ | ||
/// <summary> | ||
/// Base class for docfx tools | ||
/// </summary> | ||
/// <typeparam name="TSettings"></typeparam> | ||
public abstract class DocFxTool<TSettings> : Tool<TSettings> where TSettings : ToolSettings | ||
{ | ||
protected DocFxTool(IFileSystem fileSystem, ICakeEnvironment environment, IProcessRunner processRunner, IGlobber globber) | ||
: base(fileSystem, environment, processRunner, globber) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Gets the name of the tool. | ||
/// </summary> | ||
/// <returns> | ||
/// The name of the tool. | ||
/// </returns> | ||
protected override string GetToolName() => "DocFx"; | ||
|
||
/// <summary> | ||
/// Gets the possible names of the tool executable. | ||
/// </summary> | ||
/// <returns> | ||
/// The tool executable name. | ||
/// </returns> | ||
protected override IEnumerable<string> GetToolExecutableNames() => new[] {"docfx", "docfx.exe"}; | ||
} | ||
} |
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,18 @@ | ||
using System; | ||
|
||
namespace Cake.DocFx.Helper | ||
{ | ||
internal static class Contract | ||
{ | ||
/// <summary> | ||
/// Checks if param is not null and otherwise throws exception. | ||
/// </summary> | ||
/// <param name="parameter"></param> | ||
/// <param name="paramName"></param> | ||
internal static void NotNull(object parameter, string paramName) | ||
{ | ||
if(parameter == null) | ||
throw new ArgumentNullException(paramName); | ||
} | ||
} | ||
} |
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,40 @@ | ||
using System.Linq; | ||
using Cake.Core; | ||
using Cake.Core.IO; | ||
|
||
namespace Cake.DocFx.Metadata | ||
{ | ||
public sealed class DocFxMetadataRunner : DocFxTool<DocFxMetadataSettings> | ||
{ | ||
public DocFxMetadataRunner(IFileSystem fileSystem, ICakeEnvironment environment, IProcessRunner processRunner, IGlobber globber) | ||
: base(fileSystem, environment, processRunner, globber) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Runs docfx for current folder with the given configuration. | ||
/// </summary> | ||
/// <param name="settings"></param> | ||
public void Run(DocFxMetadataSettings settings) | ||
{ | ||
Run(settings, GetArguments(settings)); | ||
} | ||
|
||
private ProcessArgumentBuilder GetArguments(DocFxMetadataSettings settings) | ||
{ | ||
var builder = new ProcessArgumentBuilder(); | ||
|
||
// command | ||
builder.Append("metadata"); | ||
|
||
// parameters | ||
if (settings.Projects != null && settings.Projects.Any()) | ||
builder.Append(string.Join(",", settings.Projects.Select(val => val.FullPath))); | ||
|
||
if (settings.OutputPath != null) | ||
builder.Append("-o \"{0}\"", settings.OutputPath.FullPath); | ||
|
||
return builder; | ||
} | ||
} | ||
} |
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,30 @@ | ||
using System.Collections.Generic; | ||
using Cake.Core.IO; | ||
using Cake.Core.Tooling; | ||
|
||
namespace Cake.DocFx.Metadata | ||
{ | ||
/// <summary> | ||
/// Settings used for docfx metadata | ||
/// </summary> | ||
public class DocFxMetadataSettings : ToolSettings | ||
{ | ||
/// <summary> | ||
/// Specifies the projects to have metadata extracted. There are several approaches to extract language metadata. | ||
/// 1. From a supported project file or project file list | ||
/// Supported project file extensions include .csproj, .vbproj, .sln. | ||
/// 2. From a supported source code file or source code file list | ||
/// Supported source code file extensions include .cs and .vb. Files can be combined using , as seperator and search | ||
/// pattern. | ||
/// 3. From docfx.json file. If the argument is not specified, docfx.exe will try reading docfx.json under current | ||
/// directory. | ||
/// </summary> | ||
public IEnumerable<FilePath> Projects { get; set; } | ||
|
||
/// <summary> | ||
/// Optional argument. | ||
/// The default output folder is _site/ folder | ||
/// </summary> | ||
public DirectoryPath OutputPath { get; set; } | ||
} | ||
} |
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
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Cake.Core" version="0.10.0" targetFramework="net452" /> | ||
</packages> |
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
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Cake.Core" version="0.10.0" targetFramework="net452" /> | ||
</packages> |