Skip to content

Commit 93e31b2

Browse files
committed
now fetches old docs without building
1 parent 4ca882d commit 93e31b2

4 files changed

Lines changed: 36 additions & 2 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
github_token: ${{ secrets.GITHUB_TOKEN }}
3131
publish_branch: gh-pages # default: gh-pages
3232
publish_dir: ./docs/.vuepress/dist
33+
user_name: 'github-actions[bot]'
34+
user_email: 'github-actions[bot]@users.noreply.github.com'
3335

3436
- name: Upload Docs
3537
uses: EndBug/add-and-commit@v9

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ Landing page containing documentation of experimental and stable Script APIs for
44

55
## Documentation
66

7-
For more detailed documentation, the changelog, and How-To Guide provided by Microsoft, see https://learn.microsoft.com/minecraft/creator/scriptapi/.
7+
For more detailed documentation, the changelog, and How-To Guide provided by Microsoft, see [Script API Documentation Homepage | Microsoft Learn](https://learn.microsoft.com/minecraft/creator/scriptapi/).
88

src/fetchOldDocs.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { execSync } from "child_process";
2+
import * as fs from "fs-extra";
3+
import path = require("path");
4+
5+
const tempBranchDir = ".temp/scriptapi-docs";
6+
const gitUrl = "https://github.com/jaylydev/scriptapi-docs.git";
7+
const branch = "gh-pages";
8+
9+
export function copyOldDocumentation () {
10+
execSync(`git clone --depth 1 --single-branch --branch ${branch} ${gitUrl} ${tempBranchDir}`);
11+
const folders = fs.readdirSync(path.resolve(tempBranchDir)).filter(f => f.startsWith("1.") && fs.statSync(path.resolve(tempBranchDir, f)).isDirectory());
12+
folders.forEach(folder => {
13+
// Copy each folder to the dist folder
14+
fs.copySync(
15+
path.resolve(tempBranchDir, folder),
16+
path.resolve("./docs/.vuepress/dist", folder)
17+
);
18+
});
19+
20+
console.log("Successfully copied existing documentation to ./docs/.vuepress/dist");
21+
22+
// Remove the cloned directory
23+
fs.rmdirSync(tempBranchDir, { recursive: true });
24+
console.log("Successfully removed cloned directory.");
25+
};

src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { execSync } from "child_process";
33
import * as dotenv from "dotenv";
44
import { generateDocsIndexPage } from "./indexPage";
55
import { PackageMetadata, installBundle, installModule } from "./installModules";
6+
import * as fs from "fs-extra";
7+
import { copyOldDocumentation } from "./fetchOldDocs";
68

79
dotenv.config();
810

@@ -17,7 +19,7 @@ const scriptModules = [
1719

1820
const bundleModules = [
1921
"@minecraft/vanilla-data",
20-
]
22+
];
2123

2224
console.log("Generating documentation for version " + version + "...");
2325

@@ -38,6 +40,11 @@ console.log("Generating documentation for version " + version + "...");
3840
execSync("npm run docs:build");
3941
console.log("Successfully built docs at ./docs/.vuepress/dist");
4042

43+
// Pull existing documentation hosted on GitHub, to reduce build time.
44+
copyOldDocumentation();
45+
console.log("Successfully copied previous documentation at ./docs/.vuepress/dist");
46+
47+
// Generate docs for version requested
4148
execSync("typedoc");
4249
console.log("Successfully ran typedoc. Documentation are generated in ./docs/.vuepress/dist/" + version);
4350
})();

0 commit comments

Comments
 (0)