RazorDocsResolvedVersionCatalog Disabled { get; }
Source
Gets the sentinel catalog result for hosts where versioning is disabled entirely.
Harvester implementation that scans C# source files for XML documentation comments.
Task<IReadOnlyList<DocNode>> HarvestAsync(string rootPath, CancellationToken cancellationToken = default)
Source
Collects XML documentation from C# source files under the specified root and produces DocNode entries containing titles, relative file paths with anchors, and HTML-formatted content.
rootPathThe root directory to recursively scan for .cs files.cancellationTokenAn optional token to observe for cancellation requests.A collection of DocNode objects; each contains a title, a relative file path including a fragment anchor, and the extracted HTML documentation.
Skips files in excluded directories (for example "node_modules", "bin", "obj", "Tests", and "examples") and hidden dot-prefixed directories unless explicitly allowlisted. Dot-prefixed files are included.
string GetMethodId(MethodDeclarationSyntax method, string qualifiedTypeName)
Source
Computes the safe ID for a method to be used in HTML content and stub nodes.
methodThe method declaration syntax.qualifiedTypeNameThe qualified name of the containing type.The safe ID string for the method documentation section.
string GetPropertyId(PropertyDeclarationSyntax property, string qualifiedTypeName)
Source
Computes the safe ID for a property to be used in HTML content and stub nodes.
propertyThe property declaration syntax.qualifiedTypeNameThe qualified name of the containing type.The safe ID string for the property documentation section.
string GetHighlightedDisplaySignature(MethodDeclarationSyntax method)
Source
Generates a syntax-highlighted HTML string representing a method signature for display.
methodThe method declaration syntax.An HTML fragment containing the highlighted signature.
string GetHighlightedPropertySignature(PropertyDeclarationSyntax property)
Source
Generates a syntax-highlighted HTML string representing a property signature for display.
propertyThe property declaration syntax.An HTML fragment containing the highlighted signature.
string GetPropertyAccessorSignature(PropertyDeclarationSyntax property)
Source
Computes the accessors (get/set/init) for a property as a string for inclusion in signatures.
propertyThe property declaration syntax.A string like "{ get; set; }" or "{ get; }".
void AppendHighlightedParameter(StringBuilder builder, ParameterSyntax parameter)
Source
Appends a syntax-highlighted parameter declaration to the provided StringBuilder.
builderThe StringBuilder to append to.parameterThe parameter declaration syntax.string GetDisplayTypeName(TypeDeclarationSyntax typeDecl)
Source
Gets the display name for a type declaration, including generic type parameter placeholders (e.g., <T>).
typeDeclThe type declaration syntax.The display name string.
string GetTypeNameForQualifiedId(TypeDeclarationSyntax typeDecl)
Source
Gets the type name for a qualified ID, appending backtick arity for generic types (e.g., MyType`1).
typeDeclThe type declaration syntax.The type name string used in safe IDs.
bool IsCompilerGeneratedCallerParameter(ParameterSyntax parameter)
Source
Determines whether a parameter is a compiler-generated caller information parameter (e.g., [CallerFilePath]).
parameterThe parameter declaration syntax.true if the parameter should be hidden from documentation; otherwise, false.
string? ExtractDoc(SyntaxNode node)
Source
Extracts XML documentation from the leading trivia of a syntax node and converts it into HTML fragments.
nodeThe syntax node whose leading XML documentation comments will be parsed.The HTML string containing structured documentation sections, or null if no documentation is present or parsing fails.
void AppendTextSection(StringBuilder html, string cssClass, XElement? section, string? heading = null)
Source
Appends a simple text section (like summary or remarks) to the HTML builder.
htmlThe StringBuilder to append to.cssClassThe CSS class name for the section container.sectionThe XElement containing the documentation section.headingOptional heading text for the section.void AppendNamedListSection(StringBuilder html, string cssClass, string heading, IEnumerable<XElement> entries, Func<XElement, string?> keySelector)
Source
Appends a list of named entries (like parameters or exceptions) to the HTML builder.
htmlThe StringBuilder to append to.cssClassThe CSS class name for the section container.headingThe heading text for the section.entriesThe collection of XElements to process.keySelectorA function that extracts the name or key for each entry.string RenderBlockContent(XElement element)
Source
Renders the content of an XElement as block-level HTML (wrapping in paragraphs if necessary).
elementThe XElement to render.An HTML fragment string.
string RenderInlineContent(XElement element)
Source
Renders the content of an XElement as inline HTML.
elementThe XElement to render.An HTML fragment string.
string RenderNodes(IEnumerable<XNode> nodes, bool inlineContext)
Source
Renders a collection of XML nodes into HTML strings.
nodesThe nodes to render.inlineContextIndicates whether rendering occurs in an inline context (affects paragraph handling).The combined HTML string.
string RenderNode(XNode node, bool inlineContext)
Source
Renders a single XML node into its corresponding HTML fragment.
nodeThe node to render.inlineContextIndicates whether rendering occurs in an inline context.The HTML fragment string.
string NormalizeWhitespace(string value)
Source
Normalizes whitespace in the provided string by replacing all whitespace sequences with a single space.
valueThe string to normalize.The normalized string.
void AddOutlineItem(NamespaceDocPage namespacePage, string title, string id, int level)
Source
Adds an outline item to a namespace page when the entry is complete and its target ID has not already been recorded.
namespacePageThe namespace page receiving the outline item.titleThe reader-facing outline title.idThe fragment identifier for the rendered documentation section.levelThe normalized outline level.string? SimplifyCref(string? cref)
Source
Simplifies a "cref" attribute value by removing the type prefix (e.g., "M:", "T:").
crefThe cref value to simplify.The simplified string, or null if the input was empty.
bool IsCompilerGeneratedDocParameter(string? parameterName)
Source
Determines whether a parameter name corresponds to a compiler-generated caller information parameter.
parameterNameThe name of the parameter to check.true if it is a compiler-generated parameter; otherwise, false.
NamespaceDocPage GetOrCreateNamespacePage(IDictionary<string, NamespaceDocPage> namespacePages, string namespaceName)
Source
Gets an existing NamespaceDocPage for the specified namespace name, or creates a new one if it doesn't exist.
namespacePagesThe dictionary of existing pages.namespaceNameThe dotted namespace name.The retrieved or newly created page.
void EnsureNamespaceHierarchy(IDictionary<string, NamespaceDocPage> namespacePages)
Source
Builds the hierarchical structure for namespaces, ensuring parent pages exist and child links are added back into the content. Rebuilds namespacePages in place keyed by NamespaceDocPage.Path.
namespacePagesThe dictionary containing all unique namespace pages encountered during harvesting.string GetNamespaceName(SyntaxNode node)
Source
Extracts the dotted namespace name for a given syntax node by traversing its ancestors.
nodeThe syntax node to process.The full dotted namespace name, or "Global" if none is found.
string BuildNamespaceDocPath(string namespaceName)
Source
Constructs the relative documentation route path for a given namespace name.
namespaceNameThe dotted namespace name.The relative route path string (e.g., "Namespaces/MyNamespace").
string GetNamespaceTitle(string fullNamespace)
Source
Derives a display title for a namespace name.
fullNamespaceThe dotted namespace name.The display title; returns the last segment of the namespace or "Namespaces" for the root.
string GetParentNamespace(string namespaceName)
Source
Gets the parent namespace name for a dotted namespace string.
namespaceNameThe dotted namespace name.The parent namespace name, or an empty string if it is a root namespace.
string GetQualifiedName(BaseTypeDeclarationSyntax node)
Source
Builds the dot-delimited qualified name for a type or enum declaration, including enclosing types and namespaces.
nodeThe type or enum declaration syntax node to compute the qualified name for.The qualified name as a dot-delimited string containing nested type and namespace segments.
Represents a single documentation page for a C# namespace, accumulating content from types within it.
Owns the route identity contract for one cached RazorDocs snapshot.
The catalog deliberately separates source identity from public route identity: source path -> internal lookup and authoring provenance public route path -> browser-facing canonical URL redirect alias -> declared or Markdown source-shaped URL that redirects to public route Controllers render only public canonical winners. Declared aliases and Markdown source-shaped paths for public winners redirect to the canonical route, while non-Markdown source paths, collision losers, and reserved routes stay non-public. Link builders can still resolve source paths so authored Markdown stays source-friendly without rendering source-shaped URLs into the reader-facing surface.
Builds normalized RazorDocs metadata defaults and fallbacks for harvested documentation nodes.
DocMetadata CreateMarkdownMetadata(string path, string resolvedTitle, DocMetadata? explicitMetadata, string? derivedSummary)
Source
Creates normalized metadata for a Markdown documentation node without emitting normalization warnings.
pathThe source path used for default section, page-type, and audience inference.resolvedTitleThe resolved display title for the Markdown node.explicitMetadataOptional authored metadata that should override inferred defaults.derivedSummaryOptional summary text derived from the document body.The merged metadata with inferred defaults, normalized nav-group handling, and fallback breadcrumbs.
DocMetadata CreateMarkdownMetadata(string path, string resolvedTitle, DocMetadata? explicitMetadata, string? derivedSummary, ILogger? logger)
Source
Creates normalized metadata for a Markdown documentation node and optionally logs authored nav-group fallback warnings.
pathThe source path used for default section, page-type, and audience inference.resolvedTitleThe resolved display title for the Markdown node.explicitMetadataOptional authored metadata that should override inferred defaults.derivedSummaryOptional summary text derived from the document body.loggerAn optional logger that receives warnings when authored nav_group values do not resolve to a built-in public section and RazorDocs falls back to the derived section assignment.The merged metadata with normalized section labels, fallback breadcrumbs, and derived-field flags.
This shared internal entry point normalizes explicit public-section selection, preserves authored metadata where valid, derives title/summary fallback semantics, and rebuilds default breadcrumbs when authors do not supply them explicitly.
DocMetadata CreateApiReferenceMetadata(string title, string namespaceName)
Source
Creates canonical metadata for an API-reference documentation node.
titleThe display title for the API node.namespaceNameThe owning namespace used for component inference and breadcrumb generation.Metadata configured for API-reference navigation, contributor visibility, and namespace breadcrumbs.
string? DeriveComponentFromPath(string path)
Source
Derives the owning AppSurface component name from a documentation path when possible.
pathThe documentation path whose segments should be inspected.The inferred component name, or null when no component hint can be derived.
string? DeriveComponentFromNamespace(string namespaceName)
Source
Derives the owning AppSurface component name from a namespace.
namespaceNameThe namespace to inspect.The inferred component name, or null when the namespace is blank.
bool ShouldExcludeFilePath(string filePath)
Source
Determines whether a documentation file should be excluded from harvesting based on its path segments.
filePathThe relative file path to check.true if the file should be excluded; otherwise, false.
bool ShouldExcludeFilePath(string filePath, IReadOnlySet<string> excludedDirectories, bool excludeTestProjectDirectories = false)
Source
Determines whether a file should be excluded based on shared hidden-directory rules and a caller-supplied set of explicitly excluded directory names.
filePathThe relative file path to check.excludedDirectoriesDirectory names that should always be excluded in addition to the shared hidden-directory behavior.excludeTestProjectDirectoriesWhen true, also excludes test-project directory segments by case-insensitive exact names (Test, Tests, UnitTests, IntegrationTests, FunctionalTests, E2ETests) and case-insensitive suffix patterns (*.Tests, *.UnitTests, *.IntegrationTests, *.FunctionalTests, *.E2ETests, *-Tests, and *_Tests).true if the file should be excluded; otherwise, false.
Represents the authored Markdown code-fence input that RazorDocs can render as highlighted or plain code.
CodeThe literal code block body, or null when an upstream renderer provides no text.LanguageThe first whitespace-delimited Markdown info-string token, or null when omitted.RazorDocsCodeBlock stores only the first whitespace-delimited info-string token in Language because the renderer treats that token as the language hint. It does not parse full info-string attributes. Language may be null when the info string is omitted, and Code may be null when an upstream renderer provides no text, so callers must handle both defensively.
Highlights Markdown code fences behind RazorDocs' internal HTML contract.
RazorDocsHighlightedCode Highlight(RazorDocsCodeBlock block)
Source
Renders a code block as either highlighted token markup or escaped plaintext fallback.
blockThe code block to render.RazorDocs-owned code block HTML.
Resolves authored, source, and canonical RazorDocs paths against a harvested documentation corpus.
RazorDocs accepts paths from several authoring surfaces: browser routes, source-relative Markdown metadata, generated canonical paths, and route-prefixed links. This resolver is the shared source of truth for trimming route separators, ignoring lookup fragments when selecting candidate buckets, preserving exact fragment matches when available, and ranking fallback candidates when a fragment-specific page is not present.
DocPathResolver Create(IEnumerable<DocNode> docs)
Source
Builds a resolver for a docs snapshot.
docsThe harvested docs whose source and canonical paths should be resolvable.A resolver that can match source paths, canonical route paths, and route-relative variants.
DocNode? Resolve(string path)
Source
Resolves a path exactly as authored, using RazorDocs source and canonical matching rules.
pathThe authored source or canonical path to resolve.The best matching doc node, or null when no harvested doc matches.
DocNode? Resolve(string path, params string[] routeRootPaths)
Source
Resolves a path by preserving authored source-relative matches before stripping known docs route roots from browser-facing inputs.
pathThe authored or browser-facing path to resolve.routeRootPathsRoute roots, such as the configured live docs root and the stable /docs root.The best matching doc node, or null when neither route-relative variants nor the original path match.
string NormalizeLookupPath(string path)
Source
Normalizes a documentation path for lookup by trimming route separators and removing fragment anchors.
pathThe path to normalize.The normalized lookup path.
string NormalizeCanonicalPath(string path)
Source
Normalizes a documentation path for canonical comparison by trimming route separators while preserving fragments.
pathThe path to normalize.The normalized canonical path.
string? GetFragment(string path)
Source
Extracts a fragment from a documentation path after canonical normalization.
pathThe path that may contain a fragment anchor.The fragment without the leading #, or null when no non-empty fragment exists.
Applies page-shell heading rules to harvested documentation HTML at render time.
string SuppressLeadingMarkdownH1(string content, bool shellOwnsH1)
Source
Removes the leading rendered Markdown h1 element when the details page shell already renders the page H1.
contentThe sanitized harvested HTML body to render inside the details page content surface.shellOwnsH1true when the page shell renders the semantic H1 from Models.DocDetailsViewModel.Title; false when the harvested body remains responsible for its own top-level heading.The original content when the shell does not own the H1 or when the body does not begin with an h1; otherwise the body with that first rendered h1 removed.
Only the leading H1 is suppressed. Later H1 elements remain visible because they are authored body structure, not duplicated page chrome.
Loads, validates, and resolves the configured RazorDocs version catalog.
The service performs best-effort validation so a broken stored release tree becomes unavailable without preventing healthy versions or the live preview surface from loading. Validation is intentionally release-local: every version is checked independently for a readable tree root, the required landing and search pages, the search index, and the shared search runtime assets that exact-version pages depend on. Exact trees are otherwise treated as immutable, self-contained artifacts: outline-aware exports should include the page-local outline runtime they reference, while historical trees are not crawled or upgraded at host startup. Public RazorDocsResolvedVersion.AvailabilityIssue values are sanitized for archive UI consumption, while filesystem paths and exception details stay in structured logs only.
RazorDocsResolvedVersionCatalog GetCatalog()
Source
Returns the resolved version catalog for the current host.
The resolved catalog including availability information for each published version. Returns RazorDocsResolvedVersionCatalog.Disabled when versioning is off for this host, RazorDocsResolvedVersionCatalog.EnabledWithoutCatalog when versioning is on but no catalog path was configured, and RazorDocsResolvedVersionCatalog.CreateUnavailable(string?) semantics when a configured catalog could not be loaded into a usable published-release set.
Represents the resolved version catalog used by the current host.
StatusThe high-level catalog resolution state for the current host. This distinguishes successful resolution from the three sentinel states where versioning is disabled, missing a catalog path, or configured but unavailable.CatalogPathThe catalog path associated with the resolved state. This stays null for the Disabled and EnabledWithoutCatalog sentinels, is typically an absolute filesystem path after successful resolution or file-based unavailability checks, and can remain the normalized configured value when Status is RazorDocsResolvedVersionCatalogStatus.Unavailable because absolute resolution failed before CreateUnavailable(string?) was created.VersionsThe resolved catalog entries in authored catalog order. Entries stay present even when a published tree is unavailable so archive, diagnostics, and fallback experiences can explain the broken release instead of silently hiding it.RecommendedVersionThe resolved recommended version when one is public and available. This can be null when versioning is disabled, no recommendation was configured, the configured identifier did not resolve, or the matching release was hidden or unavailable after validation.Disabled means the host is running with versioning off, so callers should treat the live docs surface as the only public experience and skip published-release archive UI entirely.
EnabledWithoutCatalog means versioning was turned on but no catalog path was configured, so callers can still expose the live preview surface but should not expect any published releases to resolve.
PublicVersions preserves the ordering from Versions after filtering by RazorDocsVersionVisibility.Public only. Public-but-unavailable releases remain in that list so the archive can surface their degraded status instead of pretending they do not exist.
RazorDocsResolvedVersionCatalog Disabled { get; }
Source
Gets the sentinel catalog result for hosts where versioning is disabled entirely.
RazorDocsResolvedVersionCatalog EnabledWithoutCatalog { get; }
Source
Gets the sentinel catalog result for hosts where versioning is enabled but no catalog path was configured.
IReadOnlyList<RazorDocsResolvedVersion> PublicVersions { get; }
Source
Gets the public versions that should appear in the archive.
This list preserves the authored order from Versions after filtering only by RazorDocsVersionVisibility.Public. Versions stay in the list even when RazorDocsResolvedVersion.IsAvailable is false so archive consumers can show degraded-release messaging instead of silently dropping known public releases.
Represents one resolved published docs version and its runtime availability.
VersionThe exact published version identifier.LabelThe archive label shown to readers.SummaryOptional summary copy shown in the archive.ExactTreePathThe resolved absolute path to the exported exact-version subtree.ExactRootUrlThe canonical public root URL for the exact version.SupportStateThe support-state badge surfaced in the archive.VisibilityThe archive visibility state.AdvisoryStateThe release-level advisory state.IsAvailableWhether the exact-version tree validated successfully.AvailabilityIssueThe sanitized public-facing availability explanation when the tree is unavailable. Internal logs retain filesystem paths and exception details, but this message is safe to surface in archive UI and reader-facing diagnostics.Describes how the current host resolved its published-version catalog state.
Numeric values are explicit and stable because callers may serialize or persist catalog-resolution state across process boundaries.
Serves one or more published RazorDocs trees from static export artifacts.
Published trees are usually exported from the stable /docs surface and then mounted later under the configured route-family root or {RouteRootPath}/v/{version}. This handler resolves extensionless requests back to the exporter’s .html files and rewrites stable-root HTML or search-index payloads so the mounted tree stays version-local.
Task<bool> TryHandleAsync(HttpContext httpContext)
Source
Attempts to serve the current request from one of the configured published trees.
httpContextThe current HTTP request context.true when a published tree handled the request; otherwise false.
Describes one published exact-version tree that should be mounted into the active host.
MountRootPathThe request-path root where the tree should appear.FileProviderThe static file provider for the tree contents.When multiple RazorDocsPublishedTreeMount instances overlap, callers should treat the longest MountRootPath as the winning mount because the request handler resolves mounts from most-specific to least-specific roots before serving content.
Rewrites stable-root published-tree content so the same artifact can be served from different mount roots.
Rewrites are mount-aware rather than file-aware. The active RazorDocsPublishedTreeMount decides which root wins, and then the rewriter adjusts exported stable-root URLs so they point at that mounted surface. The default stable /docs surface only needs HTML rewrites when the host adds a non-empty request PathBase; when the mount root and route root are still /docs and no PathBase applies, the exported HTML is already correct and is returned unchanged.
string RewriteHtml(string html, string mountRootPath, string previewRootPath = "/docs/next", string routeRootPath = DocsUrlBuilder.DocsEntryPath, string? requestPathBase = null)
Source
Rewrites stable-root HTML so docs-local links, assets, and client config point at the supplied mount root.
htmlThe exported HTML document.mountRootPathThe request-path root where the tree is being served.previewRootPathThe live preview docs root that should stay untouched when encountered.routeRootPathThe route-family root that owns archive and exact-version routes.requestPathBaseThe current host path base that should prefix rewritten app-relative docs URLs.The rewritten HTML document.
This method rewrites exported stable-root docs links, assets, and the inline window.__razorDocsConfig payload matched by DocsClientConfigRegex so the document behaves like it was originally emitted for mountRootPath. As part of that rewrite, the legacy docsVersionsUrl client field is removed because version archive navigation is rendered server-side. When mountRootPath and routeRootPath are both the default /docs, rewrites only occur if requestPathBase is non-empty so sub-path-hosted apps still emit /some-base/docs/... links.
string RewriteSearchIndexJson(string json, string mountRootPath, string previewRootPath = "/docs/next", string routeRootPath = DocsUrlBuilder.DocsEntryPath, string? requestPathBase = null)
Source
Rewrites a published search-index payload so mounted document URLs stay inside the active docs surface.
jsonThe exported search-index payload.mountRootPathThe request-path root where the tree is being served.previewRootPathThe live preview docs root that should stay untouched when encountered.routeRootPathThe route-family root that owns archive and exact-version routes.requestPathBaseThe current host path base that should prefix rewritten app-relative docs URLs.The original payload when the mount and route root are the default /docs surface without a non-empty path base, when the payload is not a JSON object with a top-level documents array, or when no eligible documents[*].path values require rewriting; otherwise a payload whose rewritten document paths stay inside the mounted docs root.
Only documents[*].path values are rewritten. Other JSON fields, including titles, metadata, and facet payloads, are preserved exactly as exported. Default stable mounts rooted at /docs are a no-op unless requestPathBase is non-empty, because the exported payload already points at the default surface. Preview-root paths, archive paths such as {RouteRootPath}/versions, and already-versioned exact routes such as {RouteRootPath}/v/1.2.3/guide.html are preserved rather than rebased. When a rewrite does occur, the helper prepends the normalized request path base to eligible app-relative URLs, so /docs/guide.html becomes /some-base/docs/v/1.2.3/guide.html for an exact mount at /docs/v/1.2.3. Callers should not expect other JSON fields to change, and they must supply a non-empty requestPathBase if stable mounts need virtual-directory rebasing.
(string Markdown, DocMetadata? Metadata) Extract(string markdown)
Source
Extracts inline Markdown front matter and returns the remaining Markdown with parsed metadata.
markdownThe Markdown source that may begin with YAML front matter.A tuple containing the Markdown body and parsed DocMetadata when present and valid.
This compatibility wrapper discards parser diagnostics. Invalid inline YAML returns the original Markdown with null metadata, and non-fatal authoring warnings such as invalid curation YAML or migration metadata are intentionally not surfaced. Call ExtractWithDiagnostics when callers need warnings.
(string Markdown, MarkdownMetadataParseResult Result) ExtractWithDiagnostics(string markdown)
Source
Extracts inline Markdown front matter and returns the remaining Markdown with diagnostics-aware metadata.
markdownThe Markdown source that may begin with YAML front matter.A tuple containing the Markdown body and a MarkdownMetadataParseResult whose MarkdownMetadataParseResult.Metadata contains parsed DocMetadata when present.
This is the authoritative internal entry point for inline metadata parsing. Missing front matter returns the original Markdown and an empty diagnostic list. Invalid inline YAML returns a RazorDocsMetadataDiagnostic instead of throwing, and deliberately preserves the original Markdown so a malformed header remains visible to the reader. Callers should inspect MarkdownMetadataParseResult.Diagnostics for authoring warnings instead of relying on exceptions for inline metadata failures.
DocMetadata? ParseMetadataYaml(string yaml)
Source
Parses a YAML metadata document into normalized documentation metadata.
yamlThe raw YAML content to deserialize.The normalized metadata model, or null when the YAML document is empty or explicitly null.
YamlExceptionThrown when yaml cannot be parsed as YAML.This compatibility wrapper is shared by inline Markdown front matter and paired sidecar metadata files so both authoring styles normalize through the same schema, defaults, and empty-list handling. It returns only the MarkdownMetadataParseResult.Metadata value from ParseMetadataYamlWithDiagnostics(string) and intentionally discards schema, migration, and authoring diagnostics. Call ParseMetadataYamlWithDiagnostics(string) when callers need those warnings in addition to normalized DocMetadata.
MarkdownMetadataParseResult ParseMetadataYamlWithDiagnostics(string yaml)
Source
Parses a YAML metadata document into a diagnostics-aware metadata result.
yamlThe raw YAML metadata document to deserialize.A MarkdownMetadataParseResult containing optional normalized DocMetadata plus any RazorDocsMetadataDiagnostic warnings produced while normalizing supported metadata fields.
This is the authoritative internal entry point for metadata documents that are already known to be YAML, including sidecar files. Empty documents and explicit YAML null values return null metadata and no diagnostics. An empty mapping literal such as {} still produces a normalized DocMetadata instance whose fields may all be null. YAML syntax errors still throw YamlException so sidecar callers can report the sidecar file failure through their existing error path; schema and migration warnings are returned through MarkdownMetadataParseResult.Diagnostics.
Performs the optional strict RazorDocs harvest-health startup preflight.
The service is always registered by AddRazorDocs(), but it is inert unless RazorDocsHarvestOptions.FailOnFailure is enabled. Strict mode reads DocAggregator.GetHarvestHealthAsync(CancellationToken) so startup observes the same cached snapshot that docs requests use instead of running a second harvest pipeline.
Task StartAsync(CancellationToken cancellationToken)
Source
Checks harvest health during host startup when strict harvest failure is enabled.
cancellationTokenToken observed while waiting for the cached harvest-health snapshot.A completed task when strict mode is disabled or the aggregate status is not failed.
RazorDocsHarvestFailedExceptionThrown when RazorDocsHarvestOptions.FailOnFailure is enabled and the aggregate harvest status is DocHarvestHealthStatus.Failed.Task StopAsync(CancellationToken cancellationToken)
Source
Stops the preflight service.
cancellationTokenUnused cancellation token supplied by the host.A completed task because the preflight owns no background work.
Resolves environment-aware visibility for RazorDocs harvest health routes and sidebar chrome.
bool AreRoutesExposed(RazorDocsOptions options, IHostEnvironment environment)
Source
Resolves whether the harvest health controller routes should be registered or allowed for the current host.
This internal helper uses RazorDocsOptions.Harvest health route settings and the supplied host environment. Missing health options fall back to RazorDocsHarvestHealthExposure.DevelopmentOnly. Callers must pass the real host environment; the method null-checks both arguments before applying the environment-gated visibility contract.
bool ShouldShowChrome(RazorDocsOptions options, IHostEnvironment environment)
Source
Resolves whether the sidebar should show harvest health chrome for the current host.
This internal helper uses RazorDocsOptions.Harvest health chrome settings and the supplied host environment. Missing health options fall back to RazorDocsHarvestHealthExposure.DevelopmentOnly. Callers use this for presentation chrome only; route exposure is resolved separately by AreRoutesExposed(RazorDocsOptions, IHostEnvironment). The method null-checks both arguments before applying the environment-gated visibility contract.
Registers RazorDocs' fenced-code renderer with Markdig.
IRazorDocsCodeHighlighter CreateDefaultHighlighter(ILogger<TextMateSharpRazorDocsCodeHighlighter> logger)
Source
Creates the default TextMateSharp-backed RazorDocs highlighter.
loggerLogger used to emit diagnostics when grammar loading or highlighting falls back.The default RazorDocs code highlighter.
Renders Markdown fenced code blocks through RazorDocs' highlighter contract.
string? ExtractLanguage(FencedCodeBlock block)
Source
Extracts the first language token from a fenced code block's info string.
blockThe fenced code block to inspect.The first language token, or null when the fence has no info string.
Describes one non-fatal RazorDocs metadata authoring problem discovered while parsing or normalizing metadata.
CodeStable diagnostic code suitable for tests, logs, and documentation.FieldPathMetadata field path associated with the warning, such as featured_page_groups[0].pages.ProblemReader-facing summary of what is wrong.CauseExplanation of why RazorDocs cannot safely use the authored value as-is.FixSuggested author action that resolves the warning.Carries normalized metadata together with non-fatal diagnostics from a Markdown metadata parse.
MetadataThe parsed metadata, or null when no usable metadata document was present.DiagnosticsWarnings produced while parsing or normalizing metadata fields.Resolves authored reader-intent landing curation metadata into browser-facing RazorDocs featured-page groups.
The resolver accepts the normalized featured_page_groups metadata on a landing document, matches each authored destination against harvested docs by source or canonical path, skips destinations that are missing, hidden, blank, or duplicated, and returns only groups that still contain at least one visible page. Logging is intentionally warning-level because curation mistakes degrade first-run docs navigation without breaking application startup.
IReadOnlyList<DocLandingFeaturedPageGroupViewModel> ResolveGroups(DocNode? landingDoc, IReadOnlyList<DocNode> docs)
Source
Resolves grouped featured-page metadata from landingDoc against the harvested docs corpus.
landingDocThe root or section landing document that owns the curation metadata, or null when the caller has no landing page to resolve.docsThe harvested docs corpus used for destination lookup.A list of resolved featured-page groups ordered by authored group order, then authored position. The method returns an empty list when landingDoc is null, when the landing doc has no featured_page_groups, or when every authored group is filtered out during resolution. Groups with no visible destinations after validation are omitted. Destinations that resolve to docs without a public DocNode.CanonicalPath are skipped with a warning because collision losers and reserved routes are intentionally not linkable. Duplicate destinations are suppressed across all groups, so a page resolved earlier in authored order will not appear again later in the landing. Browser-facing DocLandingFeaturedPageViewModel.Href values are rooted at the current live docs surface from DocsUrlBuilder, not hardcoded to /docs, and authored canonical input paths are matched against that same configured live docs root before the configured route-family root and legacy stable /docs prefix fallback are considered.
Sanitizes harvested RazorDocs HTML with the package-owned allowlist for docs content and highlighted code blocks.
RazorDocs starts from the HtmlSanitizer defaults, adds the package-owned content tags section, article, header, details, summary, pre, code, and span, and allows the class, id, and open attributes. The sanitizer explicitly removes style from the default attribute set so harvested Markdown, generated API HTML, and server-side highlighted code can keep structural hooks while inline presentation and unsafe markup are stripped. Callers should pass already-rendered RazorDocs HTML through this sanitizer before display or export; supported semantic wrappers and token spans are preserved, while scripts, event handlers, inline styles, and unsupported attributes are discarded.
string Sanitize(string html)
Source
Sanitizes rendered documentation HTML using the RazorDocs allowlist.
htmlThe rendered HTML to sanitize.Safe HTML that preserves RazorDocs structural markup and removes unsupported tags or attributes.
Describes RazorDocs' normalized view of an authored code-fence language token.
NormalizedLanguageThe stable RazorDocs language name.ClassLanguageThe safe suffix used by the conventional language-* class.LabelThe reader-facing language label.TextMateLanguageIdThe TextMateSharp language id, or null for plaintext fallback.IsKnownWhether the authored token is part of RazorDocs' recognized language catalog.IsPlainTextWhether the language should render as escaped plaintext.Builds canonical RazorDocs URLs for one RazorDocs route family.
This builder centralizes the route contract so controllers, view components, views, and client scripts do not each guess how the docs surface is rooted. RouteRootPath is the stable route-family root used for archive and exact-version routes. CurrentDocsRootPath is the live source-backed docs root used for current docs, search, and current search-index routes. Most consumers should copy Routes rather than assembling route strings or calling lower-level builder methods directly.
string BuildHomeUrl()
Source
Builds the current live docs home URL.
The current docs home path.
string BuildSearchUrl()
Source
Builds the current live docs search workspace URL.
The app-relative search workspace URL for the current docs surface.
string BuildSearchIndexUrl()
Source
Builds the current live docs search-index URL.
The app-relative search-index URL for the current docs surface.
string BuildSearchIndexRefreshUrl()
Source
Builds the current live docs search-index refresh URL.
The app-relative authenticated refresh URL for the current docs search index.
string BuildHealthUrl()
Source
Builds the current live docs harvest health HTML URL.
The app-relative health page URL for the current docs surface.
string BuildHealthJsonUrl()
Source
Builds the current live docs harvest health JSON URL.
The app-relative machine-readable health URL for the current docs surface.
string BuildSectionUrl(DocPublicSection section)
Source
Builds a current-surface public section URL.
sectionThe section whose route should be built.The canonical section URL rooted at the current docs surface.
string BuildDocUrl(string path)
Source
Builds a current-surface canonical document URL.
pathThe source or canonical documentation path.The canonical document URL rooted at the current docs surface.
string BuildDocUrl(string docsRootPath, string path)
Source
Builds a canonical document URL rooted at an explicit docs surface root.
docsRootPathThe app-relative docs root path.pathThe source or canonical documentation path.The canonical document URL.
string BuildAssetUrl(string assetName)
Source
Builds the current-surface search asset URL.
assetNameThe asset file name, such as search.css.The canonical asset URL rooted at the current docs surface.
string BuildVersionRootUrl(string version)
Source
Builds the exact-version root URL for one published docs release.
versionThe exact published version identifier.The canonical root URL for that version.
string BuildVersionDocUrl(string version, string path)
Source
Builds a canonical document URL rooted at a specific exact version.
versionThe exact published version identifier.pathThe source or canonical documentation path.The canonical document URL rooted at the requested version.
string BuildVersionsUrl()
Source
Builds the public archive URL.
The stable archive URL.
bool IsCurrentDocsPath(string? path)
Source
Determines whether the supplied request path is inside the current live docs surface.
pathThe request path to check.true when the path belongs to the current live docs surface; otherwise false.
bool IsUnderRoot(string? path, string docsRootPath)
Source
Determines whether a request path belongs to the supplied docs root.
pathThe incoming request path to evaluate.docsRootPathThe normalized docs root path configured for the live docs surface.true when path resolves to the docs root itself or one of its child routes; otherwise false.
Blank paths always return false. Root-mounted docs (/) use IsLikelyRootMountedDocsPath(string) so only known docs-like routes are treated as current docs traffic. Non-root mounts use case-insensitive exact and prefix matching against {docsRootPath}/....
string JoinPath(string docsRootPath, string relativePath)
Source
Joins a normalized docs root with a relative docs route segment.
docsRootPathThe normalized app-relative docs root path.relativePathThe relative docs route to append.The combined app-relative route path.
Leading slashes on relativePath are ignored. null, empty, and whitespace-only relative paths return the docs root unchanged. When the docs root is /, the result stays root-mounted instead of producing a doubled slash. Callers are expected to pass already-normalized root paths and docs-relative segments rather than arbitrary URLs.
string NormalizeDocsRootPath(string? docsRootPath, bool versioningEnabled)
Source
Normalizes a configured docs root into the app-relative route contract RazorDocs uses at runtime.
docsRootPathThe configured docs root, which may be null, relative-looking, or already normalized.versioningEnabledWhether versioning is enabled and the default should therefore become /docs/next.The normalized app-relative docs root path.
string NormalizeRouteRootPath(string? routeRootPath, string docsRootPath, bool versioningEnabled)
Source
Normalizes a configured route-family root into the app-relative route contract RazorDocs uses at runtime.
routeRootPathThe configured route root, which may be null, relative-looking, or already normalized.docsRootPathThe normalized live docs root used when versioning is disabled and no route root is configured.versioningEnabledWhether versioning is enabled and the default route family should remain /docs.The normalized app-relative route-family root path.
bool VersioningEnabled { get; }
Source
Gets a value indicating whether versioning is enabled for the current host.
string CurrentDocsRootPath { get; }
Source
Gets the canonical root path for the current live source-backed docs surface.
string RouteRootPath { get; }
Source
Gets the stable route-family root for this RazorDocs instance.
The route root is the parent for the stable entry alias, version archive, and exact-version release trees. It is the same as CurrentDocsRootPath when versioning is disabled, and commonly the parent of the live preview root when versioning is enabled. For example, RouteRootPath=/foo/bar with DocsRootPath=/foo/bar/next keeps the archive at /foo/bar/versions while the live preview stays at /foo/bar/next.
string DocsEntryRootPath { get; }
Source
Gets the docs entry path used as the stable public landing alias.
string DocsVersionPrefixPath { get; }
Source
Gets the stable exact-version prefix for this route family.
string DocsVersionsRootPath { get; }
Source
Gets the stable archive path for this route family.
RazorDocsRouteReferences Routes { get; }
Source
Gets named RazorDocs routes that consumers should prefer over hardcoded route strings.
Named RazorDocs routes for one configured route family.
Consumers should prefer this record when they need well-known RazorDocs destinations in host code, operator guidance, generated configuration, or documentation. The values are app-relative. Views and other presentation boundaries apply request PathBase separately before sending browser-facing URLs.
void Deconstruct(out string home, out string search, out string searchIndex, out string searchIndexRefresh, out string versions)
Source
Deconstructs the original route set for callers that used the positional record contract.
homeThe current live docs home route.searchThe current live docs search workspace route.searchIndexThe current live docs search-index JSON route.searchIndexRefreshThe authenticated search-index refresh route.versionsThe route-family archive route.void Deconstruct(out string home, out string search, out string searchIndex, out string searchIndexRefresh, out string versions, out string health, out string healthJson)
Source
Deconstructs all known routes.
homeThe current live docs home route.searchThe current live docs search workspace route.searchIndexThe current live docs search-index JSON route.searchIndexRefreshThe authenticated search-index refresh route.versionsThe route-family archive route.healthThe current live docs harvest health HTML route.healthJsonThe current live docs harvest health JSON route.string Home { get; init; }
Source
Gets the current live docs home route.
string Search { get; init; }
Source
Gets the current live docs search workspace route.
string SearchIndex { get; init; }
Source
Gets the current live docs search-index JSON route.
string SearchIndexRefresh { get; init; }
Source
Gets the authenticated search-index refresh route.
string Versions { get; init; }
Source
Gets the route-family archive route, whether or not versioning endpoints are currently enabled.
string Health { get; init; }
Source
Gets the current live docs harvest health HTML route.
string HealthJson { get; init; }
Source
Gets the current live docs harvest health JSON route.
Harvester implementation that scans Markdown source files and converts them into documentation nodes.
Task<IReadOnlyList<DocNode>> HarvestAsync(string rootPath, CancellationToken cancellationToken = default)
Source
Harvests Markdown files under the specified root directory and converts each into a DocNode containing a display title, relative path, generated HTML, metadata, and page outline.
rootPathThe root directory to search recursively for `.md` files and an optional root `LICENSE` file.cancellationTokenAn optional token to observe for cancellation requests.A collection of DocNode objects representing each processed Markdown source file, including the display title, path relative to rootPath, generated HTML, metadata, and DocNode.Outline entries when outline headings are available.
Skips files in excluded directories (for example "node_modules", "bin", "obj", and "Tests") and hidden dot-prefixed directories unless explicitly allowlisted. Dot-prefixed files are included. The root LICENSE file is also included when present so repository-relative license links can resolve in static exports. If a file's name is "README" (case-insensitive), its title is set to the parent directory name or "Home" for a repository root README. The Markdown body is parsed once with Markdown.Parse(markdownBody, _pipeline); HTML is rendered from that AST and DocNode.Outline is populated from the same AST with ExtractOutline so callers can rely on outline data being present when eligible headings are available. Files that fail to process are skipped and an error is logged.
Task<DocMetadata?> ReadMetadataSidecarAsync(string markdownFilePath, string relativeMarkdownPath, CancellationToken cancellationToken)
Source
Reads an optional paired sidecar metadata file for a Markdown source document.
markdownFilePathThe absolute Markdown file path.relativeMarkdownPathThe Markdown file path relative to the harvest root.cancellationTokenA token that can cancel sidecar discovery or file reads.The parsed sidecar metadata, or null when no valid sidecar applies.
RazorDocs supports paired metadata files named {file}.yml and {file}.yaml such as README.md.yml. When both extensions exist for the same Markdown file, RazorDocs logs a warning and ignores both sidecars until the ambiguity is removed. Inline front matter remains the primary metadata source and overrides any overlapping sidecar fields.
IReadOnlyList<DocOutlineItem> ExtractOutline(MarkdownDocument document)
Source
Extracts page-local outline entries from Markdown heading blocks.
documentThe parsed Markdown document whose heading blocks should be inspected.A source-ordered list of DocOutlineItem values. Each item contains the rendered fragment DocOutlineItem.Id, normalized reader-facing DocOutlineItem.Title, and original heading DocOutlineItem.Level.
Only HeadingBlock descendants with levels between MinOutlineHeadingLevel and MaxOutlineHeadingLevel are included, which means the built-in Markdown harvester emits H2-H3 headings by default. Fragment IDs come from HtmlAttributesExtensions.GetAttributes(heading).Id and titles are produced by NormalizeHeadingText(ExtractInlineText(heading.Inline)). Headings without a non-empty fragment ID or normalized title are silently omitted; consumers and tests should account for those drops and for whitespace normalization when comparing outline titles.
string? ExtractLeadingTitle(MarkdownDocument document)
Source
Extracts the document title from a leading Markdown H1 when one exists.
documentThe parsed Markdown document whose first block may be a page-title H1.The normalized heading text from the leading H1, or null when the document starts with another block or the H1 has no readable text.
This mirrors details-page H1 suppression: only the leading H1 can become package-owned page chrome. Later H1 elements remain body structure and do not replace filename or metadata title fallback behavior.
string ExtractInlineText(ContainerInline? inline)
Source
Extracts plain reader-facing text from a Markdig inline container for outline display.
inlineThe inline container to flatten.The extracted text, or an empty string when no inline content exists.
string NormalizeHeadingText(string value)
Source
Normalizes heading text by collapsing whitespace without introducing leading spaces.
valueThe raw heading text.The normalized heading text.
Enumerates the documentation targets harvested into a RazorDocs snapshot so link rewriting can avoid guessing from file extensions alone.
The manifest stores both source paths, such as guides/start.md, and canonical browser paths, such as guides/start.md.html. Query strings and fragments are intentionally ignored because anchors and query parameters decorate a page target rather than defining a separate harvested document.
DocLinkTargetManifest FromNodes(IEnumerable<DocNode> nodes)
Source
Creates a manifest from harvested documentation nodes.
nodesThe harvested documentation nodes that may be linked through RazorDocs routes.A manifest containing source and canonical target forms for the supplied nodes.
DocLinkTargetManifest FromPaths(IEnumerable<string?> paths)
Source
Creates a manifest from source or canonical documentation paths.
pathsThe documentation paths to register as known link targets.A manifest containing normalized source and canonical target forms.
bool Contains(string? path)
Source
Determines whether the supplied path resolves to a harvested documentation target.
pathA source or canonical documentation path, optionally rooted, queried, or fragmented.true when the normalized target is in the manifest; otherwise false.
Normalizes harvested non-Markdown source paths into legacy browser-facing routes used by RazorDocs.
A harvested source path is the repository-relative or generated path assigned to a DocNode before RazorDocs publishes it. This helper is intentionally narrow: it exists for generated or imported non-Markdown sources such as XML API reference pages, generated JSON or YAML API specs, and imported HTML fragments that still use the historical .html route shape. Markdown documents should use DocRouteIdentityCatalog instead, because that catalog owns clean public routes, redirect aliases, collisions, and reserved-route diagnostics.
string BuildCanonicalPath(string sourcePath)
Source
Constructs a legacy browser-facing path for a harvested non-Markdown documentation source path.
sourcePathThe harvested source path, optionally including a fragment.The legacy docs route path, including the .html suffix used by generated API docs and any original fragment identifier. Markdown public routes are owned by DocRouteIdentityCatalog.
Use this method only when a source must keep the generated-docs compatibility contract where Namespaces/Foo.Bar becomes Namespaces/Foo.Bar.html. It trims leading and trailing separators, preserves fragments, normalizes backslashes to slashes, and appends .html unless the final file name already has that suffix. The word "canonical" in the method name refers to this legacy generated-doc route canonicalization; it does not mean the clean Markdown route contract. For authored Markdown pages, callers should query DocRouteIdentityCatalog so explicit canonical_slug, redirect aliases, public-route collisions, and reserved-route checks all remain centralized.
Sanitizes rendered RazorDocs HTML using the package's docs-specific allowlist.
IRazorDocsHtmlSanitizer exists to normalize rendered package documentation fragments before RazorDocs displays them. It is not a general-purpose user-generated-content sanitizer, JavaScript policy, or replacement for a host-owned Content Security Policy. Unsupported elements or attributes may be removed.
string Sanitize(string html)
Source
Sanitizes the provided HTML fragment.
htmlThe rendered RazorDocs HTML fragment to sanitize.The sanitized HTML fragment.
Sanitize expects a non-null rendered RazorDocs HTML fragment, not a complete document or unrendered template. Implementations should throw ArgumentNullException when html is null and should preserve already-encoded text rather than double-encoding it.
Owns Markdown code-fence language normalization, safe CSS class suffixes, and TextMateSharp lookup ids.
RazorDocsCodeLanguage Normalize(string? language)
Source
Normalizes an authored language token into RazorDocs' stable language contract.
languageThe raw first info-string token.A safe language descriptor for rendering and TextMate lookup.
string CreateSafeClassSlug(string value)
Source
Converts arbitrary language input into a CSS-safe lowercase ASCII slug.
valueThe value to slug.A lowercase slug containing only ASCII letters, digits, and hyphens.
TextMateSharp-backed implementation of RazorDocs' internal code-block highlighting contract.
IGrammar? LoadGrammar(RazorDocsCodeLanguage language)
Source
Loads the TextMate grammar for a normalized language, returning null when no grammar exists.
languageThe normalized language descriptor.The loaded grammar, or null when the language has no TextMate scope.
void AppendTokens(StringBuilder builder, string line, IReadOnlyList<IToken> tokens)
Source
Appends a tokenized source line while preserving unclassified gaps and trailing text.
builderThe destination HTML builder.lineThe original source line.tokensTextMate tokens for the line.string? ResolveTokenClass(IReadOnlyList<string> scopes)
Source
Maps TextMate scopes to RazorDocs' small semantic token vocabulary.
scopesThe scopes attached to a TextMate token.The RazorDocs token modifier, or null for unstyled scopes.
Cached search-index payload for the live source-backed docs surface.
MetadataStatic metadata emitted alongside the indexed documents.DocumentsSearchable docs entries in the shape consumed by the built-in MiniSearch client.Metadata emitted with each docs search-index payload.
GeneratedAtUtcUTC timestamp for when the snapshot was generated.VersionSchema version understood by the search client.EngineClient-side search engine identifier.Search document entry emitted for the built-in docs search experience.
IdStable identifier for the indexed document.PathBrowser-facing docs URL used for result navigation.TitleDisplay title shown in search results.SummarySummary text favored for recovery and preview UI.HeadingsNormalized heading titles harvested from the document outline.BodyTextFull normalized body text indexed for recall.SnippetShort excerpt shown in search results.PageTypePage-type facet value.PageTypeLabelResolved page-type badge label.PageTypeVariantResolved page-type badge variant.AudienceAudience facet value when explicitly authored.ComponentComponent facet value when explicitly authored.AliasesAlternative phrases that should match the page.KeywordsAdditional authored search keywords.StatusStatus facet value.NavGroupPublic navigation group label when present.PublicSectionResolved public-section slug when the page participates in a public section.PublicSectionLabelHuman-readable public-section label.IsSectionLandingWhether this record is the resolved landing page for its public section.OrderAuthored order hint used for browse sorting.SequenceKeyOptional authored sequence key for related content.CanonicalSlugOptional canonical slug used for route continuity.RelatedPagesAuthored related-page references used for recovery links.BreadcrumbsAuthored breadcrumb labels displayed in result chrome.SourcePathRepository-relative source path retained for provenance and custom integrations.The Path value is cached relative to the live docs surface root and can be rebased onto a request PathBase at response time without rebuilding the full snapshot. Lists are serialized as JSON arrays so the browser client can preserve exact ordering for headings, aliases, related pages, and breadcrumbs.
Service responsible for aggregating documentation from multiple harvesters and caching the results.
Task<IReadOnlyList<DocNode>> GetDocsAsync(CancellationToken cancellationToken = default)
Source
Retrieves all harvested documentation nodes sorted by their Path.
cancellationTokenAn optional token to observe for cancellation requests.A read-only list of all DocNode objects ordered by their Path.
Task<DocHarvestHealthSnapshot> GetHarvestHealthAsync(CancellationToken cancellationToken = default)
Source
Returns structured health for the current RazorDocs harvest snapshot.
cancellationTokenAn optional token to observe while waiting for the cached snapshot.Structured harvest health that distinguishes valid empty docs from failed or degraded harvests.
The health snapshot is produced by the same memoized harvest used by GetDocsAsync(CancellationToken). If no docs snapshot exists yet, calling this method triggers the same snapshot generation as a docs read. Caller cancellation cancels only the caller's wait; it does not cancel or poison the shared snapshot computation.
Task<DocNode?> GetDocByPathAsync(string path, CancellationToken cancellationToken = default)
Source
Retrieves a documentation node for a source path or canonical docs path.
pathThe source or canonical documentation path to look up.cancellationTokenAn optional token to observe while waiting for the cached snapshot.The matching DocNode, or null if no node exists for the given path.
The lookup awaits the cached docs snapshot, then delegates to the snapshot's DocPathResolver so legacy source paths, generated canonical .html paths, fragments, separators, and casing follow the same matching rules used by details pages and curated links.
Task<DocRouteResolution> ResolvePublicRouteAsync(string path, CancellationToken cancellationToken = default)
Source
Resolves a requested browser-facing docs route against the current snapshot route catalog.
pathThe non-null request path to resolve. Callers may pass a docs-relative route such as packages, a rooted docs path such as /docs/packages, or a source-shaped path. Markdown source-shaped paths for public winners resolve as redirects to their clean public routes; non-Markdown source paths, collision losers, and reserved routes remain non-public.cancellationTokenAn optional token observed while waiting for the cached docs snapshot.A DocRouteResolution whose kind tells callers whether the request is the canonical public route, a declared or Markdown source-shaped alias that should redirect to DocRouteResolution.PublicRoutePath, an internal non-Markdown source match, a collision or reserved-route loser, or an unresolved path.
This method does not redirect or mutate the snapshot. It awaits GetCachedDocsSnapshotAsync, then delegates to DocRouteIdentityCatalog.ResolvePublicRoute(string) so controllers and link builders branch on the same route identity semantics. Markdown source-shaped redirects let links copied from GitHub or editor paths recover to their published canonical routes instead of falling into the generic 404 page.
Task<DocDetailsViewModel?> GetDocDetailsAsync(string path, CancellationToken cancellationToken = default)
Source
Builds the typed details view model for the specified documentation page.
pathThe documentation path to resolve.cancellationTokenAn optional token to observe for cancellation requests.A DocDetailsViewModel containing the resolved page, its in-page outline, and wayfinding links, or null when the page cannot be resolved.
Task<DocsSearchIndexPayload> GetSearchIndexPayloadAsync(CancellationToken cancellationToken = default)
Source
Returns the docs search-index payload generated during docs aggregation.
cancellationTokenAn optional token to observe for cancellation requests.A typed payload containing the search metadata and documents emitted by the live docs surface. The payload is cached before response serialization so callers can rebase rooted paths, such as /docs/guide.html, onto a request PathBase without reparsing or reserializing an intermediate JSON node graph.
Task<IReadOnlyList<DocSectionSnapshot>> GetPublicSectionsAsync(CancellationToken cancellationToken = default)
Source
Returns the normalized public-section snapshots derived from the harvested docs corpus.
cancellationTokenAn optional token to observe for cancellation requests.The ordered public sections visible in the current docs snapshot.
Task<DocSectionSnapshot?> GetPublicSectionAsync(DocPublicSection section, CancellationToken cancellationToken = default)
Source
Returns one normalized public-section snapshot when the section is present in the current docs snapshot.
sectionThe public section to resolve.cancellationTokenAn optional token to observe for cancellation requests.The matching section snapshot, or null when the section has no visible public pages.
void InvalidateCache()
Source
Invalidates the cached docs snapshot so docs and search-index are rebuilt on next access.
Task<CachedDocsSnapshot> GetCachedDocsSnapshotAsync()
Source
Retrieves the cached docs snapshot, harvesting docs and generating the search-index payload when absent.
A cached snapshot containing both docs and search-index payload.
When harvesting, each configured harvester is invoked; failures from individual harvesters are caught and logged. Contents are sanitized before being cached. If multiple nodes share the same Path, a warning is logged and the first occurrence is retained. The search-index payload is generated from the same harvested snapshot. Caller cancellation does not cancel shared snapshot computation; callers can cancel their own wait. Harvester execution is bounded by a timeout so a single slow harvester cannot block snapshot regeneration indefinitely. The memoized cache entry is created with the configured absolute expiration from RazorDocsOptions.CacheExpirationMinutes.
Task<DateTimeOffset?> ResolveGitLastUpdatedUtcAsync(string repositoryRoot, string sourcePath, ILogger logger, CancellationToken cancellationToken, Func<string, IReadOnlyList<string>, string, ILogger, CancellationToken, Task<CommandResult>>? executeProcessAsync = null)
Source
Resolves the last committed UTC timestamp for a source path from local git history.
repositoryRootThe repository root used as the git working directory.sourcePathThe repository-relative source path to inspect.loggerLogger used for diagnostic output when git is unavailable or returns unusable data.cancellationTokenCancellation used to abort the lookup when snapshot generation times out.executeProcessAsyncOptional process-execution seam used by tests to simulate git output and failure modes without mutating machine-level PATH state.The exact last-updated UTC timestamp when git returns a parseable ISO 8601 commit date; otherwise null.
IReadOnlyList<DocSectionSnapshot> BuildPublicSections(IEnumerable<DocNode> docs, ILogger logger)
Source
Builds the public-section snapshots from the harvested docs corpus.
docsThe harvested docs to classify.loggerLogger used for section-landing conflict warnings.The ordered public sections that have at least one visible page.
(DocsSearchIndexPayload Payload, int RecordCount) BuildSearchIndexPayload(IEnumerable<DocNode> docs, IReadOnlyList<DocSectionSnapshot> publicSections, DocRouteIdentityCatalog routeIdentityCatalog)
Source
Builds the search-index payload from the harvested documentation nodes.
docsThe documentation nodes to index.publicSectionsThe resolved public sections used to derive landing winners.routeIdentityCatalogThe snapshot route catalog used to emit public canonical paths.A tuple containing the serializable payload and the number of records indexed.
string NormalizeSearchText(string? text)
Source
Decodes HTML entities and normalizes whitespace in the provided text for search indexing.
textThe text to normalize.The normalized text.
string BuildSearchDocUrl(string path)
Source
Constructs a browser-facing URL for a documentation path.
pathThe relative documentation path.A URL string starting with "/docs".
string BuildSearchDocUrl(string docsRootPath, string path)
Source
Constructs a browser-facing URL for a documentation path rooted at a specific docs surface.
docsRootPathThe app-relative docs root path.pathThe relative documentation path.A URL string rooted at docsRootPath.
string TruncateSnippetAtWordBoundary(string text, int maxLength)
Source
Truncates a text snippet at the last word boundary before the maximum length is exceeded.
textThe text to truncate.maxLengthThe maximum allowed length of the snippet.The truncated text with an ellipsis if it was shortened.
void MergeNamespaceReadmes(List<DocNode> nodes)
Source
Merges README content into the corresponding namespace overview pages.
nodesThe list of documentation nodes to process; README nodes used for merging are removed from this list.string MergeNamespaceIntroIntoContent(string namespaceContent, string readmeContent)
Source
Inserts README content into a namespace overview page after the auto-generated namespace groups.
namespaceContentThe auto-generated HTML content for the namespace page.readmeContentThe HTML content from the README file. A leading rendered Markdown H1 is removed before the README is wrapped because namespace overview pages render their primary H1 in the surrounding details shell.The merged HTML content, with any leading README H1 omitted from the namespace intro section.
int FindMatchingSectionEnd(string content, int sectionStart)
Source
Finds the index of the closing </section> tag that matches a <section> tag starting at the specified index.
contentThe HTML content to search.sectionStartThe starting index of the <section> tag.The index of the closing tag, or -1 if no match is found.
bool IsReadmePath(string path)
Source
Determines whether the specified path points to a documentation README file.
pathThe path to check.true if the path identifies a README.md file; otherwise, false.
string ExtractNamespaceNameFromNamespacePath(string path)
Source
Extracts the dotted namespace name from a documentation path under the "Namespaces/" directory.
pathThe path to process.The extracted namespace name.
string? ExtractNamespaceNameFromReadmePath(string path)
Source
Attempts to extract a namespace name from a README path by looking at the parent directory name.
pathThe README path to process.The extracted namespace name, or null if it cannot be determined.
string? ExtractNamespaceNameFromReadmePath(string path, IEnumerable<string>? knownNamespaceNames)
Source
Extracts a namespace name from a README path, optionally matching against a list of known namespaces.
pathThe README path to process.knownNamespaceNamesOptional list of known namespaces to match directory segments against. When provided, README paths are only treated as namespace introductions when the matching namespace folder appears under a trusted container directory such as docs or Namespaces.The extracted namespace name, or null if it cannot be determined.
bool HasNamespaceReadmePrefix(IReadOnlyList<string> parts, int namespaceStartIndex)
Source
Determines whether the matched namespace folder appears in one of the supported namespace README locations.
partsThe normalized directory path segments that precede README.md.namespaceStartIndexThe index where the matched namespace name begins within parts.true when the namespace folder lives under a trusted container like docs or Namespaces; otherwise, false.
string NormalizeLookupPath(string path)
Source
Normalizes a documentation path for lookup by trimming slashes and removing fragment anchors.
pathThe path to normalize.The normalized lookup path.
string? GetFragment(string path)
Source
Extracts the fragment anchor (after the '#') from a documentation path.
pathThe path to process.The fragment string, or null if no fragment is present.
TimeSpan SnapshotCacheDuration { get; }
Source
Gets the configured absolute lifetime for the shared docs snapshot cache.
Contains RazorDocs-owned HTML for a rendered Markdown code block.
HtmlThe complete sanitized-shape HTML fragment for the code block.NormalizedLanguageThe normalized language identifier used by RazorDocs.IsHighlightedWhether token spans were emitted for the code body.Rewrites harvested documentation links so authored Markdown can use repository-relative source links while the rendered docs experience still navigates through canonical RazorDocs routes.
string RewriteInternalDocLinks(string sourcePath, string html, string docsRootPath, DocLinkTargetManifest targetManifest)
Source
Rewrites internal documentation anchors in rendered HTML so they point at canonical RazorDocs routes and carry Turbo navigation attributes that keep browser history aligned with frame navigation.
sourcePathThe harvested source path whose content is being rewritten.htmlThe rendered and sanitized HTML fragment to rewrite.docsRootPathThe app-relative docs root path that should own rewritten links.targetManifestManifest of harvested documentation targets that may be rewritten to docs routes.The rewritten HTML fragment.
string PrefixPathBaseForDocsUrls(string html, string docsRootPath, string? requestPathBase, string routeRootPath = DocsUrlBuilder.DocsEntryPath)
Source
Prefixes request PathBase for rooted docs-local anchor hrefs in rendered HTML content.
htmlThe rendered HTML fragment whose rooted docs-local links should honor the current request path base.docsRootPathThe current live docs root that owns source-backed documentation routes.requestPathBaseThe request path base that should prefix rooted docs-local hrefs when present.routeRootPathThe route-family root that owns stable entry, archive, and exact-version routes.The original fragment when no path base applies or no docs-local rooted links are present; otherwise a fragment whose docs-local anchor hrefs are prefixed so mounted apps stay inside their virtual root.
This helper intentionally scopes itself to docs-local routes rather than all rooted links. Authored content may legitimately include other site-rooted links that should remain outside the docs shell, while docs-local links generated by RewriteInternalDocLinks(string,string,string,DocLinkTargetManifest) must stay within the current mounted app.