fix(sidebar,preview,scaffold,options): pin footer everywhere, visible razor:preview error, namespacePrefix overload, LayoutVariant hintFix/sidebar footer and dogfood batch - #23
Merged
Conversation
…ation; improve error handling in PreviewFrame and add error styling
… for unknown components in PreviewSlot
… component registration for improved clarity
…oter fixes, error handling improvements in PreviewSlot, and new component registration options
There was a problem hiding this comment.
Pull request overview
This PR is a dogfood-driven batch that improves ShellDocs’ layout behavior (sidebar footer pinning across variants) and improves authoring feedback by making razor:preview failures visible in the rendered preview frame, while also adding a convenience ShellDocsOptions overload and updating scaffolding/version metadata.
Changes:
- Make sidebar slot/nav flex behavior consistent so the sidebar footer pins to the bottom across TopNav, Sidebar variant, mobile drawer, and short-tree cases.
- Change
razor:previewhandling so unknown components produce an inline error panel (via nullablePreviewSlot.ComponentType+PreviewSlot.Error) instead of silently falling back to a plain code block. - Add
RegisterComponentsFromAssembly<TMarker>(string namespacePrefix)(andAssemblyequivalent), updateshelldocs initscaffold hints, and bump version + changelog.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ShellDocs.Templates/ScaffoldTemplates.cs | Updates scaffolded Program.cs comments to surface layout variant and component registration hints. |
| src/ShellDocs.Markdown/SlotExtractor.cs | Emits an error PreviewSlot (nullable type + message) when preview tag is unknown. |
| src/ShellDocs.Markdown/RenderedDocument.cs | Extends PreviewSlot to allow ComponentType to be null and adds an Error field. |
| src/ShellDocs.Components/ShellDocsOptions.cs | Adds namespace-prefix overloads for assembly component registration. |
| src/ShellDocs.Components/Layouts/DocsLayout.razor.css | Makes .docs-sidebar-slot a flex column in all contexts; refactors sidebar-variant overrides accordingly. |
| src/ShellDocs.Components/Content/PreviewFrame.razor.css | Adds styling for the inline preview error panel. |
| src/ShellDocs.Components/Content/PreviewFrame.razor | Renders either the component or an inline error panel when ComponentType is null. |
| src/ShellDocs.Components/Chrome/DocsSidebar.razor.css | Moves flex sizing responsibilities to .docs-sidebar to keep footer pinned across contexts. |
| Directory.Build.props | Bumps package version to 0.1.4-alpha. |
| CHANGELOG.md | Adds 0.1.4-alpha entry describing the fixes/additions. |
Suppressed comments (1)
src/ShellDocs.Components/ShellDocsOptions.cs:80
namespacePrefixvalidation should reject whitespace-only values too (consistent withRegisterComponent<T>(string tagName)usingIsNullOrWhiteSpace).
public ShellDocsOptions RegisterComponentsFromAssembly<TMarker>(string namespacePrefix)
{
if (string.IsNullOrEmpty(namespacePrefix))
throw new ArgumentException("namespacePrefix must be non-empty.", nameof(namespacePrefix));
return RegisterComponentsFromAssembly(typeof(TMarker).Assembly,
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| fence to render as a plain code block — silent failure that sent | ||
| authors hunting for a nonexistent component bug (dogfood log, | ||
| SHELLDOCS_FIXES.md #4). Warning still emitted for build logs. */ | ||
| var msg = $"Unknown component <{name}>. Register it via `o.RegisterComponent<{name}>()` or `o.RegisterComponentsFromAssembly<TMarker>()`."; |
Comment on lines
+18
to
+22
| - **`RegisterComponentsFromAssembly<TMarker>(string namespacePrefix)` overload.** Registering only components under a specific namespace from a big assembly no longer needs a `Func<Type, bool>` — the common "register everything under my Components namespace" case reads as: | ||
| ```csharp | ||
| o.RegisterComponentsFromAssembly<Marker>("ShellIcons.Icons"); | ||
| ``` | ||
| instead of the lambda form. The `Func` overload stays for anything more complex. |
Comment on lines
72
to
+76
| public ShellDocsOptions RegisterComponentsFromAssembly<TMarker>(Func<Type, bool>? filter = null) | ||
| => RegisterComponentsFromAssembly(typeof(TMarker).Assembly, filter); | ||
|
|
||
|
|
||
| public ShellDocsOptions RegisterComponentsFromAssembly<TMarker>(string namespacePrefix) |
…t and warning for unregistered tags
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Second dogfood-driven batch.
0.1.3-alphapinned the sidebar footer under the desktop Sidebar variant only — footer still floated mid-sidebar on TopNav, mobile drawer, and short-tree Sidebar-variant cases. This batch fixes that plus four items surfaced by SHELLDOCS_FIXES.md while a consumer (shellicons-docs) was set up against0.1.3-alpha.Bumps
Directory.Build.propsto0.1.4-alphaand adds a matching CHANGELOG entry. Post-merge tagv0.1.4-alphafires the release workflow.What's in
Fixed
flex: 1; min-height: 0onto.docs-sidebaritself (was scoped inside@media (min-width: 1024px)+.docs-shell-sidebarin0.1.3-alpha) and lifteddisplay: flex; flex-direction: columnonto the base.docs-sidebar-slotrule (was only in the desktop Sidebar-variant block). Footer sits hard against the bottom regardless of variant / viewport / item count.razor:previewfences with an unknown outer tag now render a visible error inline instead of falling through to a plain code block silently.SlotExtractor.TryBuildPreviewSlotpreviously returnednullon an unregistered tag; the fence rendered as regular fenced code with only a build-log warning, sending authors hunting for a nonexistent component bug. It now emits aPreviewSlotwithComponentType = null+ anErrormessage, andPreviewFramerenders a red-tinted error panel in the render region naming the unknown tag and pointing ato.RegisterComponent<T>()/o.RegisterComponentsFromAssembly<TMarker>().Added
RegisterComponentsFromAssembly<TMarker>(string namespacePrefix)overload onShellDocsOptions. Common "register everything under my Components namespace" case reads aso.RegisterComponentsFromAssembly<Marker>("ShellIcons.Icons")instead of theFunc<Type, bool>form. Lambda overload stays.shelldocs initscaffoldedProgram.csnow surfaces theLayoutVariantknob — commented// o.LayoutVariant = DocsLayoutVariant.Sidebar;line right in theAddShellDocs(...)block, plus aRegisterComponentsFromAssemblyhint. First-time consumers don't have to grepShellDocs.Components/Layouts/DocsLayout.razorto discover the sidebar-variant option exists.Files
Modified — 8 source files + 3 metadata:
src/ShellDocs.Components/Chrome/DocsSidebar.razor.csssrc/ShellDocs.Components/Layouts/DocsLayout.razor.csssrc/ShellDocs.Components/Content/PreviewFrame.razor+.razor.csssrc/ShellDocs.Components/ShellDocsOptions.cssrc/ShellDocs.Markdown/RenderedDocument.cssrc/ShellDocs.Markdown/SlotExtractor.cssrc/ShellDocs.Templates/ScaffoldTemplates.csCHANGELOG.md— new[0.1.4-alpha]sectionDirectory.Build.props—0.1.3-alpha→0.1.4-alpha