From 5ff242b4c3e23c791f52676f0ac998b984ba1852 Mon Sep 17 00:00:00 2001 From: Dave Powers Date: Thu, 17 Oct 2024 20:44:51 -0400 Subject: [PATCH] Add field to docs.json denoting available aliases - read JavaScript file defining slug/alias mapping - parse aliases object as Ruby hash - add alias key to JSON output with value or null --- lib/docs/core/manifest.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/docs/core/manifest.rb b/lib/docs/core/manifest.rb index b7c2e00d..a043cb5d 100644 --- a/lib/docs/core/manifest.rb +++ b/lib/docs/core/manifest.rb @@ -20,6 +20,15 @@ module Docs if doc.options[:attribution].is_a?(String) json[:attribution] = doc.options[:attribution].strip end + + # parse doc aliases from JS file as Ruby hash + entry_file = File.open("assets/javascripts/models/entry.js") + data = entry_file.read + aliases = eval data.split("ALIASES = ").last.split(";").first + + # set alias value + json["alias"] = aliases[json["slug"].to_sym] + result << json end end