Browse Source

Update documentation parameters and clean up visibility logic in Index page

pull/25380/head
maliming 2 weeks ago
parent
commit
5bc145cdf2
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 2
      docs/en/docs-params.json
  2. 8
      modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Documents/DocumentParameterDto.cs
  3. 3
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml
  4. 11
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs

2
docs/en/docs-params.json

@ -45,7 +45,7 @@
"MudBlazor": "MudBlazor"
},
"dependsOn": {
"UI": ["Blazor", "BlazorServer", "BlazorWebApp"]
"UI": ["Blazor", "BlazorServer", "BlazorWebApp", "MAUIBlazor"]
}
}
]

8
modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Documents/DocumentParameterDto.cs

@ -10,12 +10,6 @@ namespace Volo.Docs.Documents
public Dictionary<string, string> Values { get; set; }
/// <summary>
/// Conditional visibility: this parameter is shown only when the keyed parameter's
/// current value is one of the listed values.
/// Example: "DependsOn": { "UI": [ "Blazor", "BlazorServer", "BlazorWebApp" ] }
/// An empty dictionary means the parameter is always shown.
/// </summary>
public Dictionary<string, List<string>> DependsOn { get; set; } = new Dictionary<string, List<string>>();
public Dictionary<string, List<string>> DependsOn { get; set; }
}
}

3
modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml

@ -475,8 +475,6 @@
<div class="docs-text-field">
<div class="position-relative">
@{
// Filter the parameters that should actually be shown (after applying DependsOn rules)
// before computing the grid layout, otherwise hidden parameters would still occupy a column slot.
var visibleParameters = Model.DocumentPreferences?.Parameters?
.Where(p => Model.IsParameterVisible(p))
.ToList() ?? new List<DocumentParameterDto>();
@ -498,7 +496,6 @@
var count = visibleParameters.Count;
var rowCount = count / maxCellCount + (count % maxCellCount > 0 ? 1 : 0);
var cellSize = 12 / (count > maxCellCount ? maxCellCount : count);
// Last row may have fewer items than maxCellCount; size them to fill the row width.
var lastRowCellCount = count - (rowCount - 1) * maxCellCount;
var latestCellSize = 12 / lastRowCellCount;

11
modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs

@ -99,12 +99,6 @@ namespace Volo.Docs.Pages.Documents.Project
return IsParameterVisibleGiven(parameter, UserPreferences);
}
// Per-rule semantics for a (parameter, current selection) context:
// - rule.Value == null : malformed list, skip the rule (fail-open)
// - key not in current document : rule references an unknown parameter, skip (fail-open)
// - rule.Value.Count == 0 : explicit empty allow-list, hide the parameter (author intent: "never show")
// - selected value not in allow-list: hide
// - selected value in allow-list : pass this rule
protected virtual bool IsParameterVisibleGiven(DocumentParameterDto parameter, IReadOnlyDictionary<string, string> selectedValues)
{
if (parameter.DependsOn == null || parameter.DependsOn.Count == 0)
@ -883,9 +877,6 @@ namespace Volo.Docs.Pages.Documents.Project
AlternativeOptionLinkQueries = CollectAlternativeOptionLinksRecursively(0, new Dictionary<string, string>());
}
// Generates all parameter combinations as query strings, but skips parameters whose DependsOn rules
// aren't satisfied by the partially-built selection. This avoids producing nonsensical combinations
// (e.g. UI=MVC&BlazorUI=MudBlazor when BlazorUI depends on UI ∈ {Blazor, BlazorServer, BlazorWebApp}).
private List<string> CollectAlternativeOptionLinksRecursively(int index, Dictionary<string, string> selected)
{
if (index >= DocumentPreferences.Parameters.Count)
@ -895,8 +886,6 @@ namespace Volo.Docs.Pages.Documents.Project
var option = DocumentPreferences.Parameters[index];
// If this parameter is hidden in the current selection context, omit it from the query
// and continue with the next parameter (no Cartesian fan-out for this option).
if (!IsParameterVisibleGiven(option, selected))
{
return CollectAlternativeOptionLinksRecursively(index + 1, selected);

Loading…
Cancel
Save