-
Notifications
You must be signed in to change notification settings - Fork 1k
Migrate docs site from Jekyll to DocFX #1642
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
Open
clairernovotny
wants to merge
20
commits into
main
Choose a base branch
from
use-docfx
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
e39088f
Migrate docs site from Jekyll to DocFX
clairernovotny b75435a
Docs: refine examples and configuration guidance across documentation
clairernovotny 9d0b15e
Docs: extract DocFX multi-version build into scripts/build-docfx.sh a…
clairernovotny 402b28b
Merge branch 'main' into use-docfx
clairernovotny ca4b984
Address code review feedback: fix documentation syntax and handle leg…
Copilot 5d312f0
Update docs/application-integration.md
clairernovotny b8fdf57
Update docs/string-transformations.md
clairernovotny 4e8df74
Fix documentation paths, error codes, and script robustness (#1644)
Copilot f05cc09
Automate API toc.yml generation in DocFX (#1645)
Copilot ff6efd6
fixes
clairernovotny 2aae79f
add docfx prerelease feed
clairernovotny 47746b8
remove old feed
clairernovotny 18cb468
Adopt Docusaurus shell with DocFX API pipeline
clairernovotny 7a4db65
add serena config
clairernovotny 37257ee
Add docs generation helper script
clairernovotny 7341a4e
Improve API docs navigation and theming
clairernovotny de24982
Enable Prism syntax highlighting for docs
clairernovotny 99505c3
Fix API page layout and hook usage
clairernovotny 3c91ddd
Enhance documentation generation and API reference structure
clairernovotny 4fab166
Refactor build commands in suggested_commands.md for clarity
clairernovotny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "version": 1, | ||
| "isRoot": true, | ||
| "tools": { | ||
| "docfx": { | ||
| "version": "2.78.4", | ||
| "commands": [ | ||
| "docfx" | ||
| ], | ||
| "rollForward": false | ||
| }, | ||
| "docfxmarkdowngen": { | ||
| "version": "0.5.0", | ||
| "commands": [ | ||
| "dfmg" | ||
| ], | ||
| "rollForward": false | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| name: Build and Deploy Docs | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["main"] | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pages: write | ||
| id-token: write | ||
|
|
||
| concurrency: | ||
| group: "pages" | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup .NET SDK | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| global-json-file: global.json | ||
|
|
||
| - name: Restore .NET tools | ||
| run: dotnet tool restore | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: npm | ||
| cache-dependency-path: website/package-lock.json | ||
|
|
||
| - name: Install Docusaurus dependencies | ||
| working-directory: website | ||
| run: npm ci | ||
|
|
||
| - name: Build DocFX API versions | ||
| shell: bash | ||
| run: .github/workflows/scripts/build-docfx.sh | ||
|
|
||
| - name: Build Docusaurus site | ||
| working-directory: website | ||
| run: npm run build | ||
|
|
||
| - name: Setup Pages | ||
| uses: actions/configure-pages@v5 | ||
|
|
||
| - name: Upload artifact | ||
| uses: actions/upload-pages-artifact@v3 | ||
| with: | ||
| path: website/build | ||
|
|
||
| deploy: | ||
| environment: | ||
| name: github-pages | ||
| url: ${{ steps.deployment.outputs.page_url }} | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| steps: | ||
| - name: Deploy to GitHub Pages | ||
| id: deployment | ||
| uses: actions/deploy-pages@v4 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,251 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| ROOT="$(pwd)" | ||
| ARTIFACT_DIR="$ROOT/.docfx-artifacts" | ||
| WORKTREE_ROOT="$ROOT/.docfx-worktrees" | ||
| STATIC_API_DIR="$ROOT/website/static/api" | ||
| METADATA_ROOT="$ROOT/.dfmg-metadata" | ||
| API_DOCS_ROOT="$ROOT/website/api-docs" | ||
| API_VERSIONS_FILE="$API_DOCS_ROOT/versions.json" | ||
| DFMG_CONFIG_PATH="$ROOT/docs/dfmg.config.yaml" | ||
| WORKTREES_TO_REMOVE=() | ||
| DOCFX_CMD="dotnet tool run docfx" | ||
|
|
||
| cleanup() { | ||
| if [ ${#WORKTREES_TO_REMOVE[@]} -gt 0 ]; then | ||
| for worktree in "${WORKTREES_TO_REMOVE[@]}"; do | ||
| if [ -d "$worktree" ]; then | ||
| git worktree remove --force "$worktree" >/dev/null 2>&1 || true | ||
| fi | ||
| done | ||
| fi | ||
|
|
||
| rm -rf "$ARTIFACT_DIR" "$WORKTREE_ROOT" | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| rm -rf "$ARTIFACT_DIR" "$WORKTREE_ROOT" "$METADATA_ROOT" | ||
| mkdir -p "$ARTIFACT_DIR" "$WORKTREE_ROOT" "$METADATA_ROOT" | ||
| rm -rf "$STATIC_API_DIR" | ||
| mkdir -p "$STATIC_API_DIR" | ||
| mkdir -p "$API_DOCS_ROOT" | ||
| rm -rf "$API_DOCS_ROOT"/dev "$API_DOCS_ROOT"/v* | ||
|
|
||
| build_docfx_for_checkout() { | ||
| local checkout_root="$1" | ||
| local destination_name="$2" | ||
|
|
||
| pushd "$checkout_root" >/dev/null | ||
| $DOCFX_CMD metadata docs/docfx.json | ||
| $DOCFX_CMD build docs/docfx.json | ||
| popd >/dev/null | ||
|
|
||
| mkdir -p "$ARTIFACT_DIR/$destination_name" | ||
| cp -a "$checkout_root/docs/_site/." "$ARTIFACT_DIR/$destination_name/" | ||
|
|
||
| if [ -d "$checkout_root/docs/api" ]; then | ||
| mkdir -p "$METADATA_ROOT/$destination_name" | ||
| cp -a "$checkout_root/docs/api/." "$METADATA_ROOT/$destination_name/" | ||
| fi | ||
| } | ||
|
|
||
| generate_markdown_for_version() { | ||
| local metadata_key="$1" | ||
| local slug="$2" | ||
| local label="$3" | ||
|
|
||
| local metadata_dir="$METADATA_ROOT/$metadata_key" | ||
| if [ ! -d "$metadata_dir" ]; then | ||
| echo "Skipping markdown generation for $metadata_key (metadata missing)" | ||
| return | ||
| fi | ||
|
|
||
| local output_dir="$API_DOCS_ROOT/$slug" | ||
| rm -rf "$output_dir" | ||
| mkdir -p "$output_dir" | ||
|
|
||
| DFMG_CONFIG="$DFMG_CONFIG_PATH" \ | ||
| DFMG_YAML_PATH="$metadata_dir" \ | ||
| DFMG_OUTPUT_PATH="$output_dir" \ | ||
| dotnet tool run dfmg >/dev/null | ||
|
|
||
| # add a small marker so we know the directory corresponds to this slug | ||
| printf '{\n "label": "%s",\n "slug": "%s"\n}\n' "$label" "$slug" >"$output_dir/.dfmg-version.json" | ||
|
|
||
| sanitize_markdown_directory "$output_dir" "$slug" | ||
| } | ||
|
|
||
| sanitize_markdown_directory() { | ||
| local target_dir="$1" | ||
| local slug="$2" | ||
| python3 - "$target_dir" "$slug" <<'PY' | ||
| import pathlib | ||
| import re | ||
| import sys | ||
|
|
||
| root = pathlib.Path(sys.argv[1]) | ||
| slug = sys.argv[2] | ||
| pattern = re.compile(r'(?<![`\\])\{([A-Za-z0-9_]+)\}') | ||
| link_pattern = re.compile(r'\]\(((?:\./|\.\./)+)([^)]+)\)') | ||
|
|
||
| for md_path in root.rglob('*.md'): | ||
| text = md_path.read_text(encoding='utf-8') | ||
| lines = text.splitlines() | ||
| inside_code = False | ||
| changed = False | ||
| for index, line in enumerate(lines): | ||
| stripped = line.strip() | ||
| if stripped.startswith('```'): | ||
| inside_code = not inside_code | ||
| continue | ||
| if inside_code: | ||
| continue | ||
| new_line = pattern.sub(r'\\{\1\\}', line) | ||
| if new_line != line: | ||
| lines[index] = new_line | ||
| changed = True | ||
| if changed: | ||
| text = '\n'.join(lines) + '\n' | ||
| else: | ||
| text = '\n'.join(lines) + '\n' | ||
|
|
||
| def replace_links(match): | ||
| target = match.group(2) | ||
| if target.endswith('.md'): | ||
| target = target[:-3] | ||
| return f'](/api/{slug}/{target})' | ||
|
|
||
| new_text = link_pattern.sub(replace_links, text) | ||
| duplicate_namespace_pattern = re.compile(rf'/api/{slug}/([^/]+)/\1(?![A-Za-z0-9_])') | ||
| new_text = duplicate_namespace_pattern.sub(rf'/api/{slug}/\1', new_text) | ||
| if new_text != text: | ||
| text = new_text | ||
|
|
||
| md_path.write_text(text, encoding='utf-8') | ||
| PY | ||
| } | ||
|
|
||
| # Build current checkout (development) | ||
| build_docfx_for_checkout "$ROOT" "main" | ||
| rm -rf "$ROOT/docs/_site" | ||
|
|
||
| # Discover release branches | ||
| RELEASE_VERSIONS=() | ||
| SKIP_FETCH="${SKIP_RELEASE_FETCH:-0}" | ||
| MIN_RELEASE_VERSION="${MIN_DOCFX_RELEASE:-v2.14}" | ||
|
|
||
| should_build_release() { | ||
| local version="$1" | ||
| local min="$MIN_RELEASE_VERSION" | ||
| if [[ -z "$min" ]]; then | ||
| return 0 | ||
| fi | ||
|
|
||
| local current="${version#v}" | ||
| local required="${min#v}" | ||
| local smallest | ||
| smallest="$(printf '%s\n%s\n' "$current" "$required" | sort -V | head -n1)" | ||
| if [[ "$smallest" == "$required" ]]; then | ||
| return 0 | ||
| fi | ||
| return 1 | ||
| } | ||
|
|
||
| if [ "$SKIP_FETCH" != "1" ]; then | ||
| RELEASE_TMP="$(mktemp)" | ||
| if git ls-remote --heads origin 'rel/v*' >"$RELEASE_TMP"; then | ||
| if [ -s "$RELEASE_TMP" ]; then | ||
| git fetch --no-tags origin 'refs/heads/rel/*:refs/remotes/origin/rel/*' | ||
| mapfile -t RELEASE_VERSIONS < <(git for-each-ref --format='%(refname:short)' refs/remotes/origin/rel | sed 's#^origin/rel/##' | sort -rV) | ||
| fi | ||
| else | ||
| echo "Warning: unable to query release branches; continuing with development API only." | ||
| fi | ||
| rm -f "$RELEASE_TMP" | ||
| else | ||
| echo "Skipping release branch builds per SKIP_RELEASE_FETCH=$SKIP_FETCH" | ||
| fi | ||
|
|
||
| LATEST_RELEASE="" | ||
| BUILT_RELEASES=() | ||
|
|
||
| for version in "${RELEASE_VERSIONS[@]}"; do | ||
| [ -n "$version" ] || continue | ||
| if ! should_build_release "$version"; then | ||
| echo "Skipping $version: older than minimum DocFX release $MIN_RELEASE_VERSION" | ||
| continue | ||
| fi | ||
|
|
||
| branch="origin/rel/$version" | ||
| worktree="$WORKTREE_ROOT/$version" | ||
| git worktree add --force "$worktree" "$branch" | ||
| WORKTREES_TO_REMOVE+=("$worktree") | ||
|
|
||
| if [ ! -f "$worktree/docs/docfx.json" ]; then | ||
| echo "Skipping $version: no DocFX configuration found" | ||
| git worktree remove --force "$worktree" | ||
| unset 'WORKTREES_TO_REMOVE[-1]' | ||
| continue | ||
| fi | ||
|
|
||
| if build_docfx_for_checkout "$worktree" "$version"; then | ||
| BUILT_RELEASES+=("$version") | ||
| if [ -z "$LATEST_RELEASE" ]; then | ||
| LATEST_RELEASE="$version" | ||
| fi | ||
| else | ||
| echo "Failed to build documentation for $version, skipping" | ||
| fi | ||
|
|
||
| git worktree remove --force "$worktree" || true | ||
| unset 'WORKTREES_TO_REMOVE[-1]' | ||
| done | ||
|
|
||
| rm -rf "$STATIC_API_DIR" | ||
| mkdir -p "$STATIC_API_DIR" | ||
|
|
||
| cp -a "$ARTIFACT_DIR/main/." "$STATIC_API_DIR/main/" | ||
|
|
||
| for version in "${BUILT_RELEASES[@]}"; do | ||
| mkdir -p "$STATIC_API_DIR/$version" | ||
| cp -a "$ARTIFACT_DIR/$version/." "$STATIC_API_DIR/$version/" | ||
| done | ||
|
|
||
| generate_markdown_for_version "main" "dev" "Latest dev (main)" | ||
| for version in "${BUILT_RELEASES[@]}"; do | ||
| generate_markdown_for_version "$version" "$version" "$version" | ||
| done | ||
|
|
||
| if [ -n "$LATEST_RELEASE" ]; then | ||
| DEFAULT_RELEASE="$LATEST_RELEASE" | ||
| DEFAULT_SLUG="$LATEST_RELEASE" | ||
| else | ||
| DEFAULT_RELEASE="main" | ||
| DEFAULT_SLUG="dev" | ||
| fi | ||
|
|
||
| if [ "${#BUILT_RELEASES[@]}" -gt 0 ]; then | ||
| release_objects="[" | ||
| for version in "${BUILT_RELEASES[@]}"; do | ||
| release_objects+="{\"label\":\"$version\",\"slug\":\"$version\"}," | ||
| done | ||
| release_objects="${release_objects%,}]" | ||
| else | ||
| release_objects="[]" | ||
| fi | ||
|
|
||
| cat >"$API_VERSIONS_FILE" <<MANIFEST | ||
| { | ||
| "latest": "$DEFAULT_RELEASE", | ||
| "releases": $release_objects, | ||
| "development": { | ||
| "label": "Latest dev (main)", | ||
| "slug": "dev" | ||
| }, | ||
| "defaultSlug": "$DEFAULT_SLUG" | ||
| } | ||
| MANIFEST | ||
|
|
||
| cp "$API_VERSIONS_FILE" "$STATIC_API_DIR/versions.json" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /cache |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.