44using System . IO . Abstractions ;
55using Actions . Core . Services ;
66using ConsoleAppFramework ;
7- using Documentation . Builder . Diagnostics ;
87using Documentation . Builder . Diagnostics . Console ;
98using Documentation . Builder . Http ;
109using Elastic . Markdown ;
1110using Elastic . Markdown . IO ;
1211using Microsoft . Extensions . Logging ;
12+ using Documentation . Builder . LinkIndex ;
1313
1414namespace Documentation . Builder . Cli ;
1515
16- internal class Commands ( ILoggerFactory logger , ICoreService githubActionsService )
16+ internal class Commands ( ILoggerFactory logger , ICoreService githubActionsService , ILinkIndex linkIndex )
1717{
1818 /// <summary>
1919 /// Continuously serve a documentation folder at http://localhost:5000.
@@ -29,7 +29,6 @@ public async Task Serve(string? path = null, Cancel ctx = default)
2929 var host = new DocumentationWebHost ( path , logger , new FileSystem ( ) ) ;
3030 await host . RunAsync ( ctx ) ;
3131 await host . StopAsync ( ctx ) ;
32-
3332 }
3433
3534 /// <summary>
@@ -39,6 +38,7 @@ public async Task Serve(string? path = null, Cancel ctx = default)
3938 /// <param name="output"> -o, Defaults to `.artifacts/html` </param>
4039 /// <param name="pathPrefix"> Specifies the path prefix for urls </param>
4140 /// <param name="force"> Force a full rebuild of the destination folder</param>
41+ /// <param name="uploadToLinkIndex"> Upload the links.json file to the link index</param>
4242 /// <param name="ctx"></param>
4343 [ Command ( "generate" ) ]
4444 [ ConsoleAppFilter < StopwatchFilter > ]
@@ -48,6 +48,7 @@ public async Task<int> Generate(
4848 string ? output = null ,
4949 string ? pathPrefix = null ,
5050 bool ? force = null ,
51+ bool uploadToLinkIndex = false ,
5152 Cancel ctx = default
5253 )
5354 {
@@ -57,11 +58,13 @@ public async Task<int> Generate(
5758 {
5859 UrlPathPrefix = pathPrefix ,
5960 Force = force ?? false ,
60- Collector = new ConsoleDiagnosticsCollector ( logger , githubActionsService )
61+ Collector = new ConsoleDiagnosticsCollector ( logger , githubActionsService ) ,
6162 } ;
6263 var set = new DocumentationSet ( context ) ;
6364 var generator = new DocumentationGenerator ( set , logger ) ;
6465 await generator . GenerateAll ( ctx ) ;
66+ var linksJsonPath = set . LinkReferenceFile . FullName ;
67+ await linkIndex . UploadFileAsync ( linksJsonPath , uploadToLinkIndex ) ;
6568 return context . Collector . Errors + context . Collector . Warnings ;
6669 }
6770
@@ -72,6 +75,7 @@ public async Task<int> Generate(
7275 /// <param name="output"> -o, Defaults to `.artifacts/html` </param>
7376 /// <param name="pathPrefix"> Specifies the path prefix for urls </param>
7477 /// <param name="force"> Force a full rebuild of the destination folder</param>
78+ /// <param name="uploadToLinkIndex"> Upload the links.json file to the link index</param>
7579 /// <param name="ctx"></param>
7680 [ Command ( "" ) ]
7781 [ ConsoleAppFilter < StopwatchFilter > ]
@@ -81,7 +85,8 @@ public async Task<int> GenerateDefault(
8185 string ? output = null ,
8286 string ? pathPrefix = null ,
8387 bool ? force = null ,
88+ bool uploadToLinkIndex = false ,
8489 Cancel ctx = default
8590 ) =>
86- await Generate ( path , output , pathPrefix , force , ctx ) ;
91+ await Generate ( path , output , pathPrefix , force , uploadToLinkIndex , ctx ) ;
8792}
0 commit comments