string? RecommendedVersion { get; set; }
Source
Gets or sets the exact version that should also be exposed through the configured route-family root alias.
Declares the published RazorDocs versions that should be exposed through the version archive and static-tree mounting.
The catalog is the release-level source of truth for version routing and archive presentation. It does not describe individual documentation pages; instead it points at already-exported exact-version trees and records release state such as support posture, visibility, and advisory severity. The runtime validates each published tree independently so one broken version does not take down the whole docs host.
string? RecommendedVersion { get; set; }
Source
Gets or sets the exact version that should also be exposed through the configured route-family root alias.
List<RazorDocsPublishedVersion> Versions { get; set; }
Source
Gets or sets the published versions known to the catalog.
Describes one published RazorDocs release tree.
string Version { get; set; }
Source
Gets or sets the exact published version identifier, such as 0.4.0 or 1.2.3-rc.1.
string? Label { get; set; }
Source
Gets or sets the short reader-facing label for the release.
string? Summary { get; set; }
Source
Gets or sets optional summary copy shown in the version archive.
string? ExactTreePath { get; set; }
Source
Gets or sets the path to the exported exact-version docs subtree.
The directory should contain the static files exported from the stable docs surface for one exact release, such as index.html, search-index.json, section routes, and detail pages. RazorDocs can then mount that same artifact at either RouteRootPath or {RouteRootPath}/v/{version} by rebasing stable-root links at response time. Relative paths resolve from the directory containing the version catalog file.
RazorDocsVersionSupportState SupportState { get; set; }
Source
Gets or sets the support-state badge surfaced in the version archive.
RazorDocsVersionVisibility Visibility { get; set; }
Source
Gets or sets the archive visibility behavior for the release.
RazorDocsVersionAdvisoryState AdvisoryState { get; set; }
Source
Gets or sets the release-level advisory state surfaced beside the version.
Describes the support posture for one published docs release.
Numeric values are explicit and stable because catalog payloads and downstream consumers may serialize or persist these states outside the current process.
Controls whether a published version appears in the public archive and is mounted for static serving.
Numeric values are explicit and stable because catalog payloads and downstream consumers may serialize or persist these states outside the current process.
Describes release-level advisory severity shown in the archive.
Numeric values are explicit and stable because catalog payloads and downstream consumers may serialize or persist these states outside the current process.
Represents configuration for the RazorDocs package and host.
RazorDocsMode Mode { get; set; }
Source
Gets or sets the active docs source mode.
double CacheExpirationMinutes { get; set; }
Source
Gets or sets the absolute docs snapshot cache lifetime in minutes. The default is DefaultCacheExpirationMinutes minutes.
This setting controls the shared aggregation snapshot used by docs pages, public-section data, and the generated search-index payload. Shorter values make source-backed development changes visible sooner, while longer values reduce repeated harvest and search-index generation work in production hosts. The value must be finite, must be between MinCacheExpirationMinutes and MaxCacheExpirationMinutes, and must represent a whole number of seconds because the generated search-index Cache-Control max-age header uses whole-second delta values. Values outside those constraints are rejected during options validation.
RazorDocsSourceOptions Source { get; set; }
Source
Gets source-mode settings used when docs are harvested from a repository checkout.
RazorDocsHarvestOptions Harvest { get; set; }
Source
Gets harvest policy settings used by runtime and export hosts.
RazorDocsBundleOptions Bundle { get; set; }
Source
Gets bundle-mode settings used by future bundle-backed runtime loading.
RazorDocsSidebarOptions Sidebar { get; set; }
Source
Gets sidebar rendering settings.
RazorDocsContributorOptions Contributor { get; set; }
Source
Gets contributor provenance settings used to render source, edit, and freshness evidence on details pages.
RazorDocsRoutingOptions Routing { get; set; }
Source
Gets routing settings that control where the live RazorDocs source surface is exposed.
RazorDocsVersioningOptions Versioning { get; set; }
Source
Gets versioning settings used to mount exact release trees and the archive surface.
Source-mode configuration for RazorDocs.
string? RepositoryRoot { get; set; }
Source
Gets or sets the repository root used for source harvesting. When null, RazorDocs falls back to repository discovery from the content root.
Harvest policy settings for RazorDocs source-backed documentation.
The default policy is tolerant so public runtime hosts can continue serving even when source harvesting has a transient problem. Enable FailOnFailure in CI or export hosts that should fail closed when every configured harvester fails, times out, or cancels.
bool FailOnFailure { get; set; }
Source
Gets or sets a value indicating whether host startup should fail when the aggregate harvest health is ForgeTrust.AppSurface.Docs.Models.DocHarvestHealthStatus.Failed.
Strict mode treats only the aggregate failed state as fatal. Empty docs and degraded partial harvests remain non-fatal in this slice because they can represent intentional empty repositories or still-usable partial docs.
RazorDocsHarvestHealthOptions Health { get; set; }
Source
Gets health-surface settings for the operator-facing RazorDocs harvest health routes and sidebar chrome.
Operator-facing harvest health settings for RazorDocs.
The health surface exposes the same cached harvest state returned by ForgeTrust.AppSurface.Docs.Services.DocAggregator.GetHarvestHealthAsync(System.Threading.CancellationToken). Development hosts show the route response and sidebar chrome by default so local failures are visible immediately. Other environments must opt in explicitly before RazorDocs returns health responses or displays sidebar chrome.
RazorDocsHarvestHealthExposure ExposeRoutes { get; set; }
Source
Gets or sets when RazorDocs should return health responses from {DocsRootPath}/_health and {DocsRootPath}/_health.json.
The default is RazorDocsHarvestHealthExposure.DevelopmentOnly. RazorDocs always reserves these route patterns ahead of the docs catch-all route so they do not fall through to document lookup. Setting this to RazorDocsHarvestHealthExposure.Always allows the controller actions to return operator-facing responses in non-development hosts; protect those responses with host-owned authentication, authorization, or network controls when they are reachable by untrusted users.
RazorDocsHarvestHealthExposure ShowChrome { get; set; }
Source
Gets or sets when RazorDocs should show the harvest health entry in the built-in docs sidebar.
This option is intentionally independent from ExposeRoutes so hosts can expose a machine-readable endpoint without advertising it in the docs chrome, or show local-development chrome without changing non-development route behavior.
Bundle-mode configuration for RazorDocs.
string? Path { get; set; }
Source
Gets or sets the path to the docs bundle payload.
Sidebar presentation settings for RazorDocs.
string[] NamespacePrefixes { get; set; }
Source
Gets or sets configured namespace prefixes for sidebar label simplification.
Contributor-provenance configuration for RazorDocs details pages.
This contract controls the global contributor-provenance surface. Use Enabled to switch the entire feature on or off for a host, and use page-level contributor metadata to suppress or override individual pages without mutating host-wide defaults.
bool Enabled { get; set; }
Source
Gets or sets a value indicating whether contributor provenance rendering is enabled for RazorDocs details pages. Disable this when the host should suppress all contributor affordances, even if page-level overrides or trustworthy source paths exist. When false, RazorDocs also skips contributor-template startup validation because the feature is globally inactive.
string? DefaultBranch { get; set; }
Source
Gets or sets the stable branch name used when expanding configured source and edit URL templates. Required when Enabled is true and either SourceUrlTemplate or EditUrlTemplate is configured, and used as the fallback source ref for symbol links when SourceRef is not configured.
string? SourceUrlTemplate { get; set; }
Source
Gets or sets the source-link template. Supported tokens are {branch} and {path}. Configured templates must include {path} so each page expands to its own source location when Enabled is true.
string? EditUrlTemplate { get; set; }
Source
Gets or sets the edit-link template. Supported tokens are {branch} and {path}. Configured templates must include {path} when Enabled is true. Prefer this when maintainers should land directly in an edit workflow rather than in repository browsing.
string? SymbolSourceUrlTemplate { get; set; }
Source
Gets or sets the source-link template for generated C# API symbols. Supported tokens are {path}, {line}, {branch}, and {ref}. Configured templates must include {path} and {line} when Enabled is true, and unsupported token placeholders are rejected during startup validation. Use {ref} when links should prefer a commit SHA supplied through SourceRef and fall back to DefaultBranch.
string? SourceRef { get; set; }
Source
Gets or sets the source-control ref used for generated C# API symbol links. Prefer a commit SHA when the docs build knows one. When omitted, symbol links that use {ref} fall back to DefaultBranch so hosts can still render moving-branch links intentionally.
RazorDocsLastUpdatedMode LastUpdatedMode { get; set; }
Source
Gets or sets the mode used to resolve contributor freshness. The default is RazorDocsLastUpdatedMode.None so hosts opt into git-backed freshness explicitly instead of paying unexpected snapshot-time git costs. RazorDocsLastUpdatedMode.Git uses local repository history when a trustworthy source path exists and omits only freshness when git data is unavailable or untrustworthy.
Routing settings for the RazorDocs route family and live source surface.
RazorDocs separates the route-family root from the live docs root. RouteRootPath owns stable entry, archive, and exact-version routes. DocsRootPath owns the live source-backed surface used for current docs, search, and the current search-index payload. For a custom versioned host, use values such as RouteRootPath=/foo/bar and DocsRootPath=/foo/bar/next. Both values are normalized into app-relative paths during AddRazorDocs() post-configuration.
string? RouteRootPath { get; set; }
Source
Gets or sets the app-relative route-family root for this RazorDocs instance.
The route root is the parent for stable entry, archive, and exact-version routes. When omitted, it defaults to the live docs root with versioning disabled and to /docs with versioning enabled. Relative-looking values are normalized into app-relative paths. For example, foo/bar becomes /foo/bar. Use / for a single-purpose root-mounted docs host. The normalized path must not end with /, include query or fragment segments, or target reserved child routes such as /foo/bar/versions or /foo/bar/v.
string? DocsRootPath { get; set; }
Source
Gets or sets the app-relative root path for the live source-backed docs surface.
The live root serves current source-backed docs, search, and the current search index. Relative-looking values are normalized into app-relative paths. For example, foo/bar/next becomes /foo/bar/next. When versioning is disabled the default path is the route root. When versioning is enabled the default path is {RouteRootPath}/next, or /docs/next for the default route family. The live root must not collide with the route-family root or its reserved archive/exact-version children when versioning is enabled.
Versioning settings for published RazorDocs release trees.
Enabling versioning turns on the published-release route contract: RazorDocsRoutingOptions.RouteRootPath for the recommended release alias, {RouteRootPath}/v/{version} for immutable exact trees, {RouteRootPath}/versions for the archive, and a live preview surface rooted at RazorDocsRoutingOptions.DocsRootPath. The catalog stays file-based in this slice: runtime consumes a JSON manifest plus prebuilt exact release trees and does not perform Git or bundle resolution at request time. The catalog must describe the recommended version alias plus one or more exact release trees whose exported contents satisfy the exact-tree contract documented in the package README.
bool Enabled { get; set; }
Source
Gets or sets a value indicating whether release-tree versioning is enabled.
string? CatalogPath { get; set; }
Source
Gets or sets the path to the version catalog JSON file.
This property is required when Enabled is true. The catalog describes available exact-version trees, the recommended version alias, and release-level status metadata such as support and advisory state. Relative paths resolve from the app content root. The JSON payload is expected to contain a top-level recommended version plus a versions array whose entries point at exported exact-version trees. A missing, unreadable, or malformed catalog does not crash RazorDocs, but it leaves all published releases unavailable until the catalog can be loaded successfully. When Enabled is true and this property is blank, startup validation fails before the app begins serving requests.
Validates RazorDocsOptions and rejects unsupported or ambiguous startup configurations.
Enumerates the supported RazorDocs content source modes.
Numeric values are part of the public configuration and serialization contract. Do not reorder or renumber existing members; changing these assignments can break persisted configuration, serialized payloads, and consumers. Add new modes by appending members with new explicit values.
Enumerates environment-aware exposure policies for RazorDocs harvest health surfaces.
Numeric values are part of the public configuration and serialization contract. Do not reorder or renumber existing members; changing these assignments can break persisted configuration, serialized payloads, and consumers. Add new modes by appending members with new explicit values.
Enumerates the supported contributor freshness modes for RazorDocs details pages.
Numeric values are part of the public configuration and serialization contract. Do not reorder or renumber existing members; changing these assignments can break persisted configuration, serialized payloads, and consumers. Add new modes by appending members with new explicit values.
Provides Razor view helpers for emitting app-relative RazorDocs links that honor the active request path base.
string PathBaseAware(this IUrlHelper url, string? href)
Source
Rewrites rooted app-relative href values through IUrlHelper.Content(string) so mounted hosts keep their current PathBase, while leaving non-rooted URLs unchanged.
urlThe active URL helper for the rendered view.hrefThe href to normalize for rendering.A path-base-aware href for rooted docs links, the original non-rooted href for relative/external links, or an empty string when href is blank. Protocol-relative URLs such as //cdn.example.com/app.css are preserved as-is so they do not get mistaken for app-relative docs links.
Web module configuration for the RazorDocs documentation system.
This module owns both the live source-backed RazorDocs surface and the optional published-version overlay used when RazorDocsVersioningOptions.Enabled is turned on. Service registration wires up harvesting, aggregation, sanitization, URL generation, and version-catalog resolution through services.AddRazorDocs(), while endpoint and middleware hooks decide whether the host behaves like a plain live docs site or a mixed live-plus-archive experience.
void ConfigureServices(StartupContext context, IServiceCollection services)
Source
Registers services required by the RazorDocs module into the provided service collection.
Adds the RazorDocs harvesting, aggregation, and sanitization services via services.AddRazorDocs(). RazorDocs styling is compiled into the package during the RazorDocs build and the layout resolves the correct static asset path for root-module versus embedded consumer hosts, so hosts do not register services.AddTailwind() just to light up the embedded docs UI.
void RegisterDependentModules(ModuleDependencyBuilder builder)
Source
Registers runtime module dependencies for this web module, including RazorWireWebModule.
builderThe dependency builder used to register required modules.void ConfigureHostBeforeServices(StartupContext context, IHostBuilder builder)
Source
Performs host-level configuration steps before application services are registered.
contextThe startup context providing module and environment information.builderThe host builder to configure prior to service registration.void ConfigureHostAfterServices(StartupContext context, IHostBuilder builder)
Source
Performs host-level configuration steps after application services have been registered.
contextThe startup context providing module and environment information.builderThe host builder to modify or extend after services are configured.void ConfigureWebApplication(StartupContext context, IApplicationBuilder app)
Source
Configures the application's request pipeline and middleware for this module.
contextThe startup context for the module invocation.appThe application builder used to configure middleware and endpoints.This hook only mutates the pipeline when versioning is enabled and the resolved RazorDocsVersionCatalogService yields at least one available published tree. In that case the module mounts exact-version exports, optionally adds the configured route-family root alias for the recommended release, and inserts a short-circuiting middleware branch that lets RazorDocsPublishedTreeHandler serve matching requests before the live preview surface sees them.
(IReadOnlyList<RazorDocsPublishedTreeMount> Mounts, IReadOnlyList<PhysicalFileProvider> Providers) BuildPublishedTreeMounts(RazorDocsResolvedVersionCatalog catalog, DocsUrlBuilder docsUrlBuilder)
Source
Builds the published-tree mount table for the current resolved version catalog.
catalogThe resolved version catalog that describes available published trees.docsUrlBuilderThe configured URL builder that supplies the route-family alias root.The ordered mount list plus the unique provider instances that should be disposed with the host lifetime.
Public exact-version mounts always preserve the authored catalog order. When the recommended release points at a public exact tree, this helper adds the configured route-family root alias as an extra mount root that reuses the same PhysicalFileProvider instance instead of duplicating file watchers for the same export path.
void ConfigureEndpoints(StartupContext context, IEndpointRouteBuilder endpoints)
Source
Adds the module's default controller routes and supporting asset routes for documentation endpoints.
contextStartup context for the application and environment.endpointsEndpoint route builder used to map the module's routes.When RazorDocs is the root module assembly, standalone and static-export hosts preserve the historical /css/site.gen.css URL by redirecting it to the packaged Razor Class Library stylesheet at /_content/ForgeTrust.AppSurface.Docs/css/site.gen.css. Embedded hosts do not register that redirect because they already link to the packaged asset directly. Redirects preserve the request HttpRequest.PathBase and query string so legacy links continue to work behind a virtual path, but the path base and configured package target must remain single-slash app-relative path components.
When versioning is enabled, this hook also reserves the stable version entry route at the configured route-family root, adds the archive surface below that route root, and serves preview-surface assets from either the live web root or the packaged Razor Class Library depending on whether published-tree mounts can shadow the stable docs root. Asset routes are built with DocsUrlBuilder.BuildAssetUrl(string) for search.css, minisearch.min.js, search-client.js, and the page-local outline-client.js. Preview hosts can serve those files directly from the web root; otherwise the current-surface URLs redirect through ResolveLegacySearchAssetBasePath to the packaged RazorDocs assets. Legacy asset redirects preserve only the request query string, while the redirect path itself is constrained to an app-relative URL so cache-busting parameters cannot turn the redirect into an external hop. Route ordering matters: index, search, search-index, section, and catch-all routes are registered from most to least specific so the live preview root continues to behave correctly even when the current docs root is root-mounted or overlaps published exact-version aliases.
When RazorDocs is the root module, the bare application root redirects to the configured docs home. This keeps standalone docs hosts and static exports useful after route isolation removed the old app-wide controller fallback. Embedded hosts do not get this redirect; their owning app should decide what / means.
The operator-facing harvest health route patterns are always registered before the catch-all docs route so {DocsRootPath}/_health and {DocsRootPath}/_health.json remain reserved operator paths rather than falling through to document lookup. The route named razordocs_harvest_health maps the current docs root health pattern from DocsUrlBuilder.BuildHealthUrl to DocsController.HarvestHealth, and razordocs_harvest_health_json maps DocsUrlBuilder.BuildHealthJsonUrl to DocsController.HarvestHealthJson. The controller actions still gate responses with RazorDocsHarvestHealthVisibility.AreRoutesExposed(RazorDocsOptions, IHostEnvironment): by default they return health only in Development, while production hosts must opt in with RazorDocsHarvestHealthOptions.ExposeRoutes. These routes are intended for local and operator verification, not as unauthenticated public reader navigation.
string BuildLegacyAssetRedirectPath(PathString pathBase, string targetPath, QueryString queryString)
Source
Builds the local redirect target used when historical docs asset URLs move to packaged Razor Class Library assets.
pathBaseThe current request path base to preserve for applications mounted below a prefix.targetPathThe package asset path selected by RazorDocs endpoint configuration.queryStringThe request query string to preserve for cache-busting or diagnostics parameters.An escaped, single-slash app-relative redirect target with the original query string appended.
InvalidOperationExceptionThrown when pathBase or targetPath is not a safe app-relative path component.This helper intentionally treats query text as data appended after the validated path. It validates the unescaped path base so unsafe separators are not hidden by URI formatting, then emits the escaped path base used for redirect headers. A root path base (/) is normalized to empty so the redirect stays single-slash local. It does not allow the path base or target path to be absolute, protocol-relative, backslash-prefixed, or control-character-bearing because those shapes can be interpreted by clients as redirects away from the current host.
Registers the RazorDocs dependency injection and options normalization pipeline.
This extension binds RazorDocsOptions from configuration, rehydrates omitted nested option objects such as RazorDocsOptions.Harvest, RazorDocsOptions.Routing, and RazorDocsOptions.Versioning with their default containers, normalizes caller-provided string settings, and validates the final shape on startup. Callers should use this once per application when they want the standard RazorDocs harvesting, routing, preview, and versioned published-release services to be available to downstream modules and controllers.
IServiceCollection AddRazorDocs(this IServiceCollection services)
Source
Adds the RazorDocs package services, normalized options, and routing helpers to the service collection.
servicesThe target service collection.The same service collection for chaining.
During post-configuration this method rehydrates null nested option blocks with defaults, trims nullable string settings such as repository roots and contributor URL templates, normalizes RazorDocsRoutingOptions.RouteRootPath and RazorDocsRoutingOptions.DocsRootPath through DocsUrlBuilder.NormalizeRouteRootPath(string?, string, bool) and DocsUrlBuilder.NormalizeDocsRootPath(string?, bool), trims RazorDocsVersioningOptions.CatalogPath, and removes blank or duplicate sidebar namespace prefixes. Callers that omit RazorDocsOptions.Routing or RazorDocsOptions.Versioning can therefore still rely on a fully populated options object after registration. When RazorDocsHarvestOptions.FailOnFailure is enabled, the registered startup preflight fails the host only when the aggregate harvest health is failed.
When RazorDocsRoutingOptions.DocsRootPath is omitted or whitespace, the live docs root is derived from the normalized RazorDocsRoutingOptions.RouteRootPath through DocsUrlBuilder.ResolveDefaultDocsRootPath(string, bool). For example, RazorDocs:Routing:RouteRootPath=/foo/bar with versioning enabled produces /foo/bar/next as the default live root. Callers that set both RazorDocsRoutingOptions.RouteRootPath and RazorDocsRoutingOptions.DocsRootPath should keep the pair coherent so stable entry, archive, exact-version, and live preview routes compose predictably after DocsUrlBuilder.NormalizeRouteRootPath(string?, string, bool) and DocsUrlBuilder.NormalizeDocsRootPath(string?, bool) run.
The method also registers DocsUrlBuilder and RazorDocsVersionCatalogService as singleton downstream services alongside the standard harvesters, memo cache, and DocAggregator. Consumers that resolve RazorDocsOptions directly should expect the normalized values rather than raw configuration text, and applications that need custom routing or catalog paths should provide those values before this method runs so the normalized singleton graph stays consistent.
Resolves stylesheet paths for RazorDocs hosts.
When the current application's root module lives in the RazorDocs assembly, RazorDocs layouts preserve the historical root stylesheet URL at ~/css/site.gen.css. Published and exported hosts may only materialize the packaged Razor Class Library asset path, so RazorDocsWebModule also preserves the root URL via a compatibility redirect to ~/_content/ForgeTrust.AppSurface.Docs/css/site.gen.css. When RazorDocs is consumed from another host assembly, layouts link directly to that packaged asset path.
RazorDocsAssetPathResolver CreateDefault()
Source
Creates the default asset-path resolver used when only the RazorDocs services are registered.
A resolver that assumes RazorDocs is embedded in another host.
RazorDocsAssetPathResolver CreateForRootModule(Assembly rootModuleAssembly)
Source
Creates the asset-path resolver for the supplied root module assembly.
rootModuleAssemblyThe assembly that owns the current host's root module.The resolver that matches the current host's RazorDocs asset layout.
bool IsRootModuleAssembly(Assembly rootModuleAssembly)
Source
Determines whether the supplied root module assembly belongs to the RazorDocs standalone host.
rootModuleAssemblyThe assembly that owns the current host's root module.true when RazorDocs is the root module; otherwise, false.
string StylesheetPath { get; }
Source
Gets the application-relative stylesheet path to use from RazorDocs layouts.