diff --git a/lib/yard/code_objects/extra_file_object.rb b/lib/yard/code_objects/extra_file_object.rb index c0f53a3e5..1de75bd6b 100644 --- a/lib/yard/code_objects/extra_file_object.rb +++ b/lib/yard/code_objects/extra_file_object.rb @@ -61,6 +61,10 @@ def inspect def type; :extra_file end + def source_type; :ruby end + + def parent; YARD::Registry.root end + def ==(other) return false unless self.class === other other.filename == filename diff --git a/lib/yard/code_objects/root_extra_file_object.rb b/lib/yard/code_objects/root_extra_file_object.rb new file mode 100644 index 000000000..e69de29bb diff --git a/lib/yard/serializers/file_system_serializer.rb b/lib/yard/serializers/file_system_serializer.rb index c95f585f1..bed1a1af4 100644 --- a/lib/yard/serializers/file_system_serializer.rb +++ b/lib/yard/serializers/file_system_serializer.rb @@ -51,7 +51,7 @@ def serialized_path(object) return object if object.is_a?(String) if object.is_a?(CodeObjects::ExtraFileObject) - fspath = ['file.' + object.name + (extension.empty? ? '' : ".#{extension}")] + fspath = ['_file', object.name + (extension.empty? ? '' : ".#{extension}")] else objname = object != YARD::Registry.root ? mapped_name(object) : "top-level-namespace" objname += '_' + object.scope.to_s[0, 1] if object.is_a?(CodeObjects::MethodObject) diff --git a/lib/yard/server/doc_server_serializer.rb b/lib/yard/server/doc_server_serializer.rb index 131cda807..5263cf8c4 100644 --- a/lib/yard/server/doc_server_serializer.rb +++ b/lib/yard/server/doc_server_serializer.rb @@ -20,7 +20,7 @@ def serialized_path(object) when CodeObjects::ConstantObject, CodeObjects::ClassVariableObject serialized_path(object.namespace) + "##{object.name}-#{object.type}" when CodeObjects::ExtraFileObject - super(object).gsub(/^file\./, 'file/') + super(object).gsub(/^_file\//, 'file/') else super(object) end diff --git a/spec/serializers/file_system_serializer_spec.rb b/spec/serializers/file_system_serializer_spec.rb index 0068549e4..28c308fb3 100644 --- a/spec/serializers/file_system_serializer_spec.rb +++ b/spec/serializers/file_system_serializer_spec.rb @@ -66,7 +66,7 @@ it "handles ExtraFileObject's" do s = Serializers::FileSystemSerializer.new e = CodeObjects::ExtraFileObject.new('filename.txt', '') - expect(s.serialized_path(e)).to eq 'file.filename.html' + expect(s.serialized_path(e)).to eq '_file/filename.html' end it "differentiates instance and class methods from serialized path" do diff --git a/spec/templates/helpers/html_helper_spec.rb b/spec/templates/helpers/html_helper_spec.rb index 6b02c6e93..aa17d4509 100644 --- a/spec/templates/helpers/html_helper_spec.rb +++ b/spec/templates/helpers/html_helper_spec.rb @@ -415,12 +415,12 @@ def parse_link(link) expect(parse_link(resolve_links("{file:TEST.txt#abc}"))).to eq( :inner_text => "TEST", :title => "TEST", - :href => "file.TEST.html#abc" + :href => "_file/TEST.html#abc" ) expect(parse_link(resolve_links("{file:TEST.txt title}"))).to eq( :inner_text => "title", :title => "title", - :href => "file.TEST.html" + :href => "_file/TEST.html" ) end diff --git a/templates/default/fulldoc/html/setup.rb b/templates/default/fulldoc/html/setup.rb index 201ba63c5..3df5ea8a7 100644 --- a/templates/default/fulldoc/html/setup.rb +++ b/templates/default/fulldoc/html/setup.rb @@ -8,7 +8,7 @@ def init generate_assets serialize('_index.html') options.files.each_with_index do |file, _i| - serialize_file(file, file.title) + serialize_file(file) end options.delete(:objects) @@ -48,6 +48,7 @@ def serialize_onefile # Generate the index document for the output # @params [Hash] options contains data and flags that influence the output def serialize_index(options) + options.object = Registry.root Templates::Engine.with_serializer('index.html', options.serializer) do T('layout').run(options.merge(:index => true)) end @@ -57,18 +58,12 @@ def serialize_index(options) # the README file or files specified on the command-line. # # @param [File] file object to be saved to the output -# @param [String] title currently unused # # @see layout#diskfile -def serialize_file(file, title = nil) # rubocop:disable Lint/UnusedMethodArgument - options.object = Registry.root +def serialize_file(file) options.file = file - outfile = 'file.' + file.name + '.html' - serialize_index(options) if file == options.readme - Templates::Engine.with_serializer(outfile, options.serializer) do - T('layout').run(options) - end + serialize(file) options.delete(:file) end diff --git a/templates/guide/fulldoc/html/setup.rb b/templates/guide/fulldoc/html/setup.rb index 87d4b121b..2ff61ec77 100644 --- a/templates/guide/fulldoc/html/setup.rb +++ b/templates/guide/fulldoc/html/setup.rb @@ -23,7 +23,7 @@ def init class << options.serializer define_method(:serialized_path) do |object| if CodeObjects::ExtraFileObject === object - super(object).sub(/^file\./, '').downcase + super(object).sub(/^_file\//, '').downcase else super(object) end