Skip to content
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
29 changes: 27 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
paths:
- 'Documentation/**'
- 'Harmony/**'
- 'Lib.Harmony/**'
- 'scripts/generate_llm_pack.py'
- '.github/workflows/docs.yml'

jobs:
Expand All @@ -30,10 +30,35 @@ jobs:
- 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
force_orphan: true
- 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
66 changes: 66 additions & 0 deletions scripts/generate_llm_pack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/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')
href = item.get('href')
if href:
doc_url = f'https://harmony.pardeike.net/docs/{href.lstrip("/")}'
else:
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({
'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')
Loading