Skip to content

Commit ecfebbc

Browse files
committed
update landing page path output
1 parent 54bdcc9 commit ecfebbc

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

src/Elastic.Markdown/IO/DocumentationSet.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,8 @@ void ValidateExists(string from, string to, IReadOnlyDictionary<string, string?>
329329

330330
public FrozenSet<MarkdownFile> MarkdownFiles { get; }
331331

332-
public string FirstInterestingUrl => NavigationIndexedByOrder.Values.OfType<FileNavigationItem>().First().Url;
332+
public string FirstInterestingUrl =>
333+
NavigationIndexedByOrder.Values.OfType<DocumentationGroup>().First().Url;
333334

334335
public DocumentationFile? DocumentationFileLookup(IFileInfo sourceFile)
335336
{

src/tooling/docs-builder/Cli/Commands.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ namespace Documentation.Builder.Cli;
2222

2323
internal sealed class Commands(ILoggerFactory logger, ICoreService githubActionsService)
2424
{
25+
private readonly ILogger<Program> _log = logger.CreateLogger<Program>();
2526
[SuppressMessage("Usage", "CA2254:Template should be a static expression")]
2627
private void AssignOutputLogger()
2728
{
28-
var log = logger.CreateLogger<Program>();
29-
ConsoleApp.Log = msg => log.LogInformation(msg);
30-
ConsoleApp.LogError = msg => log.LogError(msg);
29+
ConsoleApp.Log = msg => _log.LogInformation(msg);
30+
ConsoleApp.LogError = msg => _log.LogError(msg);
3131
}
3232

3333
/// <summary>
@@ -45,6 +45,9 @@ public async Task Serve(string? path = null, int port = 3000, Cancel ctx = defau
4545
{
4646
AssignOutputLogger();
4747
var host = new DocumentationWebHost(path, port, logger, new FileSystem(), new MockFileSystem());
48+
_log.LogInformation("Find your documentation at http://localhost:{Port}/{Path}", port,
49+
host.GeneratorState.Generator.DocumentationSet.FirstInterestingUrl.TrimStart('/')
50+
);
4851
await host.RunAsync(ctx);
4952
await host.StopAsync(ctx);
5053
}

src/tooling/docs-builder/Http/DocumentationWebHost.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public class DocumentationWebHost
2424
{
2525
private readonly WebApplication _webApplication;
2626

27-
private readonly BuildContext _context;
2827
private readonly IHostedService _hostedService;
2928
private readonly IFileSystem _writeFileSystem;
3029

@@ -44,18 +43,18 @@ public DocumentationWebHost(string? path, int port, ILoggerFactory logger, IFile
4443
var hostUrl = $"http://localhost:{port}";
4544

4645
_hostedService = collector;
47-
_context = new BuildContext(collector, readFs, writeFs, path, null)
46+
Context = new BuildContext(collector, readFs, writeFs, path, null)
4847
{
4948
CanonicalBaseUrl = new Uri(hostUrl),
5049
};
51-
var generatorState = new ReloadableGeneratorState(_context.DocumentationSourceDirectory, _context.DocumentationOutputDirectory, _context, logger);
50+
GeneratorState = new ReloadableGeneratorState(Context.DocumentationSourceDirectory, Context.DocumentationOutputDirectory, Context, logger);
5251
_ = builder.Services
5352
.AddAotLiveReload(s =>
5453
{
55-
s.FolderToMonitor = _context.DocumentationSourceDirectory.FullName;
54+
s.FolderToMonitor = Context.DocumentationSourceDirectory.FullName;
5655
s.ClientFileExtensions = ".md,.yml";
5756
})
58-
.AddSingleton<ReloadableGeneratorState>(_ => generatorState)
57+
.AddSingleton<ReloadableGeneratorState>(_ => GeneratorState)
5958
.AddHostedService<ReloadGeneratorService>();
6059

6160
if (IsDotNetWatchBuild())
@@ -67,6 +66,10 @@ public DocumentationWebHost(string? path, int port, ILoggerFactory logger, IFile
6766
SetUpRoutes();
6867
}
6968

69+
public ReloadableGeneratorState GeneratorState { get; }
70+
71+
public BuildContext Context { get; }
72+
7073
private static bool IsDotNetWatchBuild() => Environment.GetEnvironmentVariable("DOTNET_WATCH") is not null;
7174

7275
public async Task RunAsync(Cancel ctx)
@@ -141,7 +144,7 @@ await context.Response.WriteAsync(@"
141144
.UseStaticFiles(
142145
new StaticFileOptions
143146
{
144-
FileProvider = new EmbeddedOrPhysicalFileProvider(_context),
147+
FileProvider = new EmbeddedOrPhysicalFileProvider(Context),
145148
RequestPath = "/_static"
146149
})
147150
.UseRouting();

0 commit comments

Comments
 (0)