Skip to content

Commit dfcb2e1

Browse files
committed
feat: Introduce a unified CLI, refactor documentation generation into a dedicated package, and add a CI workflow for automated documentation builds.
1 parent d23bc93 commit dfcb2e1

File tree

8 files changed

+1021
-2427
lines changed

8 files changed

+1021
-2427
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Generate SDK Reference Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'praisonai_tools/docs_generator/**'
9+
repository_dispatch:
10+
types: [trigger-docs-generation]
11+
workflow_dispatch:
12+
13+
jobs:
14+
generate-docs:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout PraisonAI Tools
18+
uses: actions/checkout@v4
19+
with:
20+
path: praisonai-tools
21+
22+
- name: Checkout PraisonAI Source Repo
23+
uses: actions/checkout@v4
24+
with:
25+
repository: MervinPraison/PraisonAI
26+
path: praisonai-source
27+
28+
- name: Checkout PraisonAI Docs
29+
uses: actions/checkout@v4
30+
with:
31+
repository: MervinPraison/PraisonAIDocs
32+
path: praisonai-docs
33+
token: ${{ secrets.DOCS_GITHUB_TOKEN }}
34+
35+
- name: Set up Python
36+
uses: actions/setup-python@v5
37+
with:
38+
python-version: '3.11'
39+
40+
- name: Install PraisonAI Tools
41+
run: |
42+
cd praisonai-tools
43+
pip install -e .
44+
45+
- name: Run Docs Generation
46+
run: |
47+
# Use the new unified CLI
48+
praisonai-tools docs-generate \
49+
--package all \
50+
--docs-root $(pwd)/praisonai-docs \
51+
--source-root $(pwd)/praisonai-source
52+
env:
53+
PYTHONPATH: $(pwd)/praisonai-tools
54+
55+
- name: Commit and Push Docs
56+
run: |
57+
cd praisonai-docs
58+
git config --global user.name "github-actions[bot]"
59+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
60+
git add .
61+
if git diff --staged --quiet; then
62+
echo "No changes to commit"
63+
else
64+
git commit -m "docs: auto-generate SDK reference documentation"
65+
git push
66+
fi

praisonai_tools/cli.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
"""
2+
Unified CLI for PraisonAI Tools.
3+
"""
4+
5+
import argparse
6+
import sys
7+
from importlib import import_module
8+
9+
def main():
10+
if len(sys.argv) < 2:
11+
print("PraisonAI Developer Tools CLI")
12+
print("\nUsage: praisonai-tools [tool] [args]")
13+
print("\nAvailable tools:")
14+
print(" docs-generate Generate SDK reference documentation")
15+
print(" video AI-powered video editing tools")
16+
print(" fcp Final Cut Pro automation tools")
17+
return 1
18+
19+
tool = sys.argv[1]
20+
tool_args = sys.argv[2:]
21+
22+
if tool == "docs-generate":
23+
# Handle docs-generate with its own parser for better help
24+
parser = argparse.ArgumentParser(prog="praisonai-tools docs-generate")
25+
parser.add_argument("--package", choices=["praisonaiagents", "praisonai", "typescript", "all"],
26+
default="all", help="Package to generate docs for")
27+
parser.add_argument("--dry-run", action="store_true", help="Don't write files")
28+
parser.add_argument("--docs-root", default="/Users/praison/PraisonAIDocs",
29+
help="Root directory of the documentation repository")
30+
parser.add_argument("--source-root", help="Root directory of the source code")
31+
32+
args = parser.parse_args(tool_args)
33+
from .docs_generator.generator import ReferenceDocsGenerator
34+
generator = ReferenceDocsGenerator(docs_root=args.docs_root, source_root=args.source_root)
35+
36+
if args.package == "all":
37+
generator.generate_all(dry_run=args.dry_run)
38+
else:
39+
generator.generate_package(args.package, dry_run=args.dry_run)
40+
return 0
41+
42+
elif tool == "video":
43+
try:
44+
video_main = import_module(".video.__main__", package="praisonai_tools").main
45+
sys.argv = [f"{sys.argv[0]} video"] + tool_args
46+
return video_main()
47+
except ImportError as e:
48+
print(f"Error: Video tool not available. {e}")
49+
return 1
50+
51+
elif tool == "fcp":
52+
try:
53+
fcp_main = import_module(".fcp_tool.cli", package="praisonai_tools").main
54+
return fcp_main(tool_args)
55+
except ImportError as e:
56+
print(f"Error: FCP tool not available. {e}")
57+
return 1
58+
else:
59+
print(f"Unknown tool: {tool}")
60+
return 1
61+
62+
63+
if __name__ == "__main__":
64+
sys.exit(main())

praisonai_tools/docs_generator/__init__.py

Whitespace-only changes.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
CLI entry point for praisonai_tools.docs_generator.
3+
"""
4+
5+
import argparse
6+
import sys
7+
from .generator import ReferenceDocsGenerator
8+
9+
def main():
10+
parser = argparse.ArgumentParser(description="PraisonAI SDK Documentation Generator")
11+
parser.add_argument("--package", choices=["praisonaiagents", "praisonai", "typescript", "all"],
12+
default="all", help="Package to generate docs for")
13+
parser.add_argument("--dry-run", action="store_true", help="Don't write files")
14+
parser.add_argument("--docs-root", default="/Users/praison/PraisonAIDocs",
15+
help="Root directory of the documentation repository")
16+
17+
args = parser.parse_args()
18+
19+
generator = ReferenceDocsGenerator(docs_root=args.docs_root)
20+
21+
if args.package == "all":
22+
generator.generate_all(dry_run=args.dry_run)
23+
else:
24+
generator.generate_package(args.package, dry_run=args.dry_run)
25+
26+
return 0
27+
28+
if __name__ == "__main__":
29+
sys.exit(main())

0 commit comments

Comments
 (0)