Skip to content

Commit f65d4bf

Browse files
antonsyndclaude
andcommitted
docs: add MkDocs Material site with stdlib API reference generator
Set up a documentation site using MkDocs Material that combines the language specification, auto-generated stdlib API reference, tooling docs, and the Blazor WASM playground under a single GitHub Pages deployment. - mkdocs.yml with full nav (112 spec pages, 35 stdlib pages, tooling) - docs/index.md landing page - build_tools/generate_stdlib_docs.py: regex-based C# parser that extracts XML doc comments from Sharpy.Core, mangles names to snake_case, maps C# types to Sharpy types, and generates markdown - 35 generated stdlib pages (builtins, 5 core types, 28 modules) - Unified docs.yml workflow replaces playground.yml (builds MkDocs + playground, combines into single site at /sharpy/) - Fix broken links in function_types.md and type_casting.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9c6c3ab commit f65d4bf

43 files changed

Lines changed: 8101 additions & 8 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
name: Deploy Playground
1+
name: Deploy Documentation
22

33
on:
44
push:
55
branches: [ "mainline" ]
66
paths:
7+
- 'docs/**'
8+
- 'mkdocs.yml'
79
- 'src/Sharpy.Playground/**'
810
- 'src/Sharpy.Compiler/**'
911
- 'src/Sharpy.Core/**'
10-
- '.github/workflows/playground.yml'
12+
- '.github/workflows/docs.yml'
1113
workflow_dispatch:
1214

1315
permissions:
@@ -26,6 +28,19 @@ jobs:
2628
steps:
2729
- uses: actions/checkout@v6
2830

31+
# Build MkDocs site
32+
- name: Setup Python
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: '3.12'
36+
37+
- name: Install MkDocs Material
38+
run: pip install mkdocs-material
39+
40+
- name: Build documentation
41+
run: mkdocs build --strict
42+
43+
# Build Blazor WASM playground
2944
- name: Setup .NET
3045
uses: actions/setup-dotnet@v5
3146
with:
@@ -35,15 +50,19 @@ jobs:
3550
run: dotnet workload install wasm-tools
3651

3752
- name: Publish Playground
38-
run: dotnet publish src/Sharpy.Playground/Sharpy.Playground.csproj -c Release -o release
53+
run: dotnet publish src/Sharpy.Playground/Sharpy.Playground.csproj -c Release -o playground-release
54+
55+
- name: Rewrite base href for playground subdirectory
56+
run: sed -i 's|<base href="/" />|<base href="/sharpy/playground/" />|g' playground-release/wwwroot/index.html
3957

40-
- name: Rewrite base href
41-
run: sed -i 's|<base href="/" />|<base href="/sharpy/" />|g' release/wwwroot/index.html
58+
# Combine into single site
59+
- name: Copy playground into docs site
60+
run: cp -r playground-release/wwwroot site/playground
4261

4362
- name: Upload Pages artifact
4463
uses: actions/upload-pages-artifact@v4
4564
with:
46-
path: release/wwwroot
65+
path: site
4766

4867
deploy:
4968
environment:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ editors/vscode/out/
22

33
mcp.json
44

5+
# MkDocs build output
6+
site/
7+
58
node_modules/
69
.serena/
710

build_tools/cli.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
cmd_logs as builder_logs,
5757
)
5858
from build_tools.sharpy_auto_builder.config import Config as BuilderConfig
59+
from build_tools.generate_stdlib_docs import generate as stdlib_generate
5960
except ImportError:
6061
# Fallback to relative imports
6162
from .generate_code_walkthroughs import (
@@ -78,6 +79,7 @@
7879
cmd_logs as builder_logs,
7980
)
8081
from .sharpy_auto_builder.config import Config as BuilderConfig
82+
from .generate_stdlib_docs import generate as stdlib_generate
8183
except ImportError as e:
8284
print(f"Error importing build tools: {e}", file=sys.stderr)
8385
print("Make sure you're running from the Sharpy project root", file=sys.stderr)
@@ -707,6 +709,60 @@ def build_logs(
707709
sys.exit(1)
708710

709711

712+
# ==============================================================================
713+
# Stdlib Documentation Commands
714+
# ==============================================================================
715+
716+
717+
@cli.group()
718+
def stdlib():
719+
"""Generate standard library API documentation."""
720+
pass
721+
722+
723+
@stdlib.command(name="generate")
724+
@click.option(
725+
"--source-dir",
726+
"-s",
727+
type=click.Path(exists=True, path_type=Path),
728+
default="src/Sharpy.Core",
729+
help="Path to Sharpy.Core source directory (default: src/Sharpy.Core)",
730+
)
731+
@click.option(
732+
"--output-dir",
733+
"-o",
734+
type=click.Path(path_type=Path),
735+
default="docs/stdlib",
736+
help="Output directory for generated docs (default: docs/stdlib)",
737+
)
738+
@click.option(
739+
"--force",
740+
"-f",
741+
is_flag=True,
742+
help="Overwrite existing files (default: skip existing)",
743+
)
744+
@click.option(
745+
"--verbose",
746+
"-v",
747+
is_flag=True,
748+
help="Print progress information",
749+
)
750+
def stdlib_gen(source_dir: Path, output_dir: Path, force: bool, verbose: bool):
751+
"""Generate stdlib API reference pages from Sharpy.Core C# source."""
752+
try:
753+
generated = stdlib_generate(
754+
source_dir=source_dir.resolve(),
755+
output_dir=output_dir.resolve(),
756+
force=force,
757+
verbose=verbose,
758+
)
759+
if not verbose:
760+
click.echo(f"Generated {len(generated)} files in {output_dir}")
761+
except Exception as e:
762+
click.echo(f"Error: {e}", err=True)
763+
sys.exit(1)
764+
765+
710766
# ==============================================================================
711767
# Global Status Command
712768
# ==============================================================================

0 commit comments

Comments
 (0)