Skip to content

Commit 878e93e

Browse files
authored
Merge branch 'main' into copilot/fix-1898
2 parents 3509266 + edcefbe commit 878e93e

File tree

51 files changed

+1105
-185
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1105
-185
lines changed

.github/copilot-instructions.md

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
# docs-builder
2+
3+
**ALWAYS reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.**
4+
5+
Elastic's distributed documentation tooling system built on .NET 9, consisting of:
6+
- **docs-builder**: CLI tool for building single documentation sets
7+
- **docs-assembler**: CLI tool for assembling multiple doc sets
8+
- Written in C# and F# with extensive Markdown processing capabilities
9+
10+
## Working Effectively
11+
12+
### Prerequisites and Setup
13+
Install these in order:
14+
```bash
15+
# Install .NET 9.0 SDK
16+
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 9.0
17+
export PATH="$HOME/.dotnet:$PATH"
18+
19+
# Restore .NET tools (required)
20+
dotnet tool restore
21+
22+
# Install Aspire workload (required for local development)
23+
dotnet workload install aspire
24+
```
25+
26+
### Build and Test Commands
27+
```bash
28+
# Basic build - takes 2 minutes. NEVER CANCEL. Set timeout to 180+ seconds.
29+
dotnet build
30+
31+
# Custom build system - takes 1.5 minutes. NEVER CANCEL. Set timeout to 120+ seconds.
32+
./build.sh
33+
34+
# Unit tests - takes 20 seconds. NEVER CANCEL. Set timeout to 60+ seconds.
35+
./build.sh unit-test
36+
37+
# Integration tests - takes 1 minute. NEVER CANCEL. Set timeout to 120+ seconds.
38+
# Note: May fail in sandboxed environments due to network/service dependencies
39+
./build.sh integrate
40+
41+
# Clean build artifacts
42+
./build.sh clean
43+
44+
# Format code - takes 1 minute. NEVER CANCEL. Set timeout to 120+ seconds.
45+
dotnet format
46+
47+
# Lint/format check - takes 1 minute. NEVER CANCEL. Set timeout to 120+ seconds.
48+
dotnet format --verify-no-changes
49+
```
50+
51+
### Node.js Dependencies (Documentation Site)
52+
```bash
53+
cd src/Elastic.Documentation.Site
54+
55+
# Install dependencies - takes 15 seconds
56+
npm ci
57+
58+
# Lint TypeScript/JavaScript - takes 2 seconds
59+
npm run lint
60+
61+
# Build web assets - takes 10 seconds
62+
npm run build
63+
64+
# Run tests
65+
npm run test
66+
```
67+
68+
### CLI Tools Usage
69+
```bash
70+
# Build documentation from ./docs folder - takes 15 seconds
71+
dotnet run --project src/tooling/docs-builder
72+
73+
# Serve with live reload at http://localhost:3000
74+
dotnet run --project src/tooling/docs-builder -- serve
75+
76+
# Get help for docs-builder
77+
dotnet run --project src/tooling/docs-builder -- --help
78+
79+
# Get help for docs-assembler
80+
dotnet run --project src/tooling/docs-assembler -- --help
81+
82+
# Validate assembler configuration - takes 15 seconds
83+
dotnet run --project src/tooling/docs-assembler -c release -- navigation validate
84+
```
85+
86+
### Local Development Orchestration
87+
```bash
88+
# Run full local environment with Aspire (requires network access)
89+
dotnet run --project aspire
90+
91+
# With options for local development
92+
dotnet run --project aspire -- --assume-cloned --skip-private-repositories
93+
94+
# Watch mode for continuous development - monitors file changes
95+
./build.sh watch
96+
```
97+
98+
## Validation
99+
100+
### Always run these before submitting changes:
101+
```bash
102+
# 1. Format code
103+
dotnet format
104+
105+
# 2. Build successfully
106+
./build.sh
107+
108+
# 3. Run unit tests
109+
./build.sh unit-test
110+
111+
# 4. Lint TypeScript/JavaScript
112+
cd src/Elastic.Documentation.Site && npm run lint
113+
```
114+
115+
### Testing Changes
116+
- **ALWAYS** test the docs-builder CLI after making changes to verify functionality
117+
- Test both building (`dotnet run --project src/tooling/docs-builder`) and serving (`dotnet run --project src/tooling/docs-builder -- serve`)
118+
- For markdown processing changes, build the repository's own docs to validate
119+
- For web components, build the npm assets and check output
120+
121+
## Common Tasks
122+
123+
### Key Project Structure
124+
```
125+
src/
126+
├── Elastic.Markdown/ # Core Markdown processing engine
127+
├── tooling/
128+
│ ├── docs-builder/ # Main CLI application
129+
│ └── docs-assembler/ # Assembly tool
130+
├── Elastic.Documentation.Site/ # Web rendering components (TypeScript/CSS)
131+
└── Elastic.Documentation.Configuration/ # Configuration handling
132+
133+
tests/
134+
├── Elastic.Markdown.Tests/ # C# unit tests
135+
├── authoring/ # F# authoring tests
136+
└── docs-assembler.Tests/ # Assembler tests
137+
138+
tests-integration/ # Integration tests
139+
docs/ # Repository documentation
140+
config/ # YAML configuration files
141+
```
142+
143+
### Adding New Features
144+
- **Markdown Extensions**: Add to `src/Elastic.Markdown/Myst/`
145+
- **CLI Commands**: Extend `src/tooling/docs-builder/Cli/` or `docs-assembler/Cli/`
146+
- **Web Components**: Add to `src/Elastic.Documentation.Site/`
147+
- **Configuration**: Modify `src/Elastic.Documentation.Configuration/`
148+
149+
### Important Files
150+
- `build/Targets.fs` - F# build script definitions
151+
- `docs-builder.sln` - Main solution file
152+
- `global.json` - .NET SDK version (9.0.100)
153+
- `Directory.Build.props` - MSBuild properties
154+
- `Directory.Packages.props` - Centralized package management
155+
- `dotnet-tools.json` - Required .NET tools
156+
157+
### Build Timing Expectations
158+
- **NEVER CANCEL** builds or tests - they may take longer than expected
159+
- Initial build: ~2 minutes
160+
- Incremental builds: ~30 seconds
161+
- Unit tests: ~20 seconds
162+
- Integration tests: ~1 minute (may fail without network access)
163+
- Format checking: ~1 minute
164+
- TypeScript build: ~10 seconds
165+
166+
### Environment Notes
167+
- Builds successfully on Ubuntu, macOS, and Windows
168+
- Integration tests require network access (may fail in sandboxed environments)
169+
- Uses both C# (.NET 9) and F# for different components
170+
- TypeScript/Node.js for web asset building
171+
- Self-hosting documentation demonstrating the tool's capabilities
172+
173+
### Documentation Updates
174+
When changing markdown syntax or rendering behavior, **always** update the documentation in the `/docs/` folder as this repository is self-documenting.
175+
176+
## Quick Reference
177+
178+
```bash
179+
# Full development setup from fresh clone
180+
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 9.0
181+
export PATH="$HOME/.dotnet:$PATH"
182+
dotnet tool restore
183+
dotnet workload install aspire
184+
cd src/Elastic.Documentation.Site && npm ci && cd ../..
185+
186+
# Build and validate changes
187+
dotnet format
188+
./build.sh
189+
./build.sh unit-test
190+
cd src/Elastic.Documentation.Site && npm run lint && npm run build
191+
192+
# Test CLI functionality
193+
dotnet run --project src/tooling/docs-builder
194+
dotnet run --project src/tooling/docs-builder -- serve
195+
```

.github/workflows/auto-add-needs-triage-label.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- name: Add needs triage label
18-
uses: actions/github-script@v7
18+
uses: actions/github-script@v8
1919
with:
2020
script: |
2121
github.rest.issues.addLabels({

.github/workflows/comment-on-asciidoc-changes.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
3030
- name: Add a comment if .asciidoc files changed
3131
if: steps.check-files.outputs.any_changed == 'true'
32-
uses: actions/github-script@v7
32+
uses: actions/github-script@v8
3333
with:
3434
script: |
3535
github.rest.issues.createComment({

.github/workflows/preview-build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ jobs:
147147
- name: Get modified file detail
148148
if: contains(fromJSON('["merge_group", "pull_request", "pull_request_target"]'), github.event_name)
149149
id: check-modified-file-detail
150-
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
150+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
151151
env:
152152
PATH_PATTERN: "${{ inputs.path-pattern != '' && inputs.path-pattern || '**' }}"
153153
IGNORE_PATTERNS: |
@@ -240,7 +240,7 @@ jobs:
240240
contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name)
241241
|| (needs.check.outputs.any_modified == 'true' && startsWith(github.event_name, 'pull_request'))
242242
)
243-
uses: actions/github-script@v7
243+
uses: actions/github-script@v8
244244
id: deployment
245245
env:
246246
PR_NUMBER: ${{ github.event.pull_request.number }}
@@ -465,7 +465,7 @@ jobs:
465465
uses: elastic/docs-builder/actions/update-link-index@main
466466

467467
- name: Update deployment status
468-
uses: actions/github-script@v7
468+
uses: actions/github-script@v8
469469
if: >
470470
env.MATCH == 'true'
471471
&& always()
@@ -501,7 +501,7 @@ jobs:
501501
steps:
502502
- name: Comment on PR
503503
continue-on-error: true
504-
uses: actions/github-script@v7
504+
uses: actions/github-script@v8
505505
env:
506506
ALL_CHANGED_FILES: ${{ needs.check.outputs.all_changed_files }}
507507
PATH_PREFIX: ${{ needs.build.outputs.path_prefix }}
@@ -576,7 +576,7 @@ jobs:
576576
}
577577
- name: Comment on docs changes about versioning requirements
578578
if: inputs.enable-cumulative-comment == true
579-
uses: actions/github-script@v7
579+
uses: actions/github-script@v8
580580
with:
581581
github-token: ${{ secrets.GITHUB_TOKEN }}
582582
# language=javascript

.github/workflows/preview-cleanup.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Delete GitHub environment
19-
uses: actions/github-script@v7
19+
uses: actions/github-script@v8
2020
id: delete-deployment
2121
with:
2222
script: |

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
with:
3434
commitish: ${{ github.sha }}
3535
- name: Create tag
36-
uses: actions/github-script@v7
36+
uses: actions/github-script@v8
3737
with:
3838
script: |
3939
github.rest.git.createRef({

aspire/AppHost.cs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,9 @@
55

66
using ConsoleAppFramework;
77
using Elastic.Documentation;
8-
using Microsoft.Extensions.Logging;
98
using static Elastic.Documentation.Aspire.ResourceNames;
109

11-
// ReSharper disable UnusedVariable
12-
// ReSharper disable RedundantAssignment
13-
// ReSharper disable NotAccessedVariable
14-
15-
var logLevel = LogLevel.Information;
16-
GlobalCommandLine.Process(ref args, ref logLevel, out var skipPrivateRepositories);
17-
var globalArguments = new List<string>();
18-
if (skipPrivateRepositories)
19-
globalArguments.Add("--skip-private-repositories");
20-
21-
if (logLevel != LogLevel.Information)
22-
{
23-
globalArguments.Add("--log-level");
24-
globalArguments.Add(logLevel.ToString());
25-
}
10+
GlobalCli.Process(ref args, out _, out var globalArguments);
2611

2712
await ConsoleApp.RunAsync(args, BuildAspireHost);
2813
return;
@@ -32,7 +17,6 @@
3217
async Task BuildAspireHost(bool startElasticsearch, bool assumeCloned, bool skipPrivateRepositories, Cancel ctx)
3318
{
3419
var builder = DistributedApplication.CreateBuilder(args);
35-
skipPrivateRepositories = globalArguments.Contains("--skip-private-repositories");
3620

3721
var llmUrl = builder.AddParameter("LlmGatewayUrl", secret: true);
3822
var llmServiceAccountPath = builder.AddParameter("LlmGatewayServiceAccountPath", secret: true);
@@ -63,6 +47,7 @@ async Task BuildAspireHost(bool startElasticsearch, bool assumeCloned, bool skip
6347
.WithEnvironment("LLM_GATEWAY_SERVICE_ACCOUNT_KEY_PATH", llmServiceAccountPath)
6448
.WithExplicitStart();
6549

50+
// ReSharper disable once RedundantAssignment
6651
api = startElasticsearch
6752
? api
6853
.WithReference(elasticsearchLocal)
@@ -78,6 +63,8 @@ async Task BuildAspireHost(bool startElasticsearch, bool assumeCloned, bool skip
7863
.WithArgs(["assembler", "build", "--exporters", "elasticsearch", .. globalArguments])
7964
.WithExplicitStart()
8065
.WaitForCompletion(cloneAll);
66+
67+
// ReSharper disable once RedundantAssignment
8168
indexElasticsearch = startElasticsearch
8269
? indexElasticsearch
8370
.WaitFor(elasticsearchLocal)
@@ -97,6 +84,8 @@ async Task BuildAspireHost(bool startElasticsearch, bool assumeCloned, bool skip
9784
.WithEnvironment(context => context.EnvironmentVariables["DOCUMENTATION_ELASTIC_PASSWORD"] = elasticsearchLocal.Resource.PasswordParameter)
9885
.WithExplicitStart()
9986
.WaitForCompletion(cloneAll);
87+
88+
// ReSharper disable once RedundantAssignment
10089
indexElasticsearchSemantic = startElasticsearch
10190
? indexElasticsearchSemantic
10291
.WaitFor(elasticsearchLocal)
@@ -130,6 +119,7 @@ async Task BuildAspireHost(bool startElasticsearch, bool assumeCloned, bool skip
130119
.WithEnvironment("DOCUMENTATION_ELASTIC_APIKEY", elasticsearchApiKey);
131120

132121

122+
// ReSharper disable once RedundantAssignment
133123
serveStatic = startElasticsearch ? serveStatic.WaitFor(elasticsearchLocal) : serveStatic.WaitFor(buildAll);
134124

135125
await builder.Build().RunAsync(ctx);

0 commit comments

Comments
 (0)