Skip to content

Commit a69bcc8

Browse files
authored
Gradle task for serving docs (#3846)
1 parent f3e1f54 commit a69bcc8

4 files changed

Lines changed: 56 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ out/
88
output/
99
bin/
1010
libs/
11+
docs/site
1112

1213
.classpath
1314
*/.factorypath

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ apply from: "$rootDir/dependencies.gradle"
8686
apply from: "$rootDir/gradle/scripts/resources.gradle"
8787
apply from: "$rootDir/gradle/scripts/publishing.gradle"
8888
apply from: "$rootDir/gradle/scripts/spotless.gradle"
89+
apply from: "$rootDir/gradle/scripts/docs.gradle"
8990

9091

9192
tasks.withType(JavaCompile).configureEach {

docs/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,21 @@ Once you're happy, commit these changes and make a pull request for us to review
2626
If you come back to work on the docs, you can use a codespace again. You might need to `pull` to bring your codespace up to date, which you can do by pressing this button in the `Source Control` tab.
2727

2828
![image](https://github.com/user-attachments/assets/7d1246d2-f091-4452-bdb3-edf221902503)
29+
30+
## Running in Gradle
31+
32+
To run mkdocs locally, run the mkdocsServe task in gradle.
33+
34+
Either in the gradle sidebar, click documentation/mkdocsServe, or run .`/gradlew mkdocsServe`.
35+
36+
Click on the link it gives you at the bottom to open the local copy, and pages will automatically update with content as you save your files.
37+
38+
You can also run documentation/mkdocsBuild. This will build the documentation in `docs/site`, which you can either host yourself or just open in a browser.
39+
2940
## Installing Required Dependencies & Run Locally
3041

42+
If you want to manually install and go through the steps to run locally, you can follow the steps below.
43+
3144
Please run all commands from this section inside the `docs` folder!
3245

3346
**First, setup a venv for python:**

gradle/scripts/docs.gradle

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import org.apache.tools.ant.taskdefs.condition.Os
2+
3+
tasks.register('mkdocsSetup', Exec) {
4+
description = "Installs requirements for the MkDocs server."
5+
group = "documentation"
6+
7+
workingDir 'docs'
8+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
9+
commandLine 'cmd.exe', '/c',
10+
'python -m venv .venv && .venv\\Scripts\\pip.exe install -r requirements.txt'
11+
} else {
12+
commandLine '/usr/bin/env', 'bash', '-c',
13+
'python3 -m venv .venv && ./.venv/bin/pip3 install -r requirements.txt'
14+
}
15+
}
16+
17+
tasks.register('mkdocsServe', Exec) {
18+
description = "Runs the MkDocs server."
19+
group = "documentation"
20+
dependsOn tasks.named('mkdocsSetup')
21+
22+
workingDir 'docs'
23+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
24+
commandLine '.\\docs\\.venv\\Scripts\\mkdocs.exe', 'serve'
25+
} else {
26+
commandLine './docs/.venv/bin/mkdocs', 'serve'
27+
}
28+
}
29+
30+
tasks.register('mkdocsBuild', Exec) {
31+
description = "Builds the MkDocs documentation in docs/site."
32+
group = "documentation"
33+
dependsOn tasks.named('mkdocsSetup')
34+
35+
workingDir 'docs'
36+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
37+
commandLine '.\\docs\\.venv\\Scripts\\mkdocs.exe', 'build'
38+
} else {
39+
commandLine './docs/.venv/bin/mkdocs', 'build'
40+
}
41+
}

0 commit comments

Comments
 (0)