summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouie Shprung <lshprung@scu.edu>2023-03-25 17:29:45 -0700
committerLouie Shprung <lshprung@scu.edu>2023-03-25 17:31:23 -0700
commit78056b724b9a5591ea2361429ed2d83b2e528dcf (patch)
tree171f9f6142cc96dd6e8306f857ee36acf7b3c25c
parenta26adab1566f7ad0574c93b841f640363a799092 (diff)
1st commit; basic functionality
-rw-r--r--.gitignore3
-rw-r--r--Makefile21
-rw-r--r--README18
-rw-r--r--README.md33
-rw-r--r--README.template16
-rw-r--r--src/Info.plist6
-rwxr-xr-xsrc/index.sh29
7 files changed, 67 insertions, 59 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..6a5abe2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+/Flex.docset
+/Flex.tgz
+/tmp
diff --git a/Makefile b/Makefile
index 9339745..7f47fab 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-#DOCSET_NAME = ...
+DOCSET_NAME = Flex
DOCSET_DIR = $(DOCSET_NAME).docset
CONTENTS_DIR = $(DOCSET_DIR)/Contents
@@ -12,8 +12,10 @@ ARCHIVE_FILE = $(DOCSET_NAME).tgz
#SRC_ICON = src/icon.png
-#MANUAL_URL = ...
-#MANUAL_FILE = tmp/...
+VERSION = 2.6.4
+MANUAL_URL = https://github.com/westes/flex/releases/download/v$(VERSION)/flex-$(VERSION).tar.gz
+MANUAL_SRC = tmp/flex-$(VERSION)
+MANUAL_FILE = $(MANUAL_SRC)/doc/flex.html
ERROR_DOCSET_NAME = $(error DOCSET_NAME is unset)
WARNING_MANUAL_URL = $(warning MANUAL_URL is unset)
@@ -45,6 +47,9 @@ archive: $(ARCHIVE_FILE)
clean:
rm -rf $(DOCSET_DIR) $(ARCHIVE_FILE)
+ifneq (,$(wildcard $(MANUAL_SRC)))
+ cd $(MANUAL_SRC) && make clean
+endif
tmp:
mkdir -p $@
@@ -52,8 +57,12 @@ tmp:
$(ARCHIVE_FILE): $(DOCSET)
tar --exclude='.DS_Store' -czf $@ $(DOCSET_DIR)
-$(MANUAL_FILE): tmp
- curl -o $@ $(MANUAL_URL)
+$(MANUAL_SRC): tmp
+ curl -L -o $@.tar.gz $(MANUAL_URL)
+ tar -x -z -f $@.tar.gz -C tmp
+
+$(MANUAL_FILE): $(MANUAL_SRC)
+ cd $(MANUAL_SRC) && ./configure && make html
$(DOCSET_DIR):
mkdir -p $@
@@ -66,7 +75,7 @@ $(RESOURCES_DIR): $(CONTENTS_DIR)
$(DOCUMENTS_DIR): $(RESOURCES_DIR) $(MANUAL_FILE)
mkdir -p $@
- tar -x -z -f $(MANUAL_FILE) -C $@
+ cp -r $(MANUAL_FILE)/* $@
$(INFO_PLIST_FILE): src/Info.plist $(CONTENTS_DIR)
cp src/Info.plist $@
diff --git a/README b/README
new file mode 100644
index 0000000..05f4702
--- /dev/null
+++ b/README
@@ -0,0 +1,18 @@
+Here is a script and a Makefile for generating a Flex docset for Dash. The script is based on the dash-docset-generation-template
+
+- Flex: https://github.com/westes/flex
+- 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 Flex Manual, simply
+execute `make` from the same directory as this README file. The latest edition
+will be downloaded from https://github.com/westes/flex and packaged appropriately.
+A specific version can be specified in the Makefile.
+
+Requirements:
+
+- any POSIX-compliant shell
+- curl
+- make
+- pup
+- sqlite3
diff --git a/README.md b/README.md
deleted file mode 100644
index 7fb5e46..0000000
--- a/README.md
+++ /dev/null
@@ -1,33 +0,0 @@
-# Dash Docset Template
-
-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)
-
-### `README.template`
-
-This file will provide a README for the packaging script. Replace `<NAME>`, `<UPSTREAM LINK>`, and `<UPSTREAM HOST>` with appropriate values.
-
-### `Makefile`
-
-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`.
-
-### `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).
diff --git a/README.template b/README.template
deleted file mode 100644
index 8c254e4..0000000
--- a/README.template
+++ /dev/null
@@ -1,16 +0,0 @@
-Here is a script and a Makefile for generating a <NAME> docset for Dash. The script is loosely based on benzado's script for GNU Make https://github.com/benzado/gnu-make-dash-docset.
-
-- <NAME>: <UPSTREAM LINK>
-- Dash: https://kapeli.com/dash
-
-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
-- make
-- pup
-- sqlite3
diff --git a/src/Info.plist b/src/Info.plist
index 111baae..b8645ff 100644
--- a/src/Info.plist
+++ b/src/Info.plist
@@ -3,11 +3,11 @@
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
- <string><!-- VALUE --></string>
+ <string>flex</string>
<key>CFBundleName</key>
- <string><!-- VALUE --></string>
+ <string>Flex</string>
<key>DocSetPlatformFamily</key>
- <string><!-- VALUE --></string>
+ <string>flex</string>
<key>isDashDocset</key>
<true/>
</dict>
diff --git a/src/index.sh b/src/index.sh
index 35ed08c..5aca876 100755
--- a/src/index.sh
+++ b/src/index.sh
@@ -13,10 +13,23 @@ get_title() {
FILE="$1"
pup -p -f "$FILE" 'title text{}' | \
+ sed 's/(Lexical Analysis With Flex.*)//' | \
tr -d \\n | \
sed 's/\"/\"\"/g'
}
+get_type() {
+ PAGE_NAME="$1"
+
+ case "$PAGE_NAME" in
+ option-*)
+ echo "Option"
+ ;;
+ *)
+ echo "Guide"
+ esac
+}
+
insert() {
NAME="$1"
TYPE="$2"
@@ -31,7 +44,21 @@ insert_pages() {
unset PAGE_NAME
unset PAGE_TYPE
PAGE_NAME="$(get_title "$1")"
- PAGE_TYPE="Guide"
+
+ # determine type
+ case "$PAGE_NAME" in
+ option-*)
+ PAGE_TYPE="Option"
+ PAGE_NAME="$(echo "$PAGE_NAME" | sed 's/^option-//')"
+ ;;
+ unnamed-* | deleteme* | ERASEME*)
+ shift
+ continue
+ ;;
+ *)
+ PAGE_TYPE="Guide"
+ esac
+
if [ -n "$PAGE_NAME" ]; then
insert "$PAGE_NAME" "$PAGE_TYPE" "$(basename "$1")"
fi