summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouie S <louie@example.com>2024-06-05 18:22:54 -0400
committerLouie S <louie@example.com>2024-06-05 18:22:54 -0400
commit973bbcd6a8af9695a937fdc754e384a917984d2a (patch)
tree224effa3cc35d0d0b0033a81e057e3e9123e782a
parentef4c089d4f64307e48b3810830c2559830ebf8e2 (diff)
FORK - first commit of dash-docset-builder
-rw-r--r--Makefile70
-rw-r--r--README.md39
-rw-r--r--README.template17
-rw-r--r--src/Info.plist14
-rwxr-xr-xsrc/index.sh34
-rw-r--r--src/lib/create_table7
-rw-r--r--src/lib/insert8
7 files changed, 36 insertions, 153 deletions
diff --git a/Makefile b/Makefile
index 9559806..f37435f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,18 @@
-#DOCSET_NAME = ...
+# Makefile should be called directly, passing the following arguments:
+# DOCSET_NAME = ... (should be a directory under ./configs)
+# optionally:
+# BUILD_DIR = ... (create built docsets under the directory BUILDDIR)
-DOCSET_DIR = $(DOCSET_NAME).docset
+ERROR_DOCSET_NAME = $(error DOCSET_NAME is unset)
+.phony: err
+
+ifndef DOCSET_NAME
+err: ; $(ERROR_DOCSET_NAME)
+endif
+
+SOURCE_DIR = configs/$(DOCSET_NAME)
+BUILD_DIR = .
+DOCSET_DIR = $(BUILD_DIR)/$(DOCSET_NAME).docset
CONTENTS_DIR = $(DOCSET_DIR)/Contents
RESOURCES_DIR = $(CONTENTS_DIR)/Resources
DOCUMENTS_DIR = $(RESOURCES_DIR)/Documents
@@ -10,37 +22,16 @@ INDEX_FILE = $(RESOURCES_DIR)/docSet.dsidx
ICON_FILE = $(DOCSET_DIR)/icon.png
ARCHIVE_FILE = $(DOCSET_NAME).tgz
-#SRC_ICON = src/icon.png
-
-#MANUAL_URL = ...
-#MANUAL_FILE = tmp/...
-
-ERROR_DOCSET_NAME = $(error DOCSET_NAME is unset)
-WARNING_MANUAL_URL = $(warning MANUAL_URL is unset)
-ERROR_MANUAL_FILE = $(error MANUAL_FILE is unset)
-.phony: err warn
-
-ifndef DOCSET_NAME
-err: ; $(ERROR_DOCSET_NAME)
-endif
+SRC_INFO_PLIST_FILE = $(SOURCE_DIR)/Info.plist
-ifndef MANUAL_FILE
-err: ; $(ERROR_MANUAL_FILE)
-endif
+DOCSET = $(INFO_PLIST_FILE) $(INDEX_FILE) $(ICON_FILE)
-ifndef MANUAL_URL
-warn:
- $(WARNING_MANUAL_URL)
- $(MAKE) all
-endif
+all: $(DOCSET)
-DOCSET = $(INFO_PLIST_FILE) $(INDEX_FILE)
-ifdef SRC_ICON
-DOCSET += $(ICON_FILE)
+ifdef DOCSET_NAME
+include configs/$(DOCSET_NAME)/config.mk
endif
-all: $(DOCSET)
-
archive: $(ARCHIVE_FILE)
clean:
@@ -52,11 +43,6 @@ tmp:
$(ARCHIVE_FILE): $(DOCSET)
tar --exclude='.DS_Store' -czf $@ $(DOCSET_DIR)
-ifdef MANUAL_URL
-$(MANUAL_FILE): tmp
- curl -o $@ $(MANUAL_URL)
-endif
-
$(DOCSET_DIR):
mkdir -p $@
@@ -66,16 +52,10 @@ $(CONTENTS_DIR): $(DOCSET_DIR)
$(RESOURCES_DIR): $(CONTENTS_DIR)
mkdir -p $@
-$(DOCUMENTS_DIR): $(RESOURCES_DIR) $(MANUAL_FILE)
- mkdir -p $@
- tar -x -z -f $(MANUAL_FILE) -C $@
-
-$(INFO_PLIST_FILE): src/Info.plist $(CONTENTS_DIR)
- cp src/Info.plist $@
-
-$(INDEX_FILE): src/index.sh $(DOCUMENTS_DIR)
- rm -f $@
- src/index.sh $@ $(DOCUMENTS_DIR)/*.html
+$(INFO_PLIST_FILE): $(SRC_INFO_PLIST_FILE) $(CONTENTS_DIR)
+ cp $(SRC_INFO_PLIST_FILE) $@
-$(ICON_FILE): src/icon.png $(DOCSET_DIR)
- cp $(SRC_ICON) $@
+ifdef SRC_ICON_FILE
+$(ICON_FILE): $(SRC_ICON_FILE) $(DOCSET_DIR)
+ cp $(SRC_ICON_FILE) $@
+endif
diff --git a/README.md b/README.md
index 774f7de..9163367 100644
--- a/README.md
+++ b/README.md
@@ -1,33 +1,16 @@
-# Dash Docset Template
+# Dash Docset Builder
-This is a repository providing a template to package a Dash docset from HTML source documentation. Files that need to be manually configured are listed below. Additional fine tuning is also recommended, depending on the quirks of the documentation being packaged. An example docset packaging script for GNU Make using this template can be seen [here](https://github.com/lshprung/gnu-make-dash-docset)
+This is a repository providing sources building various Dash docsets using a Makefile. Supported docsets can be found under `./configs`.
-### `README.template`
+### Documentation
-This file will provide a README for the packaging script. Replace `<NAME>`, `<UPSTREAM LINK>`, and `<UPSTREAM HOST>` with appropriate values.
+```
+Usage: make DOCSET_NAME=... [BUILD_DIR=...]
-### `Makefile`
+ DOCSET_NAME must be set to the name of a directory under ./configs.
+ BUILD_DIR can be set to a directory to build under. The default is the project root
-This file will build the docset.
-
-- `DOCSET_NAME` must be set
-- `MANUAL_FILE` must be set
- - If the script should download documentation from the internet, `MANUAL_URL` must also be set. If not, ensure a `.tgz` archive of the HTML documentation exists at `tmp/MANUAL.tgz` (where MANUAL is the name of the archive)
-
-### `src/icon.png`
-
-If you want to associate an icon with the docset, it should be saved to `src/icon.png`. Make sure to uncomment the corresponding line in `Makefile` to include the icon in the docset.
-
-### `src/index.sh`
-
-This is the main script that builds the docset index. This script does not require any manual modifications, but you will probably want to make additions/changes to improve the quality of your docset and accomodate any quirks.
-
-### `src/Info.plist`
-
-This file contains metadata for the docset. Replace `<!-- VALUE -->` with appropriate values. It may be useful to refer to the `Info.plist` file of an existing docset for reference.
-
----
-
-### Credits
-
-Created by [lshprung](https://github.com/lshprung), and originally based on [benzado](https://github.com/benzado)'s [gnu-make-dash-docset](https://github.com/benzado/gnu-make-dash-docset).
+Examples:
+ make DOCSET_NAME=GNU_Make
+ make DOCSET_NAME=GNU_Make BUILD_DIR=build/
+```
diff --git a/README.template b/README.template
deleted file mode 100644
index 5d08037..0000000
--- a/README.template
+++ /dev/null
@@ -1,17 +0,0 @@
-Here is a script and a Makefile for generating a <NAME> docset for Dash. The script is based on the dash-docset-generation-template
-
-- <NAME>: <UPSTREAM LINK>
-- Dash: https://kapeli.com/dash
-- dash-docset-generation-template: https://github.com/lshprung/dash-docset-generation-template
-
-To generate a docset from the latest edition of the <NAME> Manual, simply
-execute `make` from the same directory as this README file. The latest edition
-will be downloaded from <UPSTREAM HOST> and packaged appropriately.
-
-Requirements:
-
-- any POSIX-compliant shell
-- curl - https://curl.se/
-- make - https://www.gnu.org/software/make/
-- pup - https://github.com/ericchiang/pup
-- sqlite3 - https://www.sqlite.org/index.html
diff --git a/src/Info.plist b/src/Info.plist
deleted file mode 100644
index 111baae..0000000
--- a/src/Info.plist
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundleIdentifier</key>
- <string><!-- VALUE --></string>
- <key>CFBundleName</key>
- <string><!-- VALUE --></string>
- <key>DocSetPlatformFamily</key>
- <string><!-- VALUE --></string>
- <key>isDashDocset</key>
- <true/>
-</dict>
-</plist>
diff --git a/src/index.sh b/src/index.sh
deleted file mode 100755
index 0b6e693..0000000
--- a/src/index.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/env sh
-
-# shellcheck source=./lib/create_table
-. "$(dirname "$0")"/lib/create_table
-# shellcheck source=./lib/insert
-. "$(dirname "$0")"/lib/insert
-
-DB_PATH="$1"
-shift
-
-get_title() {
- FILE="$1"
-
- pup -p -f "$FILE" 'title text{}' | \
- tr -d \\n | \
- sed 's/\"/\"\"/g'
-}
-
-insert_pages() {
- # Get title and insert into table for each html file
- while [ -n "$1" ]; do
- unset PAGE_NAME
- unset PAGE_TYPE
- PAGE_NAME="$(get_title "$1")"
- PAGE_TYPE="Guide"
- if [ -n "$PAGE_NAME" ]; then
- insert "$DB_PATH" "$PAGE_NAME" "$PAGE_TYPE" "$(basename "$1")"
- fi
- shift
- done
-}
-
-create_table "$DB_PATH"
-insert_pages "$@"
diff --git a/src/lib/create_table b/src/lib/create_table
deleted file mode 100644
index a783c50..0000000
--- a/src/lib/create_table
+++ /dev/null
@@ -1,7 +0,0 @@
-create_table() {
- DB_PATH="$1"
-
- sqlite3 "$DB_PATH" "CREATE TABLE IF NOT EXISTS searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT);"
- sqlite3 "$DB_PATH" "CREATE UNIQUE INDEX IF NOT EXISTS anchor ON searchIndex (name, type, path);"
-}
-
diff --git a/src/lib/insert b/src/lib/insert
deleted file mode 100644
index 31c1b4c..0000000
--- a/src/lib/insert
+++ /dev/null
@@ -1,8 +0,0 @@
-insert() {
- DB_PATH="$1"
- NAME="$2"
- TYPE="$3"
- PAGE_PATH="$4"
-
- sqlite3 "$DB_PATH" "INSERT INTO searchIndex(name, type, path) VALUES (\"$NAME\",\"$TYPE\",\"$PAGE_PATH\");"
-}