Class: DocGuard::Shared::Subprocesses::LoadTrackedFilesFromDocumentation
- Inherits:
-
Object
- Object
- DocGuard::Shared::Subprocesses::LoadTrackedFilesFromDocumentation
- Defined in:
- lib/doc_guard/shared/subprocesses/load_tracked_files_from_documentation.rb
Overview
Loads a mapping between documentation files and the files they track.
Scans all ‘.md` files under the configured documentation path, and builds a map of:
documentation_file_path => [list of tracked source file paths]
Example:
"docs/user.md" => ["app/models/user.rb", "app/services/authenticator.rb"],
"docs/admin.md" => ["app/models/admin.rb"]
Constant Summary collapse
- TAG_PATTERN =
/<!--\s*doc_guard\s+files:\s*\[(?<files_to_track>[\s\S]*?)\]\s*-->/
Class Method Summary collapse
-
.run(config: ::DocGuard::Config.new) ⇒ Hash{String => Array<String>}
Builds a hash mapping documentation files to the files they track.
Class Method Details
.run(config: ::DocGuard::Config.new) ⇒ Hash{String => Array<String>}
Builds a hash mapping documentation files to the files they track.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/doc_guard/shared/subprocesses/load_tracked_files_from_documentation.rb', line 24 def self.run(config: ::DocGuard::Config.new) mapping = {} Dir.glob("#{config.documentation_path}/**/*.md") do |documentation_file| tracked = [] content = File.read(documentation_file) content.scan(TAG_PATTERN).each do |match| files = match[0].split(",").map(&:strip) tracked.concat(files) end mapping[documentation_file] = tracked.uniq unless tracked.empty? end mapping end |