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

Documentation improvements - suggestion for GitBook #413

Merged
merged 5 commits into from
Oct 16, 2024
Merged
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
51 changes: 51 additions & 0 deletions .github/workflows/typedoc-generate-gitbook-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Deploy TypeDoc to GitBook

on:
push:
branches:
- develop

env:
NODE_VERSION: 18.x
ENTRY_FILE: "packages"
CONFIG_PATH: "tsconfig.base.json"
USES_PNPM: "true"

jobs:
deploy:
concurrency: ci-${{ github.ref }}
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Install dependencies
run: pnpm install --no-frozen-lockfile

- name: Build project
run: pnpm build

- name: Build documentation
run: pnpm docs:generate-markdown

- name: Deploy to GitBook
run: |
git clone --branch=git-book https://github.com/near/near-sdk-js.git book
rsync -av --delete markdown-docs/ book/
cd book
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add .
git commit -m "Update documentation [skip ci]"
git push https://frol:${{ secrets.MY_GITHUB_TOKEN }}@github.com/near/near-sdk-js.git git-book
25 changes: 25 additions & 0 deletions generate-docs-markdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const { readFileSync, writeFileSync, unlinkSync } = require("fs");
const { execSync } = require("child_process");

// Load the base configuration from typedoc.json
const baseConfig = JSON.parse(readFileSync("./typedoc.json", "utf8"));

// Extend the base configuration for Markdown documentation
const markdownConfig = {
...baseConfig,
githubPages: false,
out: "markdown-docs",
plugin: ["typedoc-plugin-markdown"],
};

// Write the extended configuration to a temporary file
const configFilePath = "./typedoc-markdown.json";
writeFileSync(configFilePath, JSON.stringify(markdownConfig, null, 2));

// Run TypeDoc with the extended configuration
try {
execSync(`npx typedoc --options ${configFilePath}`, { stdio: "inherit" });
} finally {
// Clean up the temporary file
unlinkSync(configFilePath);
}
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
"test": "turbo run test",
"lint": "turbo run lint",
"format": "turbo run format",
"docs:generate": "typedoc"
"docs:generate": "typedoc",
"docs:generate-markdown": "node generate-docs-markdown.js"
},
"devDependencies": {
"turbo": "1.10.16",
"typedoc": "0.25.4",
"typedoc": "0.26.6",
"typedoc-plugin-markdown": "4.2.6",
"typescript": "4.7.4"
}
}
}
Loading
Loading