shelldocs init
shelldocs init is the "get to running docs" command. Two modes: create (default) makes a fresh Blazor Web App under docs/<Name>.Docs/ and wires everything for you, attach (--attach) augments an existing Blazor project in place without touching its Program.cs.
Synopsis
shelldocs init [path] [--dir <dir>] [--attach] [--yes] [--theme <preset>]
Create mode (default)
Scaffolds a fresh Blazor Web App and patches the template to be a working ShellDocs site : one command from empty directory to a running docs project.
shelldocs init MyDocs
Produces MyDocs/ in the current directory (or, when called with no path, docs/<CwdName>.Docs/).
"> Scaffolds a fresh Blazor Web App using the standard template. Fails fast if the target directory exists and isn't empty : use--attach` instead of overwriting.- Adds package references
Injects
<PackageReference Include="ShellDocs.Components" />and<PackageReference Include="ShellDocs.Tokens" />into the freshly-created.csproj. Both pinned to the CLI's shipped version. - Adds content copy-to-output
Inserts a
<Content Update="content/**/*.md;content/**/meta.json" CopyToOutputDirectory="PreserveNewest" />group sodotnet publishcarries the markdown corpus into the publish output. - Writes starter content
Creates
content/docs/introduction.mdandcontent/docs/meta.json: the minimum a ShellDocs site needs to render. - Writes `Components/Pages/DocsPage.razor`
The single-page router that serves every
/docs/**URL from the.mdfiles undercontent/. You don't edit this : it's just a<DocsLayout>around a<MarkdownContent>. - Strips the fresh-template chrome
Deletes
Counter.razor,Weather.razor,NavMenu.razor,MainLayout.razor.css,Home.razor.css. RewritesMainLayout.razoras a bare pass-through and replacesHome.razorwith the ShellDocs welcome page. - Patches `Program.cs`
Adds
using ShellDocs.Components;,builder.WebHost.UseStaticWebAssets();, andbuilder.Services.AddShellDocs(...): anchoring on the exact template shape produced bydotnet new blazor. - Patches `Components/App.razor`
Adds the
_content/ShellDocs.Tokens/tokens.cssand component CSS links, the theme-bootstrap script, andshelldocs.js+ Shiki loader. Also switches<Routes />to<Routes @rendermode="InteractiveServer" />so interactive components (theme toggle, search, tabs) come alive. - Registers with the nearest solution
Walks up from the working directory looking for a
.slnxor.sln(stops at the repo root or 6 levels up). If one is found and doesn't already reference the project, runsdotnet sln add.
Re-running shelldocs init on the same directory won't clobber your edits : every step checks for the target artifact and skips if it's already present.
Path inference
When called with no path argument, the target is docs/<CwdName>.Docs/. So running from ~/code/my-library/ produces ~/code/my-library/docs/my-library.Docs/.
Site name
The header brand is derived from the target directory name, stripping a trailing .Docs suffix. my-library.Docs → header shows "my-library".
GitHub prompt
Interactive mode asks for owner/repo (blank to skip). The answer wires the GitHub link in the header and is used by search / social meta. Pass --yes to skip the prompt.
Attach mode (--attach)
Augments an existing Blazor project in place. Never touches your Program.cs : instead emits SHELLDOCS_SETUP.md with copy-paste snippets so you can wire ShellDocs into your custom middleware, auth, or DI without a merge conflict.
shelldocs init --attach --dir path/to/my/blazor/project
- Verifies the target is a Blazor project
Checks the
.csprojforMicrosoft.NET.Sdk.Web,.Razor,.BlazorWebAssembly, or aMicrosoft.AspNetCore.Componentsreference. Bails if none match. - Adds package references
Same as create mode.
- Writes starter content
Same as create mode.
- Writes DocsPage.razor
Same as create mode.
- Writes SHELLDOCS_SETUP.md
A per-project setup guide with copy-paste snippets for the exact
AddShellDocs,MapShellDocs, andApp.razoradditions your project needs. This is what create mode does automatically : attach mode leaves it to you.
Options
| Prop | Type | Default | Description |
|---|---|---|---|
--dir |
string |
cwd |
Working directory. With `--attach`, the project directory to augment. |
--attach |
bool |
false |
Attach mode : augment an existing Blazor project instead of creating one. |
--yes |
bool |
false |
Non-interactive : skip the GitHub-repo prompt, take defaults everywhere. |
--theme |
string |
— | Theme preset : `shadcn`, `fuma`, `nextra`. Currently informational : all presets ship the same token file (see [theming](/docs/theming)). |
Exit codes
| Prop | Type | Default | Description |
|---|---|---|---|
0 |
ok |
— | Scaffolding completed (create) or attach patches wrote. |
1 |
usage |
— | Target directory exists and isn't empty (create), or target is not a Blazor project (attach), or missing/invalid arguments. |
other |
pass-through |
— | `dotnet new blazor` exit code propagated (create mode). |