Skip to content

Commit 9912690

Browse files
authored
Add utility for clean builds and link checks; update README accordingly (#53)
* Resolve issues #24 & #43 - Add a powershell script to clean files and check links - Add stuff in README regarding the bullet point above including a dedicated section - Fix typos in README Miscellaneous: - docfx.json files entry refactored to be more succinct - index.md configured with landing page metadata in docfx.json and removed relevant metadata from the file itself
1 parent 2c2902c commit 9912690

File tree

4 files changed

+92
-20
lines changed

4 files changed

+92
-20
lines changed

README.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Download and install [git](https://git-scm.com/downloads) if it is not installed
3131
``` console
3232
git submodule update --recursive --init
3333
```
34+
In particular, the source code is available in this repo as a submodule. This will update the source code to the latest commit on main.
3435
1. Configure the docfx version and restore docfx companion tools such as [DocLinkChecker](https://github.com/Ellerbach/docfx-companion-tools/tree/main/src/DocLinkChecker).
3536

3637
``` console
@@ -49,10 +50,7 @@ Download and install [git](https://git-scm.com/downloads) if it is not installed
4950

5051
## Build Documentation Locally
5152

52-
> [!NOTE]
53-
> The following steps should be be performed in Powershell.
54-
55-
To build the docs and serve locally, run:
53+
To build the docs and serve locally, run in PowerShell:
5654

5755
``` console
5856
./build.ps1 --serve
@@ -74,7 +72,7 @@ git submodule update --recursive --remote
7472

7573
## Before Pushing
7674

77-
The following three commands are run remotely by remote GitHub Actions serve upon pushing to a branch. The branch will not be able to merge to main unless all three commands completely successfully without any errors. Confirm that that they can complete successfully without errors locally before committing and pushing. Otherwise, the branch becomes cluttered with potentially several attempts to pass the link-check process. Run:
75+
The following three commands are run remotely by remote GitHub Actions serve upon pushing to a branch. The branch will not be able to merge to main unless all three commands complete successfully without any errors. Confirm that they can complete successfully without errors locally before committing and pushing. Otherwise, the branch becomes cluttered with potentially several attempts to pass the link-check process. Run:
7876

7977
``` console
8078
.\build.ps1 --logLevel Warning --warningsAsErrors
@@ -83,6 +81,8 @@ dotnet DocLinkChecker -v -f .github/workflows/DocLinkChecker.config
8381

8482
If the above command fails because "you must install or update .NET", follow the URL from the failed command's output or [this one](https://dotnet.microsoft.com/en-us/download/dotnet/6.0/runtime?cid=getdotnetcore&os=windows&arch=x64) to download and install .NET runtime 6. Dotnet supports simultaneous installation of several .NET runtime versions, and version 6 is required to run the DocLinkChecker.
8583

84+
The above set of commands can also be run using the `docfx-util.ps1` Powershell script. Specifically, run `./docfx-util.ps1 -d` in the repo's root directory.
85+
8686
To run the next command, install [Lychee](https://github.com/lycheeverse/lychee?tab=readme-ov-file) by following [these instructions](https://github.com/lycheeverse/lychee?tab=readme-ov-file#installation). If you are use Windows and download a Lychee executable, amend the below command according to the location and version of your Lychee executable, and run it.
8787

8888
``` console
@@ -91,6 +91,26 @@ To run the next command, install [Lychee](https://github.com/lycheeverse/lychee?
9191

9292
If you use a different operating systems and a different methods of installation, the above command might require additional amendments.
9393

94+
The above command can also be run using the `docfx-util.ps1` Powershell script. Specifically, run `./docfx-util.ps1 -l <path/to/lychee.exe>` in the repo's root directory.
95+
96+
All three link-checking commands can be run with the following command: `./docfx-util.ps1 -a` in the repo's root directory. This command additionally cleans remaining artifacts from past builds before performing all the link-checking commands. This is the most robust and expedient way to confirm that the repo will pass the link checks when pushed.
97+
98+
### docfx-utils.ps1
99+
100+
This is summary of docfx-utils.ps1 list members. They are described above, but they are also described below for ease-of-finding:
101+
102+
- `docfx-utils.ps1 -c` cleans cached files/removes artifacts from previous builds.
103+
- `docfx-utils.ps1 -b` exports SVGs and builds the docs.
104+
- `docfx-utils.ps1 -l <path/to/lychee.exe>` checks for broken/missing links and references.
105+
- `docfx-utils.ps1 -a <path/to/lychee.exe>` performs all of the above steps.
106+
107+
`docfx-utils.ps1 -l` and `docfx-utils.ps1 -a` will not run without a path to a lychee executable.
108+
109+
> [!NOTE]
110+
> The docfx-utils.ps1 script (.ps1 PowerShell scripts in general) must be run in PowerShell.
111+
112+
These commands do not serve the docs. Serve them by running `dotnet docfx serve`.
113+
94114
## `dotnet docfx`
95115

96116
Running `dotnet docfx` runs both the `dotnet docfx metadata` command and the `dotnet docfx build` command in that order. Unless specified otherwise, `dotnet docfx` uses the `docfx.json` as its config file.
@@ -152,7 +172,7 @@ If local html pages don't appear to be updating, hard refresh website pages in b
152172
If there are discrepancies between local and remote builds:
153173

154174
* Confirm local and remote docfx versions are consistent. This inconsistency can occur when, for example, running `docfx` instead of `dotnet docfx` or running `dotnet tool restore --configfile <configfile>` on another config file other than the one in this repo.
155-
* Clear the local files to remove any cached files that aren't available remotely. Such files exist in the `api` directory (though care to not delete the `.gitignore` in that directory), the `_site` directory, and the workflows directory.
175+
* Clear any locally cached files that aren't available remotely. Such files exist in the `api` directory (though care to not delete the `.gitignore` in that directory), the `_site` directory, and the workflows directory. Run `./docfx-util.ps1 -c` to clean artifacts from previous builds.
156176

157177
## Docs Maintainability
158178

docfx-utils.ps1

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
[CmdletBinding(PositionalBinding=$false)]
3+
param
4+
(
5+
[parameter(mandatory=$false)][switch][Alias("c")]$clean,
6+
[parameter(mandatory=$false)][switch][Alias("b")]$build,
7+
[parameter(mandatory=$false)][string][Alias("l")]$linkcheck,
8+
[parameter(mandatory=$false)][string][Alias("a")]$all
9+
)
10+
11+
# this is called removeartifacts instead of clean because clean might be already mean something in powershell?
12+
function removeartifacts
13+
{
14+
$deletePaths = ".\workflows\**\*.svg", ".\api\*.yml", ".\api\.manifest", ".\_site\", ".\_raw\", ".\_view\"
15+
foreach($deletePath in $deletePaths){if (Test-Path $deletePath){Remove-Item $deletePath -Recurse}}
16+
Write-Output ""
17+
}
18+
19+
function build{.\build.ps1 --logLevel Warning --warningsAsErrors}
20+
21+
function linkcheck
22+
{
23+
param($lycheePath)
24+
Write-Output "`nRunning DocLinkChecker... (step one)"
25+
Write-Output "------------------------------------------`n"
26+
dotnet DocLinkChecker -v -f .github/workflows/DocLinkChecker.config
27+
Write-Output "`nRunning lychee... (step two)"
28+
Write-Output "------------------------------------------`n"
29+
Invoke-Expression "& `"$lycheePath`" --no-progress --base _site --exclude ^https://github\.com.*merge.* --exclude ^https://github\.com.*apiSpec.* '_site/**/*.html'"
30+
Write-Output "`n"
31+
}
32+
33+
if ($clean){removeartifacts}
34+
35+
if ($build){build}
36+
37+
if ($PSBoundParameters.ContainsKey("linkcheck")){linkcheck($linkcheck)}
38+
39+
if ($PSBoundParameters.ContainsKey("all"))
40+
{
41+
Write-Output "`n------------------------------------------"
42+
Write-Output "Cleaning artifacts..."
43+
Write-Output "------------------------------------------"
44+
removeartifacts
45+
Write-Output "------------------------------------------"
46+
Write-Output "Exporting SVGs & building docs..."
47+
Write-Output "------------------------------------------`n"
48+
Start-Sleep -Seconds 2
49+
build
50+
Write-Output "`------------------------------------------"
51+
Write-Output "Running linkchecks... (two step process)"
52+
Write-Output "------------------------------------------"
53+
Start-Sleep -Seconds 2
54+
linkcheck($all)
55+
}

docfx.json

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,20 @@
1414
}
1515
],
1616
"build": {
17+
"fileMetadata": {
18+
"_layout": {
19+
"index.md": "landing"
20+
}
21+
},
1722
"content": [
1823
{
1924
"files": [
20-
"api/**.yml",
21-
"api/**.md"
22-
]
23-
},
24-
{
25-
"files": [
26-
"articles/**.md",
27-
"articles/**/toc.yml",
28-
"tutorials/**.md",
29-
"tutorials/**/toc.yml",
30-
"toc.yml",
31-
"*.md"
32-
]
25+
"api/**/*.{md,yml}",
26+
"articles/**/*.{md,yml}",
27+
"tutorials/**/*.{md,yml}",
28+
"*.{md,yml}"
29+
],
30+
"exclude": ["filter.yml"]
3331
}
3432
],
3533
"resource": [

index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
uid: index
33
title: OpenEphys.Onix1
4-
_disableBreadcrumb: true
54
---
65

76
> [!Warning]

0 commit comments

Comments
 (0)