Skip to content

Commit

Permalink
Include genreated schema in docs site
Browse files Browse the repository at this point in the history
  • Loading branch information
Kieranties committed May 5, 2020
1 parent a903fdf commit 9d4f3d7
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 818 deletions.
2 changes: 2 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ The `<type>` should be *one* of the following:
+ `chore` - Trivial/Arbitrary task
+ `test` - Adding tests
+ `improvement` - Improving the implementation of existing code.
+ `ci` - Supporting the CI process.
+ `build` - A build specific change.

The `<description>` should briefly describe the changes being addressed.

Expand Down
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ packages
bin
obj
integration/temp
/docs/api/*.yml
/docs/api/.manifest
coverage.json
/src/SimpleVersion.Docs/site/api/
**/site/api/*.yml
**/site/api/.manifest
**/site/manifest.json
**/site/schema/latest.json
2 changes: 1 addition & 1 deletion Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<ItemGroup Label="Source library packages">
<PackageReference Update="LibGit2Sharp" Version="0.26.*" />
<PackageReference Update="System.Text.Json" Version="4.7.*" />
<PackageReference Update="NJsonSchema" Version="10.0.*" />
<PackageReference Update="NJsonSchema" Version="10.1.*" />
</ItemGroup>

<ItemGroup Label="Docs site packages">
Expand Down
3 changes: 1 addition & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ trigger:
- release/*
paths:
exclude:
- docs/*
- .github/*
- README.md

Expand Down Expand Up @@ -65,7 +64,7 @@ jobs:
coverageThreshold: '90'

# Handle artifacts
- publish: $(ArtifactsPath)/docs
- publish: $(ArtifactsPath)/docs/site
displayName: "Artifacts: Publish Docs"
condition: succeeded()
artifact: docs
Expand Down
9 changes: 2 additions & 7 deletions src/SimpleVersion.Docs/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,9 @@ public sealed class Program
/// <param name="args">The array of arguments.</param>
public static void Main(string[] args)
{
// TODO: arguments and options
var path = System.IO.Directory.GetCurrentDirectory();
if (args?.Length > 0)
{
path = args[0];
}
var path = args[0];

SchemaGenerator.Generate(typeof(RepositoryConfiguration), Path.Combine(path, "schema.json"));
SchemaGenerator.Generate(typeof(RepositoryConfiguration), path);
}
}
}
1 change: 1 addition & 0 deletions src/SimpleVersion.Docs/SchemaGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ internal static void Generate(Type type, string path)
};

var schema = JsonSchema.FromType(type, settings);
Directory.CreateDirectory(Directory.GetParent(path).FullName);
File.WriteAllText(path, schema.ToJson());
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/SimpleVersion.Docs/SimpleVersion.Docs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,21 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="docfx.console" PrivateAssets="All" />
<PackageReference Include="docfx.console" />
<PackageReference Include="NJsonSchema" />
<PackageReference Update="@(PackageReference)" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../**/*.csproj" PrivateAssets="All" />
<ProjectReference Remove="$(MSBuildThisFile)" />
</ItemGroup>

<Target Name="GenerateSchema" AfterTargets="Build">
<!-- Generate the schema and add to site assets -->
<Exec Command="dotnet $(OutputPath)/$(AssemblyName).dll $(MSBuildThisFileDirectory)site/schema/latest.json" />
</Target>

<Target Name="DocFxBuild" AfterTargets="Publish">
<Message Importance="High" Text="[Docs]: Building metadata" />
<Exec Command="&quot;$(BuildDocToolPath)&quot; metadata &quot;$(DocfxConfigFile)&quot; --loglevel $(DocFxLogLevel)" />
Expand Down
2 changes: 1 addition & 1 deletion src/SimpleVersion.Docs/site/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
],
"resource": [
{
"files": ["images/**", "theme/**"]
"files": ["images/**", "theme/**", "schema/**"]
}
],
"globalMetadataFiles": [],
Expand Down
Loading

0 comments on commit 9d4f3d7

Please sign in to comment.