@@ -134,7 +134,7 @@ def self.build_site(docs, coverage, options)
134134 SearchBuilder . build ( source_module , output_dir )
135135 end
136136
137- copy_extensions ( output_dir )
137+ copy_extensions ( source_module , output_dir )
138138 copy_theme_assets ( output_dir )
139139
140140 DocsetBuilder . new ( output_dir , source_module ) . build!
@@ -219,7 +219,10 @@ def self.copy_theme_assets(destination)
219219 end
220220 end
221221
222- def self . copy_extensions ( destination )
222+ def self . copy_extensions ( source_module , destination )
223+ if source_host = source_module . host &.extension
224+ copy_extension ( source_host , destination )
225+ end
223226 copy_extension ( 'katex' , destination ) if Markdown . has_math
224227 end
225228
@@ -251,7 +254,14 @@ def self.document_markdown(source_module, doc_model, path_to_root)
251254 doc [ :structure ] = source_module . doc_structure
252255 doc [ :module_name ] = source_module . name
253256 doc [ :author_name ] = source_module . author_name
254- doc [ :github_url ] = source_module . github_url
257+ if source_host = source_module . host
258+ doc [ :source_host_name ] = source_host . name
259+ doc [ :source_host_url ] = source_host . url
260+ doc [ :source_host_image ] = source_host . image
261+ doc [ :source_host_item_url ] = source_host . item_url ( doc_model )
262+ doc [ :github_url ] = doc [ :source_host_url ]
263+ doc [ :github_token_url ] = doc [ :source_host_item_url ]
264+ end
255265 doc [ :dash_url ] = source_module . dash_url
256266 doc [ :path_to_root ] = path_to_root
257267 doc [ :hide_name ] = true
@@ -326,39 +336,14 @@ def self.generate_badge(coverage, options)
326336 end
327337 # rubocop:enable Metrics/MethodLength
328338
329- def self . should_link_to_github ( file )
330- return unless file
331-
332- file = file . realpath . to_path
333- source_directory = Config . instance . source_directory . to_path
334- file . start_with? ( source_directory )
335- end
336-
337- # Construct Github token URL
338- # @param [Hash] item Parsed doc child item
339- # @param [Config] options Build options
340- def self . gh_token_url ( item , source_module )
341- return unless github_prefix = source_module . github_file_prefix
342- return unless should_link_to_github ( item . file )
343-
344- gh_line = if item . start_line && ( item . start_line != item . end_line )
345- "#L#{ item . start_line } -L#{ item . end_line } "
346- else
347- "#L#{ item . line } "
348- end
349- relative_file_path = item . file . realpath . relative_path_from (
350- source_module . root_path ,
351- )
352- "#{ github_prefix } /#{ relative_file_path } #{ gh_line } "
353- end
354-
355339 # Build mustache item for a top-level doc
356340 # @param [Hash] item Parsed doc child item
357341 # @param [Config] options Build options
358342 # rubocop:disable Metrics/MethodLength
359343 def self . render_item ( item , source_module )
360344 # Combine abstract and discussion into abstract
361345 abstract = ( item . abstract || '' ) + ( item . discussion || '' )
346+ source_host_item_url = source_module . host &.item_url ( item )
362347 {
363348 name : item . name ,
364349 name_html : item . name . gsub ( ':' , ':<wbr>' ) ,
@@ -368,7 +353,8 @@ def self.render_item(item, source_module)
368353 other_language_declaration : item . display_other_language_declaration ,
369354 usr : item . usr ,
370355 dash_type : item . type . dash_type ,
371- github_token_url : gh_token_url ( item , source_module ) ,
356+ source_host_item_url : source_host_item_url ,
357+ github_token_url : source_host_item_url ,
372358 default_impl_abstract : item . default_impl_abstract ,
373359 from_protocol_extension : item . from_protocol_extension ,
374360 return : item . return ,
@@ -452,8 +438,14 @@ def self.document(source_module, doc_model, path_to_root)
452438 doc [ :tasks ] = render_tasks ( source_module , doc_model . children )
453439 doc [ :module_name ] = source_module . name
454440 doc [ :author_name ] = source_module . author_name
455- doc [ :github_url ] = source_module . github_url
456- doc [ :github_token_url ] = gh_token_url ( doc_model , source_module )
441+ if source_host = source_module . host
442+ doc [ :source_host_name ] = source_host . name
443+ doc [ :source_host_url ] = source_host . url
444+ doc [ :source_host_image ] = source_host . image
445+ doc [ :source_host_item_url ] = source_host . item_url ( doc_model )
446+ doc [ :github_url ] = doc [ :source_host_url ]
447+ doc [ :github_token_url ] = doc [ :source_host_item_url ]
448+ end
457449 doc [ :dash_url ] = source_module . dash_url
458450 doc [ :path_to_root ] = path_to_root
459451 doc [ :deprecation_message ] = doc_model . deprecation_message
0 commit comments