-
Notifications
You must be signed in to change notification settings - Fork 25
feat: api reference docs pipeline #30
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
99b1d40
feat: add pydoc-markdown configuration for documentation generation
twangodev a986a4e
feat: add GitHub Actions workflow for automatic API documentation upd…
twangodev d8809e1
feat: update GitHub Actions workflow to remove main branch trigger (t…
twangodev ee21162
feat: remove sign-commits option from API documentation update workflow
twangodev 2b44d60
feat: remove legacy SDK references from documentation and configuration
twangodev 353c64c
feat: add script to copy generated documentation files to the docs re…
twangodev cd306a0
feat: migrate doc script to new docs structure
twangodev 2826c4a
fix: ensure newline at end of file in copy_docs.py
twangodev 04f64f9
feat: simplify job name in docs.yml for clarity
twangodev ddf3799
feat: restore main branch trigger to workflow in docs.yml
twangodev 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
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,59 @@ | ||
| name: Documentation | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| update-docs: | ||
| name: Generate Docs | ||
| runs-on: ubuntu-latest | ||
| environment: docs | ||
| steps: | ||
| - name: Checkout fish-audio-python | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| path: sdk | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v4 | ||
|
|
||
| - name: Install dependencies | ||
| working-directory: sdk | ||
| run: uv sync | ||
|
|
||
| - name: Generate API documentation | ||
| working-directory: sdk | ||
| run: uv run pydoc-markdown | ||
|
|
||
| - name: Checkout docs | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| repository: ${{ vars.DOCS_REPO }} | ||
| path: docs | ||
|
|
||
| - name: Copy generated documentation | ||
| run: uv run python sdk/scripts/copy_docs.py sdk docs | ||
|
|
||
| - name: Create Pull Request | ||
| uses: peter-evans/create-pull-request@v6 | ||
| with: | ||
| token: ${{ secrets.DOCS_TOKEN }} | ||
| path: docs | ||
| commit-message: | | ||
| chore: update Python SDK API reference | ||
|
|
||
| Auto-generated from fishaudio/fish-audio-python@${{ github.sha }} | ||
| branch: auto/python-api-docs | ||
| delete-branch: true | ||
| title: "Update Python SDK API Reference" | ||
| body: | | ||
| Auto-generated API documentation update from [fish-audio-python@${{ github.sha }}](https://github.com/fishaudio/fish-audio-python/commit/${{ github.sha }}) | ||
|
|
||
| ## Changes | ||
| - Updated API reference documentation for Python SDK | ||
| - Generated from latest docstrings in the codebase | ||
|
|
||
| labels: | | ||
| python | ||
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,183 @@ | ||
| #!/usr/bin/env python3 | ||
| """ | ||
| Script to copy generated documentation files to the docs repository. | ||
|
|
||
| Usage: | ||
| python scripts/copy_docs.py <sdk_root> <docs_root> | ||
|
|
||
| Example: | ||
| python scripts/copy_docs.py . ../docs | ||
| python scripts/copy_docs.py sdk docs # In CI context | ||
| """ | ||
|
|
||
| import argparse | ||
| import shutil | ||
| from pathlib import Path | ||
| from typing import Callable | ||
|
|
||
|
|
||
| def add_frontmatter(content: str, title: str, description: str, icon: str) -> str: | ||
| """ | ||
| Add Mintlify frontmatter to markdown content. | ||
|
|
||
| Args: | ||
| content: Original markdown content | ||
| title: Page title | ||
| description: Page description | ||
| icon: Icon name | ||
|
|
||
| Returns: | ||
| Content with frontmatter prepended | ||
| """ | ||
| frontmatter = f"""--- | ||
| title: "{title}" | ||
| description: "{description}" | ||
| icon: "{icon}" | ||
| --- | ||
|
|
||
| """ | ||
| return frontmatter + content | ||
|
|
||
|
|
||
| def copy_file_with_extension_change( | ||
| source: Path, dest_dir: Path, new_extension: str = ".mdx" | ||
| ) -> None: | ||
| """ | ||
| Copy a single file to destination directory with extension change. | ||
|
|
||
| Args: | ||
| source: Source file path | ||
| dest_dir: Destination directory | ||
| new_extension: New file extension (default: .mdx) | ||
| """ | ||
| if not source.exists(): | ||
| print(f"Warning: {source} does not exist") | ||
| return | ||
|
|
||
| dest = dest_dir / source.with_suffix(new_extension).name | ||
| shutil.copy2(source, dest) | ||
| print(f" ✓ {source.name} -> {dest.name}") | ||
|
|
||
|
|
||
| def copy_files_from_directory( | ||
| source_dir: Path, dest_dir: Path, pattern: str = "*.md", new_extension: str = ".mdx" | ||
| ) -> None: | ||
| """ | ||
| Copy all files matching pattern from source directory to destination with extension change. | ||
|
|
||
| Args: | ||
| source_dir: Source directory | ||
| dest_dir: Destination directory | ||
| pattern: File pattern to match (default: *.md) | ||
| new_extension: New file extension (default: .mdx) | ||
| """ | ||
| if not source_dir.exists(): | ||
| print(f"Warning: {source_dir} does not exist") | ||
| return | ||
|
|
||
| print(f"Copying files from {source_dir} to {dest_dir}") | ||
| for file in source_dir.glob(pattern): | ||
| dest = dest_dir / file.with_suffix(new_extension).name | ||
| shutil.copy2(file, dest) | ||
| print(f" ✓ {file.name} -> {dest.name}") | ||
|
|
||
|
|
||
| def copy_file_with_transformation( | ||
| source: Path, | ||
| dest_dir: Path, | ||
| transform_fn: Callable[[str], str], | ||
| new_extension: str = ".mdx", | ||
| dest_filename: str | None = None, | ||
twangodev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) -> None: | ||
| """ | ||
| Copy a file with content transformation. | ||
|
|
||
| Args: | ||
| source: Source file path | ||
| dest_dir: Destination directory | ||
| transform_fn: Function to transform file content | ||
| new_extension: New file extension (default: .mdx) | ||
| dest_filename: Optional custom destination filename (without extension) | ||
| """ | ||
| if not source.exists(): | ||
| print(f"Warning: {source} does not exist") | ||
| return | ||
|
|
||
| if dest_filename: | ||
| dest = dest_dir / f"{dest_filename}{new_extension}" | ||
| else: | ||
| dest = dest_dir / source.with_suffix(new_extension).name | ||
|
|
||
| content = source.read_text(encoding="utf-8") | ||
| transformed_content = transform_fn(content) | ||
| dest.write_text(transformed_content, encoding="utf-8") | ||
| print(f" ✓ {source.name} -> {dest.name} (transformed)") | ||
|
|
||
|
|
||
| def copy_docs(sdk_root: Path, docs_root: Path) -> None: | ||
| """ | ||
| Copy generated documentation files to the docs repository. | ||
|
|
||
| Args: | ||
| sdk_root: Root directory of the fish-audio-python SDK | ||
| docs_root: Root directory of the docs repository | ||
| """ | ||
| # Source paths | ||
| build_dir = sdk_root / "build" / "docs" / "content" | ||
| fishaudio_dir = build_dir / "fishaudio" | ||
| index_file = build_dir / "index.md" | ||
|
|
||
| # Destination path (flat structure - all files go to the same directory) | ||
| python_sdk_dir = docs_root / "api-reference" / "sdk" / "python" | ||
|
|
||
| # Create destination directory | ||
| python_sdk_dir.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| # Copy fishaudio module reference files | ||
| copy_files_from_directory(fishaudio_dir, python_sdk_dir) | ||
|
|
||
| # Copy index.md to python directory as overview.mdx with frontmatter | ||
| copy_file_with_transformation( | ||
| index_file, | ||
| python_sdk_dir, | ||
| lambda content: add_frontmatter( | ||
| content, | ||
| title="Python SDK", | ||
| description="Fish Audio Python SDK for text-to-speech and voice cloning", | ||
| icon="python", | ||
| ), | ||
| dest_filename="overview", | ||
| ) | ||
|
|
||
| print("\nDocumentation copy completed successfully!") | ||
|
|
||
|
|
||
| def main() -> None: | ||
| parser = argparse.ArgumentParser( | ||
| description="Copy generated documentation files to the docs repository" | ||
| ) | ||
| parser.add_argument( | ||
| "sdk_root", | ||
| type=Path, | ||
| help="Root directory of the fish-audio-python SDK", | ||
| ) | ||
| parser.add_argument( | ||
| "docs_root", | ||
| type=Path, | ||
| help="Root directory of the docs repository", | ||
| ) | ||
|
|
||
| args = parser.parse_args() | ||
|
|
||
| # Validate paths | ||
| if not args.sdk_root.exists(): | ||
| parser.error(f"SDK root directory does not exist: {args.sdk_root}") | ||
|
|
||
| if not args.docs_root.exists(): | ||
| parser.error(f"Docs root directory does not exist: {args.docs_root}") | ||
|
|
||
| copy_docs(args.sdk_root, args.docs_root) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
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.