RazorDocs Search
API Reference

Services

Type

CSharpDocHarvester

Source

Harvester implementation that scans C# source files for XML documentation comments.

Method

HarvestAsync

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.

Parameters

  • rootPathThe root directory to recursively scan for .cs files.
  • cancellationTokenAn optional token to observe for cancellation requests.

Returns

A collection of DocNode objects; each contains a title, a relative file path including a fragment anchor, and the extracted HTML documentation.

Remarks

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.

Method

GetMethodId

string GetMethodId(MethodDeclarationSyntax method, string qualifiedTypeName) Source

Computes the safe ID for a method to be used in HTML content and stub nodes.

Parameters

  • methodThe method declaration syntax.
  • qualifiedTypeNameThe qualified name of the containing type.

Returns

The safe ID string for the method documentation section.

Method

GetPropertyId

string GetPropertyId(PropertyDeclarationSyntax property, string qualifiedTypeName) Source

Computes the safe ID for a property to be used in HTML content and stub nodes.

Parameters

  • propertyThe property declaration syntax.
  • qualifiedTypeNameThe qualified name of the containing type.

Returns

The safe ID string for the property documentation section.

Method

GetHighlightedDisplaySignature

string GetHighlightedDisplaySignature(MethodDeclarationSyntax method) Source

Generates a syntax-highlighted HTML string representing a method signature for display.

Parameters

  • methodThe method declaration syntax.

Returns

An HTML fragment containing the highlighted signature.

Method

GetHighlightedPropertySignature

string GetHighlightedPropertySignature(PropertyDeclarationSyntax property) Source

Generates a syntax-highlighted HTML string representing a property signature for display.

Parameters

  • propertyThe property declaration syntax.

Returns

An HTML fragment containing the highlighted signature.

Method

GetPropertyAccessorSignature

string GetPropertyAccessorSignature(PropertyDeclarationSyntax property) Source

Computes the accessors (get/set/init) for a property as a string for inclusion in signatures.

Parameters

  • propertyThe property declaration syntax.

Returns

A string like "{ get; set; }" or "{ get; }".

Method

AppendHighlightedParameter

void AppendHighlightedParameter(StringBuilder builder, ParameterSyntax parameter) Source

Appends a syntax-highlighted parameter declaration to the provided StringBuilder.

Parameters

  • builderThe StringBuilder to append to.
  • parameterThe parameter declaration syntax.
Method

GetDisplayTypeName

string GetDisplayTypeName(TypeDeclarationSyntax typeDecl) Source

Gets the display name for a type declaration, including generic type parameter placeholders (e.g., <T>).

Parameters

  • typeDeclThe type declaration syntax.

Returns

The display name string.

Method

GetTypeNameForQualifiedId

string GetTypeNameForQualifiedId(TypeDeclarationSyntax typeDecl) Source

Gets the type name for a qualified ID, appending backtick arity for generic types (e.g., MyType`1).

Parameters

  • typeDeclThe type declaration syntax.

Returns

The type name string used in safe IDs.

Method

IsCompilerGeneratedCallerParameter

bool IsCompilerGeneratedCallerParameter(ParameterSyntax parameter) Source

Determines whether a parameter is a compiler-generated caller information parameter (e.g., [CallerFilePath]).

Parameters

  • parameterThe parameter declaration syntax.

Returns

true if the parameter should be hidden from documentation; otherwise, false.

Method

ExtractDoc

string? ExtractDoc(SyntaxNode node) Source

Extracts XML documentation from the leading trivia of a syntax node and converts it into HTML fragments.

Parameters

  • nodeThe syntax node whose leading XML documentation comments will be parsed.

Returns

The HTML string containing structured documentation sections, or null if no documentation is present or parsing fails.

Method

AppendTextSection

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.

Parameters

  • 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.
Method

AppendNamedListSection

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.

Parameters

  • 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.
Method

RenderBlockContent

string RenderBlockContent(XElement element) Source

Renders the content of an XElement as block-level HTML (wrapping in paragraphs if necessary).

Parameters

  • elementThe XElement to render.

Returns

An HTML fragment string.

Method

RenderInlineContent

string RenderInlineContent(XElement element) Source

Renders the content of an XElement as inline HTML.

Parameters

  • elementThe XElement to render.

Returns

An HTML fragment string.

Method

RenderNodes

string RenderNodes(IEnumerable<XNode> nodes, bool inlineContext) Source

Renders a collection of XML nodes into HTML strings.

Parameters

  • nodesThe nodes to render.
  • inlineContextIndicates whether rendering occurs in an inline context (affects paragraph handling).

Returns

The combined HTML string.

Method

RenderNode

string RenderNode(XNode node, bool inlineContext) Source

Renders a single XML node into its corresponding HTML fragment.

Parameters

  • nodeThe node to render.
  • inlineContextIndicates whether rendering occurs in an inline context.

Returns

The HTML fragment string.

Method

NormalizeWhitespace

string NormalizeWhitespace(string value) Source

Normalizes whitespace in the provided string by replacing all whitespace sequences with a single space.

Parameters

  • valueThe string to normalize.

Returns

The normalized string.

Method

AddOutlineItem

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.

Parameters

  • namespacePageThe namespace page receiving the outline item.
  • titleThe reader-facing outline title.
  • idThe fragment identifier for the rendered documentation section.
  • levelThe normalized outline level.
Method

SimplifyCref

string? SimplifyCref(string? cref) Source

Simplifies a "cref" attribute value by removing the type prefix (e.g., "M:", "T:").

Parameters

  • crefThe cref value to simplify.

Returns

The simplified string, or null if the input was empty.

Method

IsCompilerGeneratedDocParameter

bool IsCompilerGeneratedDocParameter(string? parameterName) Source

Determines whether a parameter name corresponds to a compiler-generated caller information parameter.

Parameters

  • parameterNameThe name of the parameter to check.

Returns

true if it is a compiler-generated parameter; otherwise, false.

Method

GetOrCreateNamespacePage

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.

Parameters

  • namespacePagesThe dictionary of existing pages.
  • namespaceNameThe dotted namespace name.

Returns

The retrieved or newly created page.

Method

EnsureNamespaceHierarchy

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.

Parameters

  • namespacePagesThe dictionary containing all unique namespace pages encountered during harvesting.
Method

GetNamespaceName

string GetNamespaceName(SyntaxNode node) Source

Extracts the dotted namespace name for a given syntax node by traversing its ancestors.

Parameters

  • nodeThe syntax node to process.

Returns

The full dotted namespace name, or "Global" if none is found.

Method

BuildNamespaceDocPath

string BuildNamespaceDocPath(string namespaceName) Source

Constructs the relative documentation route path for a given namespace name.

Parameters

  • namespaceNameThe dotted namespace name.

Returns

The relative route path string (e.g., "Namespaces/MyNamespace").

Method

GetNamespaceTitle

string GetNamespaceTitle(string fullNamespace) Source

Derives a display title for a namespace name.

Parameters

  • fullNamespaceThe dotted namespace name.

Returns

The display title; returns the last segment of the namespace or "Namespaces" for the root.

Method

GetParentNamespace

string GetParentNamespace(string namespaceName) Source

Gets the parent namespace name for a dotted namespace string.

Parameters

  • namespaceNameThe dotted namespace name.

Returns

The parent namespace name, or an empty string if it is a root namespace.

Method

GetQualifiedName

string GetQualifiedName(BaseTypeDeclarationSyntax node) Source

Builds the dot-delimited qualified name for a type or enum declaration, including enclosing types and namespaces.

Parameters

  • nodeThe type or enum declaration syntax node to compute the qualified name for.

Returns

The qualified name as a dot-delimited string containing nested type and namespace segments.

Type

NamespaceDocPage

Source

Represents a single documentation page for a C# namespace, accumulating content from types within it.

Type

DocRouteIdentityCatalog

Source

Owns the route identity contract for one cached RazorDocs snapshot.

Remarks

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.

Type

DocMetadataFactory

Source

Builds normalized RazorDocs metadata defaults and fallbacks for harvested documentation nodes.

Method

CreateMarkdownMetadata

2 overloads
DocMetadata CreateMarkdownMetadata(string path, string resolvedTitle, DocMetadata? explicitMetadata, string? derivedSummary) Source

Creates normalized metadata for a Markdown documentation node without emitting normalization warnings.

Parameters

  • 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.

Returns

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.

Parameters

  • 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.

Returns

The merged metadata with normalized section labels, fallback breadcrumbs, and derived-field flags.

Remarks

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.

Method

CreateApiReferenceMetadata

DocMetadata CreateApiReferenceMetadata(string title, string namespaceName) Source

Creates canonical metadata for an API-reference documentation node.

Parameters

  • titleThe display title for the API node.
  • namespaceNameThe owning namespace used for component inference and breadcrumb generation.

Returns

Metadata configured for API-reference navigation, contributor visibility, and namespace breadcrumbs.

Method

DeriveComponentFromPath

string? DeriveComponentFromPath(string path) Source

Derives the owning AppSurface component name from a documentation path when possible.

Parameters

  • pathThe documentation path whose segments should be inspected.

Returns

The inferred component name, or null when no component hint can be derived.

Method

DeriveComponentFromNamespace

string? DeriveComponentFromNamespace(string namespaceName) Source

Derives the owning AppSurface component name from a namespace.

Parameters

  • namespaceNameThe namespace to inspect.

Returns

The inferred component name, or null when the namespace is blank.

Type

HarvestPathExclusions

Source
Method

ShouldExcludeFilePath

2 overloads
bool ShouldExcludeFilePath(string filePath) Source

Determines whether a documentation file should be excluded from harvesting based on its path segments.

Parameters

  • filePathThe relative file path to check.

Returns

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.

Parameters

  • 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).

Returns

true if the file should be excluded; otherwise, false.

Type

RazorDocsCodeBlock

Source

Represents the authored Markdown code-fence input that RazorDocs can render as highlighted or plain code.

Parameters

  • 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.

Remarks

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.

Type

IRazorDocsCodeHighlighter

Source

Highlights Markdown code fences behind RazorDocs' internal HTML contract.

Method

Highlight

RazorDocsHighlightedCode Highlight(RazorDocsCodeBlock block) Source

Renders a code block as either highlighted token markup or escaped plaintext fallback.

Parameters

  • blockThe code block to render.

Returns

RazorDocs-owned code block HTML.

Type

DocPathResolver

Source

Resolves authored, source, and canonical RazorDocs paths against a harvested documentation corpus.

Remarks

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.

Method

Create

DocPathResolver Create(IEnumerable<DocNode> docs) Source

Builds a resolver for a docs snapshot.

Parameters

  • docsThe harvested docs whose source and canonical paths should be resolvable.

Returns

A resolver that can match source paths, canonical route paths, and route-relative variants.

Method

Resolve

2 overloads
DocNode? Resolve(string path) Source

Resolves a path exactly as authored, using RazorDocs source and canonical matching rules.

Parameters

  • pathThe authored source or canonical path to resolve.

Returns

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.

Parameters

  • pathThe authored or browser-facing path to resolve.
  • routeRootPathsRoute roots, such as the configured live docs root and the stable /docs root.

Returns

The best matching doc node, or null when neither route-relative variants nor the original path match.

Method

NormalizeLookupPath

string NormalizeLookupPath(string path) Source

Normalizes a documentation path for lookup by trimming route separators and removing fragment anchors.

Parameters

  • pathThe path to normalize.

Returns

The normalized lookup path.

Method

NormalizeCanonicalPath

string NormalizeCanonicalPath(string path) Source

Normalizes a documentation path for canonical comparison by trimming route separators while preserving fragments.

Parameters

  • pathThe path to normalize.

Returns

The normalized canonical path.

Method

GetFragment

string? GetFragment(string path) Source

Extracts a fragment from a documentation path after canonical normalization.

Parameters

  • pathThe path that may contain a fragment anchor.

Returns

The fragment without the leading #, or null when no non-empty fragment exists.

Type

RazorDocsHeadingSuppressor

Source

Applies page-shell heading rules to harvested documentation HTML at render time.

Method

SuppressLeadingMarkdownH1

string SuppressLeadingMarkdownH1(string content, bool shellOwnsH1) Source

Removes the leading rendered Markdown h1 element when the details page shell already renders the page H1.

Parameters

  • 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.

Returns

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.

Remarks

Only the leading H1 is suppressed. Later H1 elements remain visible because they are authored body structure, not duplicated page chrome.

Type

RazorDocsVersionCatalogService

Source

Loads, validates, and resolves the configured RazorDocs version catalog.

Remarks

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.

Method

GetCatalog

RazorDocsResolvedVersionCatalog GetCatalog() Source

Returns the resolved version catalog for the current host.

Returns

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.

Type

RazorDocsResolvedVersionCatalog

Source

Represents the resolved version catalog used by the current host.

Parameters

  • 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.

Remarks

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.

Method

CreateUnavailable

RazorDocsResolvedVersionCatalog CreateUnavailable(string? catalogPath) Source

Creates an enabled catalog result with no available versions because the backing catalog could not be used.

Parameters

  • catalogPathThe resolved catalog path to surface with the unavailable sentinel. This is usually an absolute filesystem path, but can also be the normalized configured value when resolution failed before an absolute path could be constructed.

Returns

An enabled-but-unavailable catalog result.

Property

Disabled

RazorDocsResolvedVersionCatalog Disabled { get; } Source

Gets the sentinel catalog result for hosts where versioning is disabled entirely.

Property

EnabledWithoutCatalog

RazorDocsResolvedVersionCatalog EnabledWithoutCatalog { get; } Source

Gets the sentinel catalog result for hosts where versioning is enabled but no catalog path was configured.

Property

PublicVersions

IReadOnlyList<RazorDocsResolvedVersion> PublicVersions { get; } Source

Gets the public versions that should appear in the archive.

Remarks

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.

Type

RazorDocsResolvedVersion

Source

Represents one resolved published docs version and its runtime availability.

Parameters

  • 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.
Enum

RazorDocsResolvedVersionCatalogStatus

Source

Describes how the current host resolved its published-version catalog state.

Remarks

Numeric values are explicit and stable because callers may serialize or persist catalog-resolution state across process boundaries.

Type

RazorDocsPublishedTreeHandler

Source

Serves one or more published RazorDocs trees from static export artifacts.

Remarks

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.

Method

TryHandleAsync

Task<bool> TryHandleAsync(HttpContext httpContext) Source

Attempts to serve the current request from one of the configured published trees.

Parameters

  • httpContextThe current HTTP request context.

Returns

true when a published tree handled the request; otherwise false.

Type

RazorDocsPublishedTreeMount

Source

Describes one published exact-version tree that should be mounted into the active host.

Parameters

  • MountRootPathThe request-path root where the tree should appear.
  • FileProviderThe static file provider for the tree contents.

Remarks

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.

Type

RazorDocsPublishedTreeContentRewriter

Source

Rewrites stable-root published-tree content so the same artifact can be served from different mount roots.

Remarks

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.

Method

RewriteHtml

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.

Parameters

  • 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.

Returns

The rewritten HTML document.

Remarks

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.

Method

RewriteSearchIndexJson

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.

Parameters

  • 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.

Returns

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.

Remarks

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.

Type

MarkdownFrontMatterParser

Source
Method

Extract

(string Markdown, DocMetadata? Metadata) Extract(string markdown) Source

Extracts inline Markdown front matter and returns the remaining Markdown with parsed metadata.

Parameters

  • markdownThe Markdown source that may begin with YAML front matter.

Returns

A tuple containing the Markdown body and parsed DocMetadata when present and valid.

Remarks

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.

Method

ExtractWithDiagnostics

(string Markdown, MarkdownMetadataParseResult Result) ExtractWithDiagnostics(string markdown) Source

Extracts inline Markdown front matter and returns the remaining Markdown with diagnostics-aware metadata.

Parameters

  • markdownThe Markdown source that may begin with YAML front matter.

Returns

A tuple containing the Markdown body and a MarkdownMetadataParseResult whose MarkdownMetadataParseResult.Metadata contains parsed DocMetadata when present.

Remarks

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.

Method

ParseMetadataYaml

DocMetadata? ParseMetadataYaml(string yaml) Source

Parses a YAML metadata document into normalized documentation metadata.

Parameters

  • yamlThe raw YAML content to deserialize.

Returns

The normalized metadata model, or null when the YAML document is empty or explicitly null.

Exceptions

  • YamlExceptionThrown when yaml cannot be parsed as YAML.

Remarks

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.

Method

ParseMetadataYamlWithDiagnostics

MarkdownMetadataParseResult ParseMetadataYamlWithDiagnostics(string yaml) Source

Parses a YAML metadata document into a diagnostics-aware metadata result.

Parameters

  • yamlThe raw YAML metadata document to deserialize.

Returns

A MarkdownMetadataParseResult containing optional normalized DocMetadata plus any RazorDocsMetadataDiagnostic warnings produced while normalizing supported metadata fields.

Remarks

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.

Type

RazorDocsHarvestFailurePreflightService

Source

Performs the optional strict RazorDocs harvest-health startup preflight.

Remarks

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.

Method

StartAsync

Task StartAsync(CancellationToken cancellationToken) Source

Checks harvest health during host startup when strict harvest failure is enabled.

Parameters

  • cancellationTokenToken observed while waiting for the cached harvest-health snapshot.

Returns

A completed task when strict mode is disabled or the aggregate status is not failed.

Exceptions

  • RazorDocsHarvestFailedExceptionThrown when RazorDocsHarvestOptions.FailOnFailure is enabled and the aggregate harvest status is DocHarvestHealthStatus.Failed.
Method

StopAsync

Task StopAsync(CancellationToken cancellationToken) Source

Stops the preflight service.

Parameters

  • cancellationTokenUnused cancellation token supplied by the host.

Returns

A completed task because the preflight owns no background work.

Type

RazorDocsHarvestHealthVisibility

Source

Resolves environment-aware visibility for RazorDocs harvest health routes and sidebar chrome.

Method

AreRoutesExposed

bool AreRoutesExposed(RazorDocsOptions options, IHostEnvironment environment) Source

Resolves whether the harvest health controller routes should be registered or allowed for the current host.

Remarks

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.

Method

ShouldShowChrome

bool ShouldShowChrome(RazorDocsOptions options, IHostEnvironment environment) Source

Resolves whether the sidebar should show harvest health chrome for the current host.

Remarks

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.

Type

RazorDocsCodeBlockMarkdownExtension

Source

Registers RazorDocs' fenced-code renderer with Markdig.

Method

CreateDefaultHighlighter

IRazorDocsCodeHighlighter CreateDefaultHighlighter(ILogger<TextMateSharpRazorDocsCodeHighlighter> logger) Source

Creates the default TextMateSharp-backed RazorDocs highlighter.

Parameters

  • loggerLogger used to emit diagnostics when grammar loading or highlighting falls back.

Returns

The default RazorDocs code highlighter.

Type

RazorDocsCodeBlockRenderer

Source

Renders Markdown fenced code blocks through RazorDocs' highlighter contract.

Method

ExtractLanguage

string? ExtractLanguage(FencedCodeBlock block) Source

Extracts the first language token from a fenced code block's info string.

Parameters

  • blockThe fenced code block to inspect.

Returns

The first language token, or null when the fence has no info string.

Type

RazorDocsMetadataDiagnostic

Source

Describes one non-fatal RazorDocs metadata authoring problem discovered while parsing or normalizing metadata.

Parameters

  • 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.
Type

MarkdownMetadataParseResult

Source

Carries normalized metadata together with non-fatal diagnostics from a Markdown metadata parse.

Parameters

  • MetadataThe parsed metadata, or null when no usable metadata document was present.
  • DiagnosticsWarnings produced while parsing or normalizing metadata fields.
Type

DocFeaturedPageResolver

Source

Resolves authored reader-intent landing curation metadata into browser-facing RazorDocs featured-page groups.

Remarks

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.

Method

ResolveGroups

IReadOnlyList<DocLandingFeaturedPageGroupViewModel> ResolveGroups(DocNode? landingDoc, IReadOnlyList<DocNode> docs) Source

Resolves grouped featured-page metadata from landingDoc against the harvested docs corpus.

Parameters

  • 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.

Returns

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.

Type

RazorDocsHtmlSanitizer

Source

Sanitizes harvested RazorDocs HTML with the package-owned allowlist for docs content and highlighted code blocks.

Remarks

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.

Method

Sanitize

string Sanitize(string html) Source

Sanitizes rendered documentation HTML using the RazorDocs allowlist.

Parameters

  • htmlThe rendered HTML to sanitize.

Returns

Safe HTML that preserves RazorDocs structural markup and removes unsupported tags or attributes.

Type

RazorDocsCodeLanguage

Source

Describes RazorDocs' normalized view of an authored code-fence language token.

Parameters

  • 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.
Type

DocsUrlBuilder

Source

Builds canonical RazorDocs URLs for one RazorDocs route family.

Remarks

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.

Method

BuildHomeUrl

string BuildHomeUrl() Source

Builds the current live docs home URL.

Returns

The current docs home path.

Method

BuildSearchUrl

string BuildSearchUrl() Source

Builds the current live docs search workspace URL.

Returns

The app-relative search workspace URL for the current docs surface.

Method

BuildSearchIndexUrl

string BuildSearchIndexUrl() Source

Builds the current live docs search-index URL.

Returns

The app-relative search-index URL for the current docs surface.

Method

BuildSearchIndexRefreshUrl

string BuildSearchIndexRefreshUrl() Source

Builds the current live docs search-index refresh URL.

Returns

The app-relative authenticated refresh URL for the current docs search index.

Method

BuildHealthUrl

string BuildHealthUrl() Source

Builds the current live docs harvest health HTML URL.

Returns

The app-relative health page URL for the current docs surface.

Method

BuildHealthJsonUrl

string BuildHealthJsonUrl() Source

Builds the current live docs harvest health JSON URL.

Returns

The app-relative machine-readable health URL for the current docs surface.

Method

BuildSectionUrl

string BuildSectionUrl(DocPublicSection section) Source

Builds a current-surface public section URL.

Parameters

  • sectionThe section whose route should be built.

Returns

The canonical section URL rooted at the current docs surface.

Method

BuildDocUrl

2 overloads
string BuildDocUrl(string path) Source

Builds a current-surface canonical document URL.

Parameters

  • pathThe source or canonical documentation path.

Returns

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.

Parameters

  • docsRootPathThe app-relative docs root path.
  • pathThe source or canonical documentation path.

Returns

The canonical document URL.

Method

BuildAssetUrl

string BuildAssetUrl(string assetName) Source

Builds the current-surface search asset URL.

Parameters

  • assetNameThe asset file name, such as search.css.

Returns

The canonical asset URL rooted at the current docs surface.

Method

BuildVersionRootUrl

string BuildVersionRootUrl(string version) Source

Builds the exact-version root URL for one published docs release.

Parameters

  • versionThe exact published version identifier.

Returns

The canonical root URL for that version.

Method

BuildVersionDocUrl

string BuildVersionDocUrl(string version, string path) Source

Builds a canonical document URL rooted at a specific exact version.

Parameters

  • versionThe exact published version identifier.
  • pathThe source or canonical documentation path.

Returns

The canonical document URL rooted at the requested version.

Method

BuildVersionsUrl

string BuildVersionsUrl() Source

Builds the public archive URL.

Returns

The stable archive URL.

Method

IsCurrentDocsPath

bool IsCurrentDocsPath(string? path) Source

Determines whether the supplied request path is inside the current live docs surface.

Parameters

  • pathThe request path to check.

Returns

true when the path belongs to the current live docs surface; otherwise false.

Method

IsUnderRoot

bool IsUnderRoot(string? path, string docsRootPath) Source

Determines whether a request path belongs to the supplied docs root.

Parameters

  • pathThe incoming request path to evaluate.
  • docsRootPathThe normalized docs root path configured for the live docs surface.

Returns

true when path resolves to the docs root itself or one of its child routes; otherwise false.

Remarks

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}/....

Method

JoinPath

string JoinPath(string docsRootPath, string relativePath) Source

Joins a normalized docs root with a relative docs route segment.

Parameters

  • docsRootPathThe normalized app-relative docs root path.
  • relativePathThe relative docs route to append.

Returns

The combined app-relative route path.

Remarks

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.

Method

NormalizeDocsRootPath

string NormalizeDocsRootPath(string? docsRootPath, bool versioningEnabled) Source

Normalizes a configured docs root into the app-relative route contract RazorDocs uses at runtime.

Parameters

  • 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.

Returns

The normalized app-relative docs root path.

Method

NormalizeRouteRootPath

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.

Parameters

  • 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.

Returns

The normalized app-relative route-family root path.

Property

VersioningEnabled

bool VersioningEnabled { get; } Source

Gets a value indicating whether versioning is enabled for the current host.

Property

CurrentDocsRootPath

string CurrentDocsRootPath { get; } Source

Gets the canonical root path for the current live source-backed docs surface.

Property

RouteRootPath

string RouteRootPath { get; } Source

Gets the stable route-family root for this RazorDocs instance.

Remarks

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.

Property

DocsEntryRootPath

string DocsEntryRootPath { get; } Source

Gets the docs entry path used as the stable public landing alias.

Property

DocsVersionPrefixPath

string DocsVersionPrefixPath { get; } Source

Gets the stable exact-version prefix for this route family.

Property

DocsVersionsRootPath

string DocsVersionsRootPath { get; } Source

Gets the stable archive path for this route family.

Property

Routes

RazorDocsRouteReferences Routes { get; } Source

Gets named RazorDocs routes that consumers should prefer over hardcoded route strings.

Type

RazorDocsRouteReferences

Source

Named RazorDocs routes for one configured route family.

Remarks

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.

Method

Deconstruct

2 overloads
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.

Parameters

  • 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.

Parameters

  • 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.
Property

Home

string Home { get; init; } Source

Gets the current live docs home route.

Property

Search

string Search { get; init; } Source

Gets the current live docs search workspace route.

Property

SearchIndex

string SearchIndex { get; init; } Source

Gets the current live docs search-index JSON route.

Property

SearchIndexRefresh

string SearchIndexRefresh { get; init; } Source

Gets the authenticated search-index refresh route.

Property

Versions

string Versions { get; init; } Source

Gets the route-family archive route, whether or not versioning endpoints are currently enabled.

Property

Health

string Health { get; init; } Source

Gets the current live docs harvest health HTML route.

Property

HealthJson

string HealthJson { get; init; } Source

Gets the current live docs harvest health JSON route.

Type

MarkdownHarvester

Source

Harvester implementation that scans Markdown source files and converts them into documentation nodes.

Method

HarvestAsync

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.

Parameters

  • rootPathThe root directory to search recursively for `.md` files and an optional root `LICENSE` file.
  • cancellationTokenAn optional token to observe for cancellation requests.

Returns

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.

Remarks

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.

Method

ReadMetadataSidecarAsync

Task<DocMetadata?> ReadMetadataSidecarAsync(string markdownFilePath, string relativeMarkdownPath, CancellationToken cancellationToken) Source

Reads an optional paired sidecar metadata file for a Markdown source document.

Parameters

  • markdownFilePathThe absolute Markdown file path.
  • relativeMarkdownPathThe Markdown file path relative to the harvest root.
  • cancellationTokenA token that can cancel sidecar discovery or file reads.

Returns

The parsed sidecar metadata, or null when no valid sidecar applies.

Remarks

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.

Method

ExtractOutline

IReadOnlyList<DocOutlineItem> ExtractOutline(MarkdownDocument document) Source

Extracts page-local outline entries from Markdown heading blocks.

Parameters

  • documentThe parsed Markdown document whose heading blocks should be inspected.

Returns

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.

Remarks

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.

Method

ExtractLeadingTitle

string? ExtractLeadingTitle(MarkdownDocument document) Source

Extracts the document title from a leading Markdown H1 when one exists.

Parameters

  • documentThe parsed Markdown document whose first block may be a page-title H1.

Returns

The normalized heading text from the leading H1, or null when the document starts with another block or the H1 has no readable text.

Remarks

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.

Method

ExtractInlineText

string ExtractInlineText(ContainerInline? inline) Source

Extracts plain reader-facing text from a Markdig inline container for outline display.

Parameters

  • inlineThe inline container to flatten.

Returns

The extracted text, or an empty string when no inline content exists.

Method

NormalizeHeadingText

string NormalizeHeadingText(string value) Source

Normalizes heading text by collapsing whitespace without introducing leading spaces.

Parameters

  • valueThe raw heading text.

Returns

The normalized heading text.

Type

DocLinkTargetManifest

Source

Enumerates the documentation targets harvested into a RazorDocs snapshot so link rewriting can avoid guessing from file extensions alone.

Remarks

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.

Method

FromNodes

DocLinkTargetManifest FromNodes(IEnumerable<DocNode> nodes) Source

Creates a manifest from harvested documentation nodes.

Parameters

  • nodesThe harvested documentation nodes that may be linked through RazorDocs routes.

Returns

A manifest containing source and canonical target forms for the supplied nodes.

Method

FromPaths

DocLinkTargetManifest FromPaths(IEnumerable<string?> paths) Source

Creates a manifest from source or canonical documentation paths.

Parameters

  • pathsThe documentation paths to register as known link targets.

Returns

A manifest containing normalized source and canonical target forms.

Method

Contains

bool Contains(string? path) Source

Determines whether the supplied path resolves to a harvested documentation target.

Parameters

  • pathA source or canonical documentation path, optionally rooted, queried, or fragmented.

Returns

true when the normalized target is in the manifest; otherwise false.

Type

DocRoutePath

Source

Normalizes harvested non-Markdown source paths into legacy browser-facing routes used by RazorDocs.

Remarks

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.

Method

BuildCanonicalPath

string BuildCanonicalPath(string sourcePath) Source

Constructs a legacy browser-facing path for a harvested non-Markdown documentation source path.

Parameters

  • sourcePathThe harvested source path, optionally including a fragment.

Returns

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.

Remarks

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.

Type

IRazorDocsHtmlSanitizer

Source

Sanitizes rendered RazorDocs HTML using the package's docs-specific allowlist.

Remarks

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.

Method

Sanitize

string Sanitize(string html) Source

Sanitizes the provided HTML fragment.

Parameters

  • htmlThe rendered RazorDocs HTML fragment to sanitize.

Returns

The sanitized HTML fragment.

Remarks

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.

Type

RazorDocsCodeLanguageCatalog

Source

Owns Markdown code-fence language normalization, safe CSS class suffixes, and TextMateSharp lookup ids.

Method

Normalize

RazorDocsCodeLanguage Normalize(string? language) Source

Normalizes an authored language token into RazorDocs' stable language contract.

Parameters

  • languageThe raw first info-string token.

Returns

A safe language descriptor for rendering and TextMate lookup.

Method

CreateSafeClassSlug

string CreateSafeClassSlug(string value) Source

Converts arbitrary language input into a CSS-safe lowercase ASCII slug.

Parameters

  • valueThe value to slug.

Returns

A lowercase slug containing only ASCII letters, digits, and hyphens.

Type

TextMateSharpRazorDocsCodeHighlighter

Source

TextMateSharp-backed implementation of RazorDocs' internal code-block highlighting contract.

Method

LoadGrammar

IGrammar? LoadGrammar(RazorDocsCodeLanguage language) Source

Loads the TextMate grammar for a normalized language, returning null when no grammar exists.

Parameters

  • languageThe normalized language descriptor.

Returns

The loaded grammar, or null when the language has no TextMate scope.

Method

AppendTokens

void AppendTokens(StringBuilder builder, string line, IReadOnlyList<IToken> tokens) Source

Appends a tokenized source line while preserving unclassified gaps and trailing text.

Parameters

  • builderThe destination HTML builder.
  • lineThe original source line.
  • tokensTextMate tokens for the line.
Method

ResolveTokenClass

string? ResolveTokenClass(IReadOnlyList<string> scopes) Source

Maps TextMate scopes to RazorDocs' small semantic token vocabulary.

Parameters

  • scopesThe scopes attached to a TextMate token.

Returns

The RazorDocs token modifier, or null for unstyled scopes.

Type

DocsSearchIndexPayload

Source

Cached search-index payload for the live source-backed docs surface.

Parameters

  • MetadataStatic metadata emitted alongside the indexed documents.
  • DocumentsSearchable docs entries in the shape consumed by the built-in MiniSearch client.
Type

DocsSearchIndexMetadata

Source

Metadata emitted with each docs search-index payload.

Parameters

  • GeneratedAtUtcUTC timestamp for when the snapshot was generated.
  • VersionSchema version understood by the search client.
  • EngineClient-side search engine identifier.
Type

DocsSearchIndexDocument

Source

Search document entry emitted for the built-in docs search experience.

Parameters

  • 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.

Remarks

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.

Type

DocAggregator

Source

Service responsible for aggregating documentation from multiple harvesters and caching the results.

Method

GetDocsAsync

Task<IReadOnlyList<DocNode>> GetDocsAsync(CancellationToken cancellationToken = default) Source

Retrieves all harvested documentation nodes sorted by their Path.

Parameters

  • cancellationTokenAn optional token to observe for cancellation requests.

Returns

A read-only list of all DocNode objects ordered by their Path.

Method

GetHarvestHealthAsync

Task<DocHarvestHealthSnapshot> GetHarvestHealthAsync(CancellationToken cancellationToken = default) Source

Returns structured health for the current RazorDocs harvest snapshot.

Parameters

  • cancellationTokenAn optional token to observe while waiting for the cached snapshot.

Returns

Structured harvest health that distinguishes valid empty docs from failed or degraded harvests.

Remarks

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.

Method

GetDocByPathAsync

Task<DocNode?> GetDocByPathAsync(string path, CancellationToken cancellationToken = default) Source

Retrieves a documentation node for a source path or canonical docs path.

Parameters

  • pathThe source or canonical documentation path to look up.
  • cancellationTokenAn optional token to observe while waiting for the cached snapshot.

Returns

The matching DocNode, or null if no node exists for the given path.

Remarks

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.

Method

ResolvePublicRouteAsync

Task<DocRouteResolution> ResolvePublicRouteAsync(string path, CancellationToken cancellationToken = default) Source

Resolves a requested browser-facing docs route against the current snapshot route catalog.

Parameters

  • 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.

Returns

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.

Remarks

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.

Method

GetDocDetailsAsync

Task<DocDetailsViewModel?> GetDocDetailsAsync(string path, CancellationToken cancellationToken = default) Source

Builds the typed details view model for the specified documentation page.

Parameters

  • pathThe documentation path to resolve.
  • cancellationTokenAn optional token to observe for cancellation requests.

Returns

A DocDetailsViewModel containing the resolved page, its in-page outline, and wayfinding links, or null when the page cannot be resolved.

Method

GetSearchIndexPayloadAsync

Task<DocsSearchIndexPayload> GetSearchIndexPayloadAsync(CancellationToken cancellationToken = default) Source

Returns the docs search-index payload generated during docs aggregation.

Parameters

  • cancellationTokenAn optional token to observe for cancellation requests.

Returns

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.

Method

GetPublicSectionsAsync

Task<IReadOnlyList<DocSectionSnapshot>> GetPublicSectionsAsync(CancellationToken cancellationToken = default) Source

Returns the normalized public-section snapshots derived from the harvested docs corpus.

Parameters

  • cancellationTokenAn optional token to observe for cancellation requests.

Returns

The ordered public sections visible in the current docs snapshot.

Method

GetPublicSectionAsync

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.

Parameters

  • sectionThe public section to resolve.
  • cancellationTokenAn optional token to observe for cancellation requests.

Returns

The matching section snapshot, or null when the section has no visible public pages.

Method

InvalidateCache

void InvalidateCache() Source

Invalidates the cached docs snapshot so docs and search-index are rebuilt on next access.

Method

GetCachedDocsSnapshotAsync

Task<CachedDocsSnapshot> GetCachedDocsSnapshotAsync() Source

Retrieves the cached docs snapshot, harvesting docs and generating the search-index payload when absent.

Returns

A cached snapshot containing both docs and search-index payload.

Remarks

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.

Method

ResolveGitLastUpdatedUtcAsync

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.

Parameters

  • 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.

Returns

The exact last-updated UTC timestamp when git returns a parseable ISO 8601 commit date; otherwise null.

Method

BuildPublicSections

IReadOnlyList<DocSectionSnapshot> BuildPublicSections(IEnumerable<DocNode> docs, ILogger logger) Source

Builds the public-section snapshots from the harvested docs corpus.

Parameters

  • docsThe harvested docs to classify.
  • loggerLogger used for section-landing conflict warnings.

Returns

The ordered public sections that have at least one visible page.

Method

BuildSearchIndexPayload

(DocsSearchIndexPayload Payload, int RecordCount) BuildSearchIndexPayload(IEnumerable<DocNode> docs, IReadOnlyList<DocSectionSnapshot> publicSections, DocRouteIdentityCatalog routeIdentityCatalog) Source

Builds the search-index payload from the harvested documentation nodes.

Parameters

  • docsThe documentation nodes to index.
  • publicSectionsThe resolved public sections used to derive landing winners.
  • routeIdentityCatalogThe snapshot route catalog used to emit public canonical paths.

Returns

A tuple containing the serializable payload and the number of records indexed.

Method

NormalizeSearchText

string NormalizeSearchText(string? text) Source

Decodes HTML entities and normalizes whitespace in the provided text for search indexing.

Parameters

  • textThe text to normalize.

Returns

The normalized text.

Method

BuildSearchDocUrl

2 overloads
string BuildSearchDocUrl(string path) Source

Constructs a browser-facing URL for a documentation path.

Parameters

  • pathThe relative documentation path.

Returns

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.

Parameters

  • docsRootPathThe app-relative docs root path.
  • pathThe relative documentation path.

Returns

A URL string rooted at docsRootPath.

Method

TruncateSnippetAtWordBoundary

string TruncateSnippetAtWordBoundary(string text, int maxLength) Source

Truncates a text snippet at the last word boundary before the maximum length is exceeded.

Parameters

  • textThe text to truncate.
  • maxLengthThe maximum allowed length of the snippet.

Returns

The truncated text with an ellipsis if it was shortened.

Method

MergeNamespaceReadmes

void MergeNamespaceReadmes(List<DocNode> nodes) Source

Merges README content into the corresponding namespace overview pages.

Parameters

  • nodesThe list of documentation nodes to process; README nodes used for merging are removed from this list.
Method

MergeNamespaceIntroIntoContent

string MergeNamespaceIntroIntoContent(string namespaceContent, string readmeContent) Source

Inserts README content into a namespace overview page after the auto-generated namespace groups.

Parameters

  • 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.

Returns

The merged HTML content, with any leading README H1 omitted from the namespace intro section.

Method

FindMatchingSectionEnd

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.

Parameters

  • contentThe HTML content to search.
  • sectionStartThe starting index of the <section> tag.

Returns

The index of the closing tag, or -1 if no match is found.

Method

IsReadmePath

bool IsReadmePath(string path) Source

Determines whether the specified path points to a documentation README file.

Parameters

  • pathThe path to check.

Returns

true if the path identifies a README.md file; otherwise, false.

Method

ExtractNamespaceNameFromNamespacePath

string ExtractNamespaceNameFromNamespacePath(string path) Source

Extracts the dotted namespace name from a documentation path under the "Namespaces/" directory.

Parameters

  • pathThe path to process.

Returns

The extracted namespace name.

Method

ExtractNamespaceNameFromReadmePath

2 overloads
string? ExtractNamespaceNameFromReadmePath(string path) Source

Attempts to extract a namespace name from a README path by looking at the parent directory name.

Parameters

  • pathThe README path to process.

Returns

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.

Parameters

  • 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.

Returns

The extracted namespace name, or null if it cannot be determined.

Method

HasNamespaceReadmePrefix

bool HasNamespaceReadmePrefix(IReadOnlyList<string> parts, int namespaceStartIndex) Source

Determines whether the matched namespace folder appears in one of the supported namespace README locations.

Parameters

  • partsThe normalized directory path segments that precede README.md.
  • namespaceStartIndexThe index where the matched namespace name begins within parts.

Returns

true when the namespace folder lives under a trusted container like docs or Namespaces; otherwise, false.

Method

NormalizeLookupPath

string NormalizeLookupPath(string path) Source

Normalizes a documentation path for lookup by trimming slashes and removing fragment anchors.

Parameters

  • pathThe path to normalize.

Returns

The normalized lookup path.

Method

GetFragment

string? GetFragment(string path) Source

Extracts the fragment anchor (after the '#') from a documentation path.

Parameters

  • pathThe path to process.

Returns

The fragment string, or null if no fragment is present.

Property

SnapshotCacheDuration

TimeSpan SnapshotCacheDuration { get; } Source

Gets the configured absolute lifetime for the shared docs snapshot cache.

Type

RazorDocsHighlightedCode

Source

Contains RazorDocs-owned HTML for a rendered Markdown code block.

Parameters

  • 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.
Type

DocContentLinkRewriter

Source

Rewrites harvested documentation links so authored Markdown can use repository-relative source links while the rendered docs experience still navigates through canonical RazorDocs routes.

Method

PrefixPathBaseForDocsUrls

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.

Parameters

  • 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.

Returns

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.

Remarks

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.