Skip to content

Commit 73ba35f

Browse files
committed
File copy now in a decent place
1 parent b627f97 commit 73ba35f

File tree

10 files changed

+105
-21
lines changed

10 files changed

+105
-21
lines changed

src/Elastic.Documentation.Tooling/Diagnostics/Console/ConsoleDiagnosticsCollector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected override void HandleItem(Diagnostic diagnostic)
2424
_errors.Add(diagnostic);
2525
else if (diagnostic.Severity == Severity.Warning)
2626
_warnings.Add(diagnostic);
27-
else
27+
else if (!NoHints)
2828
_hints.Add(diagnostic);
2929
}
3030

src/Elastic.Markdown/BuildContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public record BuildContext
2929

3030
public bool Force { get; init; }
3131

32+
public bool SkipMetadata { get; init; }
33+
3234
// This property is used to determine if the site should be indexed by search engines
3335
public bool AllowIndexing { get; init; }
3436

src/Elastic.Markdown/Diagnostics/DiagnosticsChannel.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,12 @@ public class DiagnosticsCollector(IReadOnlyCollection<IDiagnosticsOutput> output
8585

8686
public HashSet<string> OffendingFiles { get; } = [];
8787

88-
public HashSet<string> InUseSubstitutionKeys { get; } = [];
88+
public ConcurrentDictionary<string, bool> InUseSubstitutionKeys { get; } = [];
8989

9090
public ConcurrentBag<string> CrossLinks { get; } = [];
9191

92+
public bool NoHints { get; init; }
93+
9294
public Task StartAsync(Cancel cancellationToken)
9395
{
9496
if (_started is not null)
@@ -117,6 +119,8 @@ void Drain()
117119
{
118120
while (Channel.Reader.TryRead(out var item))
119121
{
122+
if (item.Severity == Severity.Hint && NoHints)
123+
continue;
120124
IncrementSeverityCount(item);
121125
HandleItem(item);
122126
_ = OffendingFiles.Add(item.File);
@@ -132,7 +136,7 @@ private void IncrementSeverityCount(Diagnostic item)
132136
_ = Interlocked.Increment(ref _errors);
133137
else if (item.Severity == Severity.Warning)
134138
_ = Interlocked.Increment(ref _warnings);
135-
else if (item.Severity == Severity.Hint)
139+
else if (item.Severity == Severity.Hint && !NoHints)
136140
_ = Interlocked.Increment(ref _hints);
137141
}
138142

@@ -175,5 +179,5 @@ public async ValueTask DisposeAsync()
175179
}
176180

177181
public void CollectUsedSubstitutionKey(ReadOnlySpan<char> key) =>
178-
_ = InUseSubstitutionKeys.Add(key.ToString());
182+
_ = InUseSubstitutionKeys.TryAdd(key.ToString(), true);
179183
}

src/Elastic.Markdown/DocumentationGenerator.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public async Task ResolveDirectoryTree(Cancel ctx)
8282
public async Task GenerateAll(Cancel ctx)
8383
{
8484
var generationState = GetPreviousGenerationState();
85-
if (Context.Force || generationState == null)
85+
if (!Context.SkipMetadata && (Context.Force || generationState == null))
8686
DocumentationSet.ClearOutputDirectory();
8787

8888
if (CompilationNotNeeded(generationState, out var offendingFiles, out var outputSeenChanges))
@@ -99,6 +99,9 @@ public async Task GenerateAll(Cancel ctx)
9999

100100
await ExtractEmbeddedStaticResources(ctx);
101101

102+
if (Context.SkipMetadata)
103+
return;
104+
102105
_logger.LogInformation($"Generating documentation compilation state");
103106
await GenerateDocumentationState(ctx);
104107

@@ -150,7 +153,8 @@ await Parallel.ForEachAsync(DocumentationSet.Files, ctx, async (file, token) =>
150153
private void HintUnusedSubstitutionKeys()
151154
{
152155
var definedKeys = new HashSet<string>(Context.Configuration.Substitutions.Keys.ToArray());
153-
var keysNotInUse = definedKeys.Except(Context.Collector.InUseSubstitutionKeys).ToArray();
156+
var inUse = new HashSet<string>(Context.Collector.InUseSubstitutionKeys.Keys);
157+
var keysNotInUse = definedKeys.Except(inUse).ToArray();
154158
// If we have less than 20 unused keys emit them separately
155159
// Otherwise emit one hint with all of them for brevity
156160
if (keysNotInUse.Length >= 20)

src/Elastic.Markdown/IO/DocumentationSet.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public DocumentationSet(BuildContext build, ILoggerFactory logger, ICrossLinkRes
9191
.SelectMany(extension => extension.ScanDocumentationFiles(ScanDocumentationFiles, DefaultFileHandling))
9292
.ToArray();
9393

94-
Files = files.Concat(additionalSources).ToArray();
94+
Files = files.Concat(additionalSources).Where(f => f is not ExcludedFile).ToArray();
9595

9696
LastWrite = Files.Max(f => f.SourceFile.LastWriteTimeUtc);
9797

@@ -154,7 +154,7 @@ private DocumentationFile DefaultFileHandling(IFileInfo file, IDirectoryInfo sou
154154
if (documentationFile is not null)
155155
return documentationFile;
156156
}
157-
return new StaticFile(file, sourceDirectory);
157+
return new ExcludedFile(file, sourceDirectory);
158158
}
159159

160160
private void ValidateRedirectsExists()

src/docs-assembler/Building/AssemblerBuilder.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ public async Task BuildAllAsync(IReadOnlyCollection<Checkout> checkouts, Publish
2020
var uriResolver = new PublishEnvironmentUriResolver(globalNavigation, environment);
2121
var crossLinkResolver = new CrossLinkResolver(crossLinkFetcher, uriResolver);
2222

23+
if (context.OutputDirectory.Exists)
24+
context.OutputDirectory.Delete(true);
25+
context.OutputDirectory.Create();
26+
2327
foreach (var checkout in checkouts)
2428
{
2529
if (checkout.Repository.Skip)
2630
{
27-
context.Collector.EmitWarning(context.ConfigurationPath.FullName, $"Skipping {checkout.Repository.Origin} as its not yet been migrated to V3");
31+
context.Collector.EmitWarning(context.ConfigurationPath.FullName, $"Skipping {checkout.Repository.Origin} as its marked as skip in configuration");
2832
continue;
2933
}
3034

@@ -55,8 +59,9 @@ private async Task BuildAsync(Checkout checkout, PublishEnvironment environment,
5559
var buildContext = new BuildContext(context.Collector, context.ReadFileSystem, context.WriteFileSystem, path, output)
5660
{
5761
UrlPathPrefix = environment.PathPrefix,
58-
Force = true,
59-
AllowIndexing = environment.AllowIndexing
62+
Force = false,
63+
AllowIndexing = environment.AllowIndexing,
64+
SkipMetadata = true
6065
};
6166

6267
var set = new DocumentationSet(buildContext, logger, crossLinkResolver);

src/docs-assembler/Cli/RepositoryCommands.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ public async Task<int> BuildAll(
6363
var githubEnvironmentInput = githubActionsService.GetInput("environment");
6464
environment ??= !string.IsNullOrEmpty(githubEnvironmentInput) ? githubEnvironmentInput : "dev";
6565

66-
await using var collector = new ConsoleDiagnosticsCollector(logger, githubActionsService);
66+
await using var collector = new ConsoleDiagnosticsCollector(logger, githubActionsService)
67+
{
68+
NoHints = true
69+
};
70+
6771
_ = collector.StartAsync(ctx);
6872

6973
var assembleContext = new AssembleContext(collector, new FileSystem(), new FileSystem(), null, null)

src/docs-assembler/Navigation/GlobalNavigation.cs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ public string GetSubPath(Uri crossLinkUri, ref string path)
7070
}
7171
if (match is null || !_tocLookup.TryGetValue(match, out var toc))
7272
{
73-
_context.Collector.EmitError(_context.NavigationPath, $"Unable to find defined toc for url: {crossLinkUri}");
73+
//TODO remove
74+
if (crossLinkUri.Scheme != "asciidocalypse")
75+
_context.Collector.EmitError(_context.NavigationPath, $"Unable to find defined toc for url: {crossLinkUri}");
7476
return $"reference/{crossLinkUri.Scheme}";
7577
}
7678
path = path.AsSpan().TrimStart(toc.SourcePrefix).ToString();
@@ -85,10 +87,22 @@ public string GetSubPath(Uri crossLinkUri, ref string path)
8587

8688
var outputDirectory = documentationSet.OutputDirectory;
8789
var fs = defaultOutputFile.FileSystem;
88-
var relativePathSpan = relativePath.AsSpan();
8990

90-
var lookup = $"{documentationSet.Name}://{relativePath}";
91-
var match = TableOfContentsPrefixes.FirstOrDefault(prefix => lookup.StartsWith(prefix, StringComparison.Ordinal));
91+
var lookup = $"{documentationSet.Name}://{relativePath}".AsSpan();
92+
if (lookup.StartsWith("docs-content://serverless/", StringComparison.Ordinal))
93+
return null;
94+
if (lookup.StartsWith("eland://sphinx/", StringComparison.Ordinal))
95+
return null;
96+
97+
98+
string? match = null;
99+
foreach (var prefix in TableOfContentsPrefixes)
100+
{
101+
if (!lookup.StartsWith(prefix, StringComparison.Ordinal))
102+
continue;
103+
match = prefix;
104+
break;
105+
}
92106
if (match is null || !_tocLookup.TryGetValue(match, out var toc))
93107
{
94108
if (relativePath.StartsWith("raw-migrated-files/", StringComparison.Ordinal))
@@ -108,7 +122,12 @@ public string GetSubPath(Uri crossLinkUri, ref string path)
108122
_context.Collector.EmitError(_context.NavigationPath, $"No toc for output path: '{lookup}' falling back to: '{fallBack}'");
109123
return fs.FileInfo.New(fallBack);
110124
}
111-
var path = fs.Path.Combine(outputDirectory.FullName, toc.PathPrefix, relativePath);
125+
126+
var newPath = relativePath.AsSpan().TrimStart(toc.SourcePrefix.TrimEnd('/')).TrimStart('/').ToString();
127+
var path = fs.Path.Combine(outputDirectory.FullName, toc.PathPrefix, newPath);
128+
if (path.Contains("deploy-manage"))
129+
{
130+
}
112131
return fs.FileInfo.New(path);
113132
}
114133
}

src/docs-assembler/Navigation/GlobalNavigationFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ private static IReadOnlyCollection<TableOfContentsReference> ReadChildren(YamlSt
109109
if (source.AsSpan().IndexOf("://") == -1)
110110
{
111111
parent = source;
112-
source = $"{NarrativeRepository.RepositoryName}://{source}";
113112
pathPrefix = source;
113+
source = $"{NarrativeRepository.RepositoryName}://{source}";
114114
}
115115

116116
break;

src/docs-assembler/navigation.yml

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,54 @@ toc:
4343
# repo is short for
4444
# - toc: <repo>://<parent_toc>
4545
# path_prefix: <parent_toc>/<repo>
46-
- repo: elasticsearch
47-
- repo: apm
46+
- repo: asciidocalypse
4847
- repo: apm-agent-android
49-
- repo: apm-agent-go
5048
- repo: apm-agent-dotnet
49+
- repo: apm-agent-go
50+
- repo: apm-agent-ios
51+
- repo: apm-agent-java
52+
- repo: apm-agent-nodejs
53+
- repo: apm-agent-php
54+
- repo: apm-agent-python
55+
- repo: apm-agent-ruby
56+
- repo: apm-agent-rum-js
57+
- repo: apm-aws-lambda
58+
- repo: apm-k8s-attacher
59+
- repo: beats
60+
- repo: cloud-on-k8s
61+
- repo: cloud
62+
- repo: curator
63+
- repo: ecctl
64+
- repo: ecs-dotnet
65+
- repo: ecs-logging-go-logrus
66+
- repo: ecs-logging-go-zap
67+
- repo: ecs-logging-go-zerolog
68+
- repo: ecs-logging-java
69+
- repo: ecs-logging-nodejs
70+
- repo: ecs-logging-php
71+
- repo: ecs-logging-python
72+
- repo: ecs-logging-ruby
73+
- repo: ecs-logging
74+
- repo: ecs
75+
- repo: eland
76+
- repo: elastic-serverless-forwarder
77+
- repo: elasticsearch-hadoop
78+
- repo: elasticsearch-java
79+
- repo: elasticsearch-js
80+
- repo: elasticsearch-net
81+
- repo: elasticsearch-php
82+
- repo: elasticsearch-py
83+
- repo: elasticsearch-rs
84+
- repo: elasticsearch-ruby
85+
- repo: elasticsearch
86+
- repo: go-elasticsearch
87+
- repo: integrations
88+
- repo: kibana
89+
- repo: logstash-docs
90+
- repo: logstash
91+
- repo: search-ui
92+
- repo: integration-docs
93+
- repo: security-docs
5194

5295
#############
5396
# REFERENCE #
@@ -175,6 +218,9 @@ toc:
175218
- toc: docs-content://reference/ingestion-tools
176219
path_prefix: reference/ingestion-tools
177220
children:
221+
# Elasticsearch (TODO discuss with Colleen)
222+
- toc: elasticsearch://reference/ingestion-tools/enrich-processor
223+
path_prefix: reference/elasticsearch/enrich-processor
178224

179225
# Fleet and Elastic Agent
180226
# 🔜 https://github.com/elastic/docs-content/blob/prepare-for-assembler/reference/fleet/toc.yml

0 commit comments

Comments
 (0)