Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate documentation from ruby to docfx #849

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/release_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
dotnet-version: |
9.0.x
8.0.x

- name: Setup Ruby for documentation build
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
- name: Setup docfx
run: dotnet tool install -g docfx

- name: Build documentation
run: dotnet run --project 'build/build.fsproj' -- -t Documentation
run: docfx build
working-directory: ./docs

- name: Upload documentation
uses: actions/upload-artifact@v4
with:
name: docs
path: |
bin/Release/nsubstitute.github.com/
./docs/_site
retention-days: 7
compression-level: 9
7 changes: 0 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ jobs:
9.0.x
8.0.x

# used for documentation
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true

- name: Build documentation
run: build\build.cmd --target Documentation

Expand Down
48 changes: 4 additions & 44 deletions build/build.fs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
open System
open System.Diagnostics
open System.IO

open Fake.Core
open Fake.Core.TargetOperators
open Fake.DotNet
open Fake.IO
open Fake.IO.Globbing.Operators
Expand Down Expand Up @@ -54,18 +51,18 @@ let initTargets() =
let outputCodePath = output </> "CodeFromDocs"
Directory.create outputCodePath
// generate samples from docs
ExamplesToCode.Convert [ root </> "docs/"; root </> "docs/help/_posts/"; root ] outputCodePath
ExamplesToCode.Convert [ root </> "docs/"; root </> "docs/docs"; root ] outputCodePath
// compile code samples
let csproj = """
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net462</TargetFrameworks>
<TargetFrameworks>net8.0;net462</TargetFrameworks>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\NSubstitute\NSubstitute.csproj" />
Expand All @@ -78,41 +75,6 @@ let initTargets() =
DotNet.build (fun p -> p) projPath
DotNet.test (fun p -> p) projPath

let tryFindFileOnPath (file : string) : string option =
Environment.GetEnvironmentVariable("PATH").Split([| Path.PathSeparator |])
|> Seq.append ["."]
|> fun path -> ProcessUtils.tryFindFile path file

Target.description("Build documentation website. Requires Ruby, bundler and jekyll.")
Target.create "Documentation" <| fun _ ->
Trace.log "Building site..."
let exe = [ "bundle.bat"; "bundle" ]
|> Seq.map tryFindFileOnPath
|> Seq.collect (Option.toList)
|> Seq.tryFind (fun _ -> true)
|> function | Some x -> Trace.log ("using " + x); x
| None -> Trace.log ("count not find exe"); "bundle"

let workingDir = root </> "docs/"
let docOutputRelativeToWorkingDir = ".." </> output </> "nsubstitute.github.com"

// TODO migrate the following to FAKE API: CreateProcess.ofStartInfo(p)
// https://fake.build/apidocs/v5/fake-core-createprocess.html
// that doesn't work for some reason
let p = ProcessStartInfo(
UseShellExecute = false,
CreateNoWindow = true,
FileName = exe,
WorkingDirectory = workingDir,
Arguments = "exec jekyll build -d \"" + docOutputRelativeToWorkingDir + "\"")
let proc = Process.Start(p)
proc.WaitForExit()
let result = proc.ExitCode
if result = 0 then
"Site built in " + docOutputRelativeToWorkingDir |> Trace.log
else
"failed to build site" |> failwith

Target.description("List targets, similar to `rake -T`. For more details, run `--listTargets` instead.")
Target.create "-T" <| fun _ ->
printfn "Optional config options:"
Expand All @@ -121,8 +83,6 @@ let initTargets() =
printfn ""
Target.listAvailable()

"Documentation" <== [ "TestCodeFromDocs" ]

[<EntryPoint>]
let main argv =
argv
Expand Down
9 changes: 0 additions & 9 deletions docs/_config.yml

This file was deleted.

34 changes: 0 additions & 34 deletions docs/_layouts/default.html

This file was deleted.

35 changes: 0 additions & 35 deletions docs/_layouts/post.html

This file was deleted.

17 changes: 0 additions & 17 deletions docs/_plugins/kramdownplus.rb

This file was deleted.

Loading
Loading