@@ -71,7 +71,6 @@ public static async void EnsureCacheLatest()
7171 }
7272
7373 private string _cachedDocumentation = string . Empty ;
74- private string _cachedPath = string . Empty ;
7574
7675 internal static async Task < Sample > FindAsync ( string category , string name )
7776 {
@@ -149,8 +148,21 @@ public string CodeUrl
149148
150149 public string XamlCode { get ; private set ; }
151150
151+ /// <summary>
152+ /// Gets or sets the path set in the samples.json pointing to the doc for the sample.
153+ /// </summary>
152154 public string DocumentationUrl { get ; set ; }
153155
156+ /// <summary>
157+ /// Gets or sets the absolute local doc path for cached file in app.
158+ /// </summary>
159+ public string LocalDocumentationFilePath { get ; set ; }
160+
161+ /// <summary>
162+ /// Gets or sets the base path segment to the current document location.
163+ /// </summary>
164+ public string RemoteDocumentationPath { get ; set ; }
165+
154166 public string Icon { get ; set ; }
155167
156168 public string BadgeUpdateVersionRequired { get ; set ; }
@@ -191,32 +203,29 @@ public async Task<string> GetCSharpSourceAsync()
191203 }
192204 }
193205
194- #pragma warning disable SA1009 // Doesn't like ValueTuples.
195- public async Task < ( string contents , string path ) > GetDocumentationAsync ( )
196- #pragma warning restore SA1009 // Doesn't like ValueTuples.
206+ public async Task < string > GetDocumentationAsync ( )
197207 {
198208 if ( ! string . IsNullOrWhiteSpace ( _cachedDocumentation ) )
199209 {
200- return ( _cachedDocumentation , _cachedPath ) ;
210+ return _cachedDocumentation ;
201211 }
202212
203213 var filepath = string . Empty ;
204214 var filename = string . Empty ;
205- var localPath = string . Empty ;
215+ LocalDocumentationFilePath = string . Empty ;
206216
207217 var docRegex = new Regex ( "^" + _docsOnlineRoot + "(?<branch>.+?)/docs/(?<file>.+)" ) ;
208218 var docMatch = docRegex . Match ( DocumentationUrl ) ;
209219 if ( docMatch . Success )
210220 {
211221 filepath = docMatch . Groups [ "file" ] . Value ;
212- filename = Path . GetFileName ( filepath ) ;
213- localPath = $ "ms-appx:///docs/{ Path . GetDirectoryName ( filepath ) } /";
222+ filename = Path . GetFileName ( RemoteDocumentationPath ) ;
223+ RemoteDocumentationPath = Path . GetDirectoryName ( filepath ) ;
224+ LocalDocumentationFilePath = $ "ms-appx:///docs/{ RemoteDocumentationPath } /";
214225 }
215226
216227#if ! DEBUG // use the docs repo in release mode
217- string modifiedDocumentationUrl = $ "{ _docsOnlineRoot } master/docs/{ filepath } ";
218-
219- _cachedPath = modifiedDocumentationUrl . Replace ( filename , string . Empty ) ;
228+ string modifiedDocumentationUrl = $ "{ _docsOnlineRoot } live/docs/{ filepath } ";
220229
221230 // Read from Cache if available.
222231 try
@@ -264,15 +273,14 @@ public async Task<string> GetCSharpSourceAsync()
264273 {
265274 var result = await localDocsStream . ReadTextAsync ( Encoding . UTF8 ) ;
266275 _cachedDocumentation = ProcessDocs ( result ) ;
267- _cachedPath = localPath ;
268276 }
269277 }
270278 catch ( Exception )
271279 {
272280 }
273281 }
274282
275- return ( _cachedDocumentation , _cachedPath ) ;
283+ return _cachedDocumentation ;
276284 }
277285
278286 /// <summary>
0 commit comments