Skip to content

Commit aaf1123

Browse files
ArgoZhangCopilot
andauthored
feat(LLMsDocsGenerator): support core-only package generation (#1299)
* feat: 增加 core only 开关参数 * chore: bump version 11.0.1 * feat(LLMsDocsGenerator): support core-only package output Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix(LLMsDocsGenerator): preserve core-only output contents Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ea66765 commit aaf1123

5 files changed

Lines changed: 64 additions & 21 deletions

File tree

‎tools/BootstrapBlazor.LLMsDocsGenerator/ArgumentsHelper.cs‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,19 @@ public static ParseResult Parse(string[] args)
1919
};
2020
var outputFolderOption = new Option<string>("--output")
2121
{
22-
Description = "Set the publish folder of project",
22+
Description = "Set the output folder (core-only writes directly; default writes to wwwroot/llms)",
2323
DefaultValueFactory = _ => defaultFolder
2424
};
25+
var coreOnlyOption = new Option<bool>("--core-only")
26+
{
27+
Description = "Generate only core components and services for BootstrapBlazor packaging, without extension sources"
28+
};
2529

2630
var rootCommand = new RootCommand("BootstrapBlazor LLMs Documentation Generator")
2731
{
2832
rootFolderOption,
29-
outputFolderOption
33+
outputFolderOption,
34+
coreOnlyOption
3035
};
3136

3237
rootCommand.SetAction(async result =>
@@ -40,10 +45,10 @@ public static ParseResult Parse(string[] args)
4045
var outputFolder = result.GetValue(outputFolderOption);
4146
if (string.IsNullOrEmpty(outputFolder))
4247
{
43-
throw new ArgumentException("Publish folder must not be empty.");
48+
throw new ArgumentException("Output folder must not be empty.");
4449
}
4550

46-
await DocsGenerator.GenerateAllAsync(rootFolder, outputFolder);
51+
await DocsGenerator.GenerateAllAsync(rootFolder, outputFolder, result.GetValue(coreOnlyOption));
4752
});
4853

4954
return rootCommand.Parse(args);

‎tools/BootstrapBlazor.LLMsDocsGenerator/BootstrapBlazor.LLMsDocsGenerator.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<Version>11.0.0</Version>
4+
<Version>11.0.1</Version>
55
<OutputType>Exe</OutputType>
66
<SatelliteResourceLanguages>false</SatelliteResourceLanguages>
77
</PropertyGroup>

‎tools/BootstrapBlazor.LLMsDocsGenerator/DocsGenerator.cs‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ internal static class DocsGenerator
1212
/// <summary>
1313
/// Generate all documentation files
1414
/// </summary>
15-
public static async Task GenerateAllAsync(string rootFolder, string outputFolder)
15+
public static async Task GenerateAllAsync(string rootFolder, string outputFolder, bool coreOnly = false)
1616
{
1717
var _sourcePath = Path.Combine(rootFolder, "..", "BootstrapBlazor");
18-
var _outputPath = Path.Combine(outputFolder, "wwwroot", "llms");
18+
var _outputPath = coreOnly ? outputFolder : Path.Combine(outputFolder, "wwwroot", "llms");
1919

2020
Logger($"Source path: {_sourcePath}");
2121
Logger($"Output path: {_outputPath}");
@@ -31,7 +31,7 @@ public static async Task GenerateAllAsync(string rootFolder, string outputFolder
3131
// <core-repo>/.. / BootstrapBlazor.Extensions / src
3232
var coreRepoRoot = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetFullPath(_sourcePath)))!;
3333
var extensionsSrc = Path.Combine(Path.GetDirectoryName(coreRepoRoot)!, "BootstrapBlazor.Extensions", "src");
34-
var hasExtensions = Directory.Exists(extensionsSrc);
34+
var hasExtensions = !coreOnly && Directory.Exists(extensionsSrc);
3535

3636
var extensionProjects = hasExtensions
3737
? ReadExtensionProjects(Path.GetDirectoryName(extensionsSrc)!)
@@ -40,6 +40,10 @@ public static async Task GenerateAllAsync(string rootFolder, string outputFolder
4040
extensionProjects);
4141
var components = await _analyzer.AnalyzeAllComponentsAsync();
4242
Logger($"Found {components.Count} components");
43+
if (components.Count == 0)
44+
{
45+
throw new InvalidDataException("No core components found.");
46+
}
4347

4448
// Derive index categories, injected services and extension packages from docs.json.
4549
var serverPath = Path.Combine(Path.GetDirectoryName(Path.GetFullPath(_sourcePath))!, "BootstrapBlazor.Server");
@@ -48,8 +52,12 @@ public static async Task GenerateAllAsync(string rootFolder, string outputFolder
4852
Logger($"Found {categories.Count} categories");
4953
var services = await _analyzer.AnalyzeServicesAsync(provider.ParseServices());
5054
Logger($"Found {services.Count} services");
55+
if (services.Count == 0)
56+
{
57+
throw new InvalidDataException("No core services found.");
58+
}
5159

52-
var configuredPackages = provider.ParseExtensions();
60+
var configuredPackages = coreOnly ? new List<ExtensionPackage>() : provider.ParseExtensions();
5361
if (!hasExtensions && configuredPackages.Count > 0)
5462
{
5563
throw new DirectoryNotFoundException($"Extension sources required by docs.json were not found: {extensionsSrc}");

‎tools/BootstrapBlazor.LLMsDocsGenerator/README.md‎

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ AI coding assistants (Claude Code, Cursor, GitHub Copilot) often generate incorr
2525
│
2626
▼
2727
┌─────────────────────────────────────────────────────────────┐
28-
│ Output: <output>/wwwroot/llms/ │
28+
│ Default output: <output>/wwwroot/llms/ │
2929
├─────────────────────────────────────────────────────────────┤
3030
│ llms.txt → Index with quick start guide │
3131
│ components/ → Individual component documentation │
@@ -39,6 +39,8 @@ AI coding assistants (Claude Code, Cursor, GitHub Copilot) often generate incorr
3939
└─────────────────────────────────────────────────────────────┘
4040
```
4141

42+
With `--core-only`, the output directory is `<output>` itself.
43+
4244
### Why One File Per Component?
4345

4446
This design optimizes for LLM and Code Agent consumption:
@@ -85,7 +87,7 @@ Components are organized in the index by category for easy navigation, but each
8587
## Requirements
8688

8789
- An SDK matching the project's `TargetFrameworks` (currently .NET 11 for source builds).
88-
- A local `BootstrapBlazor` checkout; when `docs.json` configures extension packages, also check out `BootstrapBlazor.Extensions` beside it. The generator does not clone repositories.
90+
- A local `BootstrapBlazor` checkout; unless using `--core-only`, when `docs.json` configures extension packages, also check out `BootstrapBlazor.Extensions` beside it. The generator does not clone repositories.
8991

9092
## Installation
9193

@@ -117,21 +119,24 @@ Once installed, the tool is invoked with the command name `llms-docs`.
117119

118120
## Usage
119121

120-
Both options are optional and independently default to the current working directory (`.`). Run `llms-docs` without arguments from BB's `src/BootstrapBlazor.Server` directory to write documentation into that project. Overriding `--root` does not change the default `--output`; specify both when using another checkout or publish directory.
122+
Both path options independently default to the current working directory (`.`). Run `llms-docs` without arguments from BB's `src/BootstrapBlazor.Server` directory to write documentation into that project. With `--core-only`, output is written directly to the `--output` directory without clearing existing contents. Overriding `--root` does not change the default `--output`; specify both when using another checkout or publish directory.
121123

122124
From the Server project directory, `dotnet llms-docs --output=bin\Release\publish\` also works: the omitted `--root` defaults to `.`, and relative output paths are resolved from that same directory. MSBuild can use `dotnet llms-docs --output=$(PublishDir)` when the path contains no spaces.
123125

124126
| Option | Required | Description |
125127
|--------|----------|-------------|
126128
| `--root` | No | Project root folder. Defaults to `.`. Component source is read from `<root>/../BootstrapBlazor`. |
127-
| `--output` | No | Publish folder. Defaults to `.`. Documentation is written to `<output>/wwwroot/llms/`. |
129+
| `--output` | No | Output folder. Defaults to `.`. Default mode writes to `<output>/wwwroot/llms/`; `--core-only` writes directly to `<output>/`. |
130+
| `--core-only` | No | Generate only core components and built-in services for BootstrapBlazor packaging. Defaults to `false`; extension configuration and sources are not analyzed. |
128131

129132
When a `BootstrapBlazor.Extensions` checkout is available beside the core `BootstrapBlazor` checkout, the generator also analyzes the extension sources. The extension types to document are configured under `extensions` in `src/BootstrapBlazor.Server/docs.json`, the only configuration location. Generation fails if the file is missing. Extension docs are written to `extensions/`.
130133

131-
Only source projects listed in `BootstrapBlazor.Extensions.slnx` are scanned. Package names are matched against project filenames, not directory names. Configured packages outside the solution are skipped with a diagnostic; missing solution projects are reported as errors. Leftover directories do not participate in analysis. Core Razor-only components with an `@inherits` directive are also supported. Regeneration removes obsolete `.txt` files carrying the generator's `<!-- Generated: ... -->` marker, while preserving other files.
134+
Only source projects listed in `BootstrapBlazor.Extensions.slnx` are scanned. Package names are matched against project filenames, not directory names. Configured packages outside the solution are skipped with a diagnostic; missing solution projects are reported as errors. Leftover directories do not participate in analysis. Core Razor-only components with an `@inherits` directive are also supported. In default mode, regeneration removes obsolete `.txt` files carrying the generator's `<!-- Generated: ... -->` marker, while preserving other files.
132135

133136
If extension packages are configured but the sibling extension source checkout is missing, generation fails before changing existing documentation. Unresolved configured component or service types also fail generation before writing files or removing stale documents. Services shared by multiple packages retain one document listing the registration method for each configured package; choose the registration matching the package in use.
134137

138+
With `--core-only`, the `extensions` section is ignored without editing `docs.json`, and no extension checkout or solution is required or read, even when present. Core categories and services still come from `docs.json`, which remains required. No extension documents or extension index sections/links are generated; services also provided by extensions remain in the core service documentation. The output is `<output>/llms.txt` and `<output>/components/*.txt`, with relative index links suitable for a package. The output directory is created if needed; existing contents are not cleared. Stale files carrying the generator marker are removed while unmarked files and subdirectories are preserved.
139+
135140
Explicit `<Using Include="..." />` items in each source project's `.csproj` (including aliases and static imports) are applied to that project's C# files, without leaking these imports into other projects in the combined analysis.
136141

137142
This is source analysis, not a full MSBuild evaluation: conditions, property expansion, imported `.props`/`.targets`, and `Using Remove` are not evaluated. Razor-only support synthesizes inheritance declarations; it does not compile Razor or extract members from `@code` blocks.
@@ -140,7 +145,7 @@ Declare extension services by the types actually registered for injection. For e
140145

141146
Generation errors and explicitly empty paths return a nonzero process exit code so MSBuild and CI can stop.
142147

143-
Run the integration checks with PowerShell:
148+
Run the integration checks with PowerShell 7. They build the tool and invoke its actual CLI against isolated source fixtures for core-only packaging and full website generation:
144149

145150
```powershell
146151
.\tools\BootstrapBlazor.LLMsDocsGenerator\tests\Verify-Generation.ps1
@@ -170,6 +175,16 @@ From the same `BootstrapBlazor` repository root, run the sibling source project:
170175
dotnet run --project "..\BootstrapBlazor.Extensions\tools\BootstrapBlazor.LLMsDocsGenerator" --root "src\BootstrapBlazor.Server" --output "src\BootstrapBlazor.Server"
171176
```
172177

178+
### BootstrapBlazor NuGet packaging
179+
180+
From the `BootstrapBlazor` repository root, generate core-only documentation directly into the skill references directory:
181+
182+
```powershell
183+
dotnet llms-docs --core-only --root "src\BootstrapBlazor.Server" --output "src\BootstrapBlazor\skills\bootstrapblazor\references"
184+
```
185+
186+
No staging copy of `docs.json` with extensions removed is needed. BootstrapBlazor.Server publishing must omit `--core-only` to keep the full website index, core documentation and extension documentation; its existing command and output paths are unchanged.
187+
173188
## CI/CD Integration
174189

175190
Check out both repositories as siblings and use an SDK matching the checked-out generator project. The following steps assume the workflow belongs to `dotnetcore/BootstrapBlazor`; pin compatible refs when building a release:

0 commit comments

Comments
 (0)