Skip to content

Commit b3075aa

Browse files
committed
misc: update DocFX log file path and enhance build documentation process
1 parent fedcf1b commit b3075aa

File tree

5 files changed

+45
-17
lines changed

5 files changed

+45
-17
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ jobs:
9090
- name: Build docs
9191
run: |
9292
dotnet tool install --global docfx --version 2.78.2
93-
docfx --version
94-
docfx Yubico.YubiKey/src/docfx.json --logLevel warning --log Yubico.YubiKey/docs/docfx-log.txt
93+
docfx Yubico.YubiKey/src/docfx.json --logLevel warning --log Yubico.YubiKey/docs/docfx.log
9594
9695
# Upload documentation
9796
- name: "Save build artifacts: Docs"

.vscode/tasks.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,22 @@
156156
],
157157
"problemMatcher": "$msCompile",
158158
"group": "test"
159+
},
160+
{
161+
"label": "Build DocFX Documentation",
162+
"type": "shell",
163+
"command": "dotnet",
164+
"args": [
165+
"msbuild",
166+
"${workspaceFolder}/Yubico.YubiKey/src/Yubico.YubiKey.csproj",
167+
"/t:DocFXBuild",
168+
],
169+
"group": {
170+
"kind": "build",
171+
"isDefault": true
172+
},
173+
"problemMatcher": [],
174+
"detail": "Builds the documentation using DocFX"
159175
}
160176
]
161177
}

Yubico.YubiKey/src/Yubico.YubiKey.csproj

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,21 +155,25 @@ limitations under the License. -->
155155

156156
</ItemGroup>
157157

158-
<!-- DocFX build target runs after Release-build -->
158+
<!-- Build documentation -->
159+
<!-- DocFX is a tool that generates documentation from source code. It is used to generate the API documentation for the YubiKey SDK. -->
160+
<!-- Run this before submitting a PR to make sure that your code does not produce any documentation issues -->
161+
<!-- This can be called either by command line or in VS Code Tasks (.vscode/tasks.json)
162+
> dotnet msbuild Yubico.YubiKey/src/Yubico.YubiKey.csproj /t:DocFXBuild
163+
-->
164+
<Target Name="DocFXBuild" DependsOnTargets="CheckDocFX;Restore;Build">
165+
<Exec Command="docfx build $(MSBuildProjectDirectory)/docfx.json --logLevel warning --log ../docs/docfx.log --warningsAsErrors" IgnoreExitCode="true">
166+
<Output TaskParameter="ExitCode" PropertyName="DocFXExitCode" />
167+
</Exec>
168+
<!-- Quirk. 255 seems to be the exit code it uses but we don't know the reason, so we catch it and refer to the log -->
169+
<Error Condition="'$(DocFXExitCode)' != '255' AND '$(DocFXExitCode)' != '0'" Text="DocFX build failed with exit code $(DocFXExitCode). Check docfx-log.txt for details." />
170+
</Target>
171+
172+
<!-- Check if DocFX is installed -->
159173
<Target Name="CheckDocFX">
160174
<Exec Command="docfx --version" ContinueOnError="true">
161175
<Output TaskParameter="ExitCode" PropertyName="DocFXExists" />
162176
</Exec>
163177
<Error Condition="'$(DocFXExists)' != '0'" Text="DocFX is not installed. Please install it using: dotnet tool install --global docfx" />
164178
</Target>
165-
166-
<Target Name="DocFXBuild" AfterTargets="Build" DependsOnTargets="CheckDocFX" Condition="'$(Configuration)' == 'ReleaseWithDocs'">
167-
<Exec Command="docfx build $(MSBuildProjectDirectory)/docfx.json --logLevel warning --log docfx-log.txt --warningsAsErrors" IgnoreExitCode="true">
168-
<Output TaskParameter="ExitCode" PropertyName="DocFXExitCode" />
169-
</Exec>
170-
<!-- Quirk. 255 seems to be the exit code it uses but we don't know the reason, so we catch it and refer to the log -->
171-
<Error Condition="'$(DocFXExitCode)' != '255' AND '$(DocFXExitCode)' != '0'"
172-
Text="DocFX build failed with exit code $(DocFXExitCode). Check docfx-log.txt for details." />
173-
</Target>
174-
175179
</Project>

contributordocs/code-flow-and-pull-requests.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,22 @@ better name than it is to push code that has nothing to do with the original nam
106106
Prior to merging into `develop`, you should check your own work for the following things:
107107

108108
- Did I remember to document all public APIs, types, members, etc.?
109-
- Did I build the ReleaseWithDocs configuration and check for build errors in the examples and documentation?
109+
- Did I [build the documentation](./documentation-system/building-docs-and-running.md) and check for build errors in the examples and documentation?
110110
- Did I write unit and/or integration tests for the functionality I just added?
111111

112112
If the answer to any one of these questions is no, please take the time to complete this task. Chances
113113
are you will be asked to do so anyways as part of the pull request process.
114114

115-
**DO** a full build (ReleaseWithDocs) prior to opening a pull request.
115+
**DO** a full build and build documentation prior to opening a pull request.
116116

117117
**CONSIDER** doing a self-review based on the branch diffs before opening a PR. Often times you can
118118
catch mistakes yourself this way.
119119

120120
**DO NOT** open a pull request for code that is not ready. Draft PRs can be used for this, or you can
121121
direct someone to checkout your in-progress branch.
122122

123+
> **NOTE:** See the page on [Building the docs and running](./documentation-system/building-docs-and-running.md) page for more information on building the documentation.
124+
123125
### Doing the review
124126

125127
Code reviews are meant to be educational for both the reviewers and the author. Regular code reviews allow

contributordocs/documentation-system/building-docs-and-running.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@ limitations under the License. -->
1414

1515
# Building the docs and running
1616

17-
We have DocFX integrated into the project's build system using NuGet. Documentation is automatically
18-
generated when the source code is compiled.
17+
We use DocFX to build the documentation for the Yubico.YubiKey project. This is a tool that
18+
generates documentation from comments in the source code. The comments are written in Markdown
19+
format.
20+
21+
In order to build the documentation, use either of the following methods:
22+
1. Command Line: `docfx build Yubico.YubiKey/src/docfx.json`
23+
2. VS Code: Run the build task `DocFXBuild` using [VS Code Tasks](https://code.visualstudio.com/docs/editor/tasks)
24+
25+
> Note: In order to run `docfx` commands, you need to have docfx installed. Install `docfx` using the following command: `dotnet tool install -g docfx`
1926
2027
The result is in `Yubico.YubiKey/docs/_site`. The home page is `index.html`.
2128

0 commit comments

Comments
 (0)