Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Questions about file selection #1163

Open
BurdetteLamar opened this issue Aug 25, 2024 · 2 comments
Open

Questions about file selection #1163

BurdetteLamar opened this issue Aug 25, 2024 · 2 comments

Comments

@BurdetteLamar
Copy link
Member

I'm looking at file selection for the rdoc command.

I see in the code that certain files and directories are excluded by default:

  • Each file whose name ends with ~, .orig, .rej, .bak, .gemspec.
  • Each file or directory whose name begins with ..
  • Each directory named test or spec.

When I run rdoc (no arguments or options) in ruby/rdoc/, certain other files (and possibly directories) are excluded:

  • console in bin/.
  • rdoc and ri in exe/.
  • ri.1 in man/.
  • epock.rake in rakelib/.

Questions:

  • Where is the code that controls these?
  • Are there other exclusions that I'm not (yet) seeing?
@colby-swandale
Copy link
Member

colby-swandale commented Aug 26, 2024

I don't know the rules off the top of my head, but you can find code around what's removed and included at:

RDoc#normalized_file_list

rdoc/lib/rdoc/rdoc.rb

Lines 275 to 315 in 95cc15b

def normalized_file_list(relative_files, force_doc = false,
exclude_pattern = nil)
file_list = {}
relative_files.each do |rel_file_name|
rel_file_name = rel_file_name.sub(/^\.\//, '')
next if rel_file_name.end_with? 'created.rid'
next if exclude_pattern && exclude_pattern =~ rel_file_name
stat = File.stat rel_file_name rescue next
case type = stat.ftype
when "file" then
mtime = (stat.mtime unless (last_modified = @last_modified[rel_file_name] and
stat.mtime.to_i <= last_modified.to_i))
if force_doc or RDoc::Parser.can_parse(rel_file_name) then
file_list[rel_file_name] = mtime
end
when "directory" then
next if UNCONDITIONALLY_SKIPPED_DIRECTORIES.include?(rel_file_name)
basename = File.basename(rel_file_name)
next if options.skip_tests && TEST_SUITE_DIRECTORY_NAMES.include?(basename)
created_rid = File.join rel_file_name, "created.rid"
next if File.file? created_rid
dot_doc = File.join rel_file_name, RDoc::DOT_DOC_FILENAME
if File.file? dot_doc then
file_list.update(parse_dot_doc_file(rel_file_name, dot_doc))
else
file_list.update(list_files_in_directory(rel_file_name))
end
else
warn "rdoc can't parse the #{type} #{rel_file_name}"
end
end
file_list
end

RDoc#remove_unparseable

rdoc/lib/rdoc/rdoc.rb

Lines 428 to 434 in 95cc15b

def remove_unparseable files
files.reject do |file, *|
file =~ /\.(?:class|eps|erb|scpt\.txt|svg|ttf|yml)$/i or
(file =~ /tags$/i and
/\A(\f\n[^,]+,\d+$|!_TAG_)/.match?(File.binread(file, 100)))
end
end

@BurdetteLamar
Copy link
Member Author

Thanks, @colby-swandale; will look into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants