Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
84 changes: 45 additions & 39 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,45 @@
name: Build and Deploy Documentation

on:
push:
branches: [ master ]
paths:
- 'Documentation/**'
- 'Harmony/**'
- 'Lib.Harmony/**'
- '.github/workflows/docs.yml'

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x

- name: Install DocFX
run: dotnet tool install -g docfx

- name: Build Library
run: dotnet build -c Debug -f net35 .\Lib.Harmony\Lib.Harmony.csproj

- name: Build Documentation
run: docfx Documentation/docfx.json

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/master'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
force_orphan: true
name: Build and Deploy Documentation

on:
push:
branches: [ master ]
paths:
- 'Documentation/**'
- 'Harmony/**'
- 'scripts/generate_llm_pack.py'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Restore docs workflow trigger for Lib.Harmony changes

The docs workflow no longer runs when files under Lib.Harmony/ change. The previous configuration explicitly listed that folder, but the new path filter only covers Harmony/** plus the new generator script. API metadata is produced from Lib.Harmony/bin/Debug/net35/0Harmony.dll, so any API changes applied solely in Lib.Harmony will now bypass the workflow and leave both the documentation and the llm-pack stale. Consider reintroducing Lib.Harmony/** to the trigger list.

Useful? React with 👍 / 👎.

- '.github/workflows/docs.yml'

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x

- name: Install DocFX
run: dotnet tool install -g docfx

- name: Build Library
run: dotnet build -c Debug -f net35 .\Lib.Harmony\Lib.Harmony.csproj

- name: Build Documentation
run: docfx Documentation/docfx.json

- name: Install Python dependencies
run: pip install pyyaml

- name: Generate LLM Pack
run: python scripts/generate_llm_pack.py

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/master'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
force_orphan: true
Expand Down
62 changes: 62 additions & 0 deletions scripts/generate_llm_pack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python3
from pathlib import Path
import json

import yaml

OUT_DIR = Path('docs', 'llm-pack')
OUT_DIR.mkdir(parents=True, exist_ok=True)
OUT_FILE = OUT_DIR / 'harmony.cards.jsonl'

cards = []

# API
for path in Path('Documentation/api').rglob('*.yml'):
with path.open(encoding='utf-8') as f:
data = yaml.safe_load(f)
for item in data.get('items', []):
uid = item.get('uid')
kind = (item.get('type') or '').lower()
if not uid or not kind:
continue
summary = item.get('summary')
signature = item.get('syntax', {}).get('content')
remarks = item.get('remarks')
parent = item.get('parent')
doc_page = uid if not parent or parent == 'HarmonyLib' else parent
doc_url = f'https://harmony.pardeike.net/docs/api/{doc_page}.html'
cards.append({
Comment on lines +13 to +32

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Generated API URLs break for generic types

The LLM pack builds API URLs by concatenating the raw uid with .html. DocFX does not emit HTML files with the raw UID for generic or overloaded types (e.g. HarmonyLib.AccessTools.FieldRef<T> becomes HarmonyLib.AccessTools.FieldRef-1.html). For any API element whose UID contains characters like < and >, the resulting doc_url will point to a non-existent page, yielding unusable entries in the JSONL index. Using the href field provided in the YAML or applying the same sanitization as DocFX would keep the links valid.

Useful? React with 👍 / 👎.

'id': uid,
'kind': kind,
'summary': summary,
'signature': signature,
'remarks': remarks,
'doc_url': doc_url,
'examples': None
})

# Articles
for path in Path('Documentation/articles').rglob('*.md'):
with path.open(encoding='utf-8') as f:
lines = [line.strip() for line in f]
lines = [l for l in lines if l]
if not lines:
continue
summary = lines[0]
remarks = '\n'.join(lines[1:5]) if len(lines) > 1 else None
rel = path.relative_to('Documentation')
slug = rel.with_suffix('').as_posix()
doc_url = f'https://harmony.pardeike.net/docs/{slug}.html'
cards.append({
'id': slug,
'kind': 'article',
'summary': summary,
'signature': None,
'remarks': remarks,
'doc_url': doc_url,
'examples': None
})

with OUT_FILE.open('w', encoding='utf-8') as out:
for card in cards:
out.write(json.dumps(card, ensure_ascii=False) + '\n')