From 1944a844a74312fb68277acae003da3b7d773162 Mon Sep 17 00:00:00 2001 From: Benjamin Ragheb Date: Sat, 9 May 2015 17:57:45 -0400 Subject: Here is a script and a Makefile for generating a GNU Make docset for Dash. --- src/Info.plist | 14 ++++++++++++++ src/icon.png | Bin 0 -> 1617 bytes src/index.rb | 27 +++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 src/Info.plist create mode 100644 src/icon.png create mode 100755 src/index.rb (limited to 'src') diff --git a/src/Info.plist b/src/Info.plist new file mode 100644 index 0000000..b95b162 --- /dev/null +++ b/src/Info.plist @@ -0,0 +1,14 @@ + + + + + CFBundleIdentifier + gnumake + CFBundleName + GNU Make + DocSetPlatformFamily + make + isDashDocset + + + diff --git a/src/icon.png b/src/icon.png new file mode 100644 index 0000000..9b18522 Binary files /dev/null and b/src/icon.png differ diff --git a/src/index.rb b/src/index.rb new file mode 100755 index 0000000..c719fcc --- /dev/null +++ b/src/index.rb @@ -0,0 +1,27 @@ +require 'pathname' + +puts %Q[ + CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT); + CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path); +] + +INSERT_SQL = %Q[ + INSERT INTO searchIndex(name, type, path) VALUES ('%s','%s','%s'); +] + +PATTERN = %r[GNU make: (.+)] + +def quote(s) + s.gsub(/&/, '&').gsub(/'/, "\\'") +end + +ARGV.each do |arg| + Pathname.glob(arg) do |path| + match = path.each_line.lazy.map { |line| PATTERN.match(line) }.find { |m| m } + if match + printf INSERT_SQL, quote(match[1]), 'Guide', path.basename + else + $stderr.puts "%{path.basename}: no title found" + end + end +end -- cgit