Skip to content

Commit dba7525

Browse files
committed
Move towards a nuget fetcher way to generate api docs
1 parent 5b90945 commit dba7525

12 files changed

Lines changed: 1252 additions & 418 deletions

File tree

.github/workflows/main.yml

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,30 @@ on:
88

99
jobs:
1010
build:
11-
runs-on: windows-latest
11+
runs-on: ubuntu-latest
1212
steps:
1313
- name: Setup .NET (With cache)
1414
uses: actions/setup-dotnet@v5.2.0
1515
with:
16-
dotnet-version: |
17-
8.0.x
18-
9.0.x
19-
10.0.x
20-
dotnet-quality: 'preview'
16+
dotnet-version: 10.0.x
17+
dotnet-quality: 'preview'
2118

22-
- name: 'Setup Java JDK 11'
23-
uses: actions/setup-java@v5.2.0
24-
with:
25-
distribution: 'microsoft'
26-
java-version: '11'
27-
28-
- name: 'Add MSBuild to PATH'
29-
uses: microsoft/setup-msbuild@v2.0.0
30-
with:
31-
vs-prerelease: true
32-
33-
- name: 'Install DotNet workloads'
34-
shell: bash
35-
run: |
36-
dotnet workload install android ios tvos macos maui maccatalyst
37-
38-
- name: Checkout
19+
- name: Checkout
3920
uses: actions/checkout@v6
4021
with:
4122
fetch-depth: 0
4223

43-
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
24+
- name: 'Cache: .nuke/temp, NuGet packages'
4425
uses: actions/cache@v5
4526
with:
4627
path: |
4728
.nuke/temp
4829
~/.nuget/packages
49-
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
30+
reactiveui/api/cache
31+
key: ${{ runner.os }}-${{ hashFiles('**/global.json', 'nuget-packages.json') }}
5032

51-
- name: 'Restore and Compile ReactiveUI Projects'
52-
run: ./build.cmd Compile
53-
5433
- name: 'Build Website'
55-
run: ./build.cmd BuildWebsite
34+
run: ./build.sh BuildWebsite
5635

5736
- name: 'Deploy netlify'
5837
if: ${{ github.event_name != 'pull_request' }}

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,5 +349,12 @@ MigrationBackup/
349349
# Ionide (cross platform F# VS Code tools) working folder
350350
.ionide/
351351

352+
reactiveui/api/lib/
353+
reactiveui/api/cache/
354+
reactiveui/api/refs/
352355
reactiveui/api/reactiveui/
353356
reactiveui/api/reactivemarbles/
357+
reactiveui/api-android/
358+
reactiveui/api-test/
359+
reactiveui/api-windows/
360+
reactiveui/_site/

.nuke/build.schema.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
"enum": [
2727
"BuildWebsite",
2828
"Clean",
29-
"Compile",
30-
"Restore"
29+
"FetchPackages",
30+
"Serve"
3131
]
3232
},
3333
"Verbosity": {
@@ -101,13 +101,10 @@
101101
"allOf": [
102102
{
103103
"properties": {
104-
"Configuration": {
105-
"type": "string",
106-
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
107-
"enum": [
108-
"Debug",
109-
"Release"
110-
]
104+
"Port": {
105+
"type": "integer",
106+
"description": "Port for the preview server (default: 8080)",
107+
"format": "int32"
111108
}
112109
}
113110
},

build.sh

100644100755
File mode changed.

build/Build.cs

Lines changed: 25 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,149 +1,59 @@
11
using Nuke.Common;
22
using Nuke.Common.IO;
3-
using Nuke.Common.ProjectModel;
43
using Nuke.Common.Tooling;
5-
using Nuke.Common.Tools.DotNet;
6-
using Nuke.Common.Tools.MSBuild;
74
using ReactiveUI.Web;
85
using System;
9-
using System.IO;
10-
using System.Linq;
11-
using static Nuke.Common.Tools.DotNet.DotNetTasks;
126

137
class Build : NukeBuild
148
{
15-
/// Support plugins are available for:
16-
/// - JetBrains ReSharper https://nuke.build/resharper
17-
/// - JetBrains Rider https://nuke.build/rider
18-
/// - Microsoft VisualStudio https://nuke.build/visualstudio
19-
/// - Microsoft VSCode https://nuke.build/vscode
20-
21-
public static int Main() => Execute<Build>(x => x.Compile);
22-
23-
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
24-
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
25-
26-
private static readonly string reactiveui = nameof(reactiveui);
27-
private static readonly string akavache = nameof(akavache);
28-
private static readonly string fusillade = nameof(fusillade);
29-
private static readonly string punchclock = nameof(punchclock);
30-
private static readonly string splat = nameof(splat);
31-
private static readonly string DynamicData = nameof(DynamicData);
32-
private static readonly string reactivemarbles = nameof(reactivemarbles);
33-
private static readonly string extensions = nameof(extensions);
34-
private static readonly string[] RxUIProjects = [reactiveui, akavache, fusillade, punchclock, splat, "ReactiveUI.Validation", "ReactiveUI.Avalonia", extensions, "Maui.Plugins.Popup"];
35-
36-
private AbsolutePath RxUIAPIDirectory => RootDirectory / reactiveui / "api" / reactiveui;
37-
private AbsolutePath RxMAPIDirectory => RootDirectory / reactiveui / "api" / reactivemarbles;
9+
public static int Main() => Execute<Build>(x => x.BuildWebsite);
3810

11+
private AbsolutePath ApiLibDirectory => RootDirectory / "reactiveui" / "api" / "lib";
12+
private AbsolutePath ApiRefsDirectory => RootDirectory / "reactiveui" / "api" / "refs";
13+
private AbsolutePath ApiCacheDirectory => RootDirectory / "reactiveui" / "api" / "cache";
3914

4015
Target Clean => _ => _
41-
.Before(Restore)
16+
.Before(FetchPackages)
4217
.Executes(() =>
4318
{
44-
RxUIAPIDirectory.DeleteDirectory();
45-
RxMAPIDirectory.DeleteDirectory();
19+
ApiLibDirectory.DeleteDirectory();
20+
ApiRefsDirectory.DeleteDirectory();
4621
// Install docfx
4722
ProcessTasks.StartShell("dotnet tool update -g docfx").AssertZeroExitCode();
4823
});
4924

50-
Target Restore => _ => _
25+
Target FetchPackages => _ => _
5126
.DependsOn(Clean)
5227
.Executes(() =>
5328
{
54-
// Restore ReactiveUI Projects
55-
RxUIAPIDirectory.GetSources(RootDirectory, reactiveui, RxUIProjects);
56-
57-
// Restore Reactive Marbles Projects
58-
RxMAPIDirectory.GetSources(RootDirectory, reactivemarbles, DynamicData);
29+
NuGetFetcher.FetchPackages(RootDirectory);
5930
});
6031

61-
Target Compile => _ => _
62-
.DependsOn(Restore)
32+
Target BuildWebsite => _ => _
33+
.DependsOn(FetchPackages)
34+
.Produces(RootDirectory / "reactiveui" / "_site")
6335
.Executes(() =>
6436
{
65-
foreach (var project in RxUIProjects)
66-
{
67-
try
68-
{
69-
var dirRx = RxUIAPIDirectory / "external" / project / $"{project}-main" / "src";
70-
File.Copy(RootDirectory / "global.json", dirRx / "global.json", true);
71-
var solutionFile = dirRx / $"{project}.sln";
72-
73-
// Find any .sln or .slnx file as a fallback
74-
var solutionFileSearch = Directory.EnumerateFiles(dirRx, "*.sln*").FirstOrDefault();
75-
if (File.Exists(solutionFile) == false)
76-
{
77-
solutionFile += "x";
78-
if (File.Exists(solutionFile) == false)
79-
{
80-
if (File.Exists(solutionFileSearch))
81-
{
82-
solutionFile = solutionFileSearch;
83-
}
84-
else
85-
{
86-
SourceFetcher.LogRepositoryError(reactiveui, project, $"Solution file not found: {dirRx / $"{project}.sln(x)"}");
87-
continue;
88-
}
89-
}
90-
}
91-
92-
SourceFetcher.LogInfo($"Restoring {solutionFile}...");
93-
DotNetRestore(s => s.SetProjectFile(solutionFile));
94-
SourceFetcher.LogInfo($"Building {solutionFile}...");
95-
DotNetBuild(s => s
96-
.SetProjectFile(solutionFile)
97-
.SetConfiguration(Configuration)
98-
.EnableNoRestore());
99-
SourceFetcher.LogInfo($"{project} build complete");
100-
}
101-
catch (Exception ex)
102-
{
103-
SourceFetcher.LogRepositoryError(reactiveui, project, ex.ToString());
104-
}
105-
}
106-
10737
try
10838
{
109-
var dirDd = RxMAPIDirectory / "external" / DynamicData / $"{DynamicData}-main" / "src";
110-
File.Copy(RootDirectory / "global.json", dirDd / "global.json", true);
111-
var solutionFile = dirDd / $"{DynamicData}.sln";
112-
if (File.Exists(solutionFile) == false)
113-
{
114-
solutionFile += "x";
115-
if (File.Exists(solutionFile) == false)
116-
{
117-
SourceFetcher.LogRepositoryError(reactivemarbles, DynamicData, $"Solution file not found: {dirDd / $"{DynamicData}.sln(x)"}");
118-
return;
119-
}
120-
}
121-
122-
SourceFetcher.LogInfo($"Building {solutionFile}...");
123-
MSBuildTasks.MSBuild(s => s
124-
.SetProjectFile(solutionFile)
125-
.SetConfiguration(Configuration)
126-
.SetRestore(true));
127-
SourceFetcher.LogInfo($"{DynamicData} build complete");
39+
NuGetFetcher.PatchDocfxJson(RootDirectory);
40+
ProcessTasks.StartShell("docfx reactiveui/docfx.json").AssertZeroExitCode();
41+
NuGetFetcher.LogInfo("Web Site build complete");
12842
}
12943
catch (Exception ex)
13044
{
131-
SourceFetcher.LogRepositoryError(reactivemarbles, DynamicData, ex.ToString());
45+
NuGetFetcher.LogError(ex.ToString());
13246
}
13347
});
13448

135-
Target BuildWebsite => _ => _
136-
.Produces(RootDirectory / reactiveui / "_site")
137-
.Executes(() =>
138-
{
139-
try
140-
{
141-
ProcessTasks.StartShell("docfx reactiveui/docfx.json").AssertZeroExitCode();
142-
SourceFetcher.LogInfo("Web Site build complete");
143-
}
144-
catch (Exception ex)
49+
[Parameter("Port for the preview server (default: 8080)")]
50+
readonly int Port = 8080;
51+
52+
Target Serve => _ => _
53+
.DependsOn(BuildWebsite)
54+
.Executes(() =>
14555
{
146-
SourceFetcher.LogError(ex.ToString());
147-
}
148-
});
56+
NuGetFetcher.LogInfo($"Serving website at http://localhost:{Port}");
57+
ProcessTasks.StartShell($"docfx serve reactiveui/_site -p {Port}").AssertZeroExitCode();
58+
});
14959
}

0 commit comments

Comments
 (0)