From 4f57c823c8eb72c4e72f87db07f6fe4bbbe6f09f Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Wed, 22 Jul 2020 12:01:56 +0300 Subject: [PATCH] Docs module: option to disable section rendering --- modules/docs/src/Volo.Docs.Web/DocsUiOptions.cs | 6 ++++++ .../Pages/Documents/Project/Index.cshtml.cs | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/docs/src/Volo.Docs.Web/DocsUiOptions.cs b/modules/docs/src/Volo.Docs.Web/DocsUiOptions.cs index 4b4ab6a3b4..b4f3dfbf21 100644 --- a/modules/docs/src/Volo.Docs.Web/DocsUiOptions.cs +++ b/modules/docs/src/Volo.Docs.Web/DocsUiOptions.cs @@ -21,6 +21,12 @@ namespace Volo.Docs /// public bool ShowProjectsCombobox = true; + /// + /// If true, allows to create sections in document and show/hide sections according to user preferences. + /// Default value: True; + /// + public bool SectionRendering = true; + private string GetFormattedRoutePrefix() { if (string.IsNullOrWhiteSpace(_routePrefix)) diff --git a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs index 7049adf011..a9c91aed12 100644 --- a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs +++ b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs @@ -405,12 +405,15 @@ namespace Volo.Docs.Pages.Documents.Project private async Task ConvertDocumentContentToHtmlAsync() { - await SetDocumentPreferencesAsync(); - SetUserPreferences(); + if (_uiOptions.SectionRendering) + { + await SetDocumentPreferencesAsync(); + SetUserPreferences(); - var partialTemplates = await GetDocumentPartialTemplatesAsync(); + var partialTemplates = await GetDocumentPartialTemplatesAsync(); - Document.Content = await _documentSectionRenderer.RenderAsync(Document.Content, UserPreferences, partialTemplates); + Document.Content = await _documentSectionRenderer.RenderAsync(Document.Content, UserPreferences, partialTemplates); + } var converter = _documentToHtmlConverterFactory.Create(Document.Format ?? Project.Format); var content = converter.Convert(Project, Document, GetSpecificVersionOrLatest(), LanguageCode);