diff --git a/.gitignore b/.gitignore index 23dc435..0d075d0 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,6 @@ syntax-highlighter.min.css # External Go dependencies vendor/ build/ +archive/ .DS_Store docset-gen diff --git a/Makefile b/Makefile index b97099a..ee6a4a6 100644 --- a/Makefile +++ b/Makefile @@ -7,36 +7,44 @@ all: package-apex package-vf package-lightning vendor: dep ensure -docset-gen: vendor - go build -i -x -o docset-gen ./SFDashC/ - .PHONY: run-apex -run-apex: clean-index docset-gen - ./docset-gen apexcode +run-apex: clean-index vendor + go run ./SFDashC/*.go apexcode .PHONY: run-vf -run-vf: clean-index docset-gen - ./docset-gen pages +run-vf: clean-index vendor + go run ./SFDashC/*.go pages .PHONY: run-lightning -run-lightning: clean-index docset-gen - ./docset-gen lightning +run-lightning: clean-index vendor + go run ./SFDashC/*.go lightning +.PHONY: package-apex package-apex: run-apex - ./package-docset.sh Apex + ./package-docset.sh apexcode .PHONY: package-vf package-vf: run-vf - ./package-docset.sh Pages + ./package-docset.sh pages .PHONY: package-lightning package-lightning: run-lightning - ./package-docset.sh Lightning + ./package-docset.sh lightning -.PHONY: archive -archive: - find *.docset -depth 0 | xargs -I '{}' sh -c 'tar --exclude=".DS_Store" -czf "$$(echo {} | sed -e "s/\.[^.]*$$//" -e "s/ /_/").tgz" "{}"' - @echo "Archives created!" +.PHONY: archive-apex +archive-apex: package-apex + ./archive-docset.sh apexcode + +.PHONY: archive-vf +archive-vf: package-vf + ./archive-docset.sh pages + +.PHONY: archive-lightning +archive-lightning: package-lightning + ./archive-docset.sh lightning + +.PHONY: archive-all +archive-all: archive-apex archive-vf archive-lightning .PHONY: clean-index clean-index: @@ -49,10 +57,10 @@ clean-package: .PHONY: clean-archive clean-archive: rm -f *.tgz + rm -fr ./archive .PHONY: clean clean: clean-index clean-package clean-archive - rm -f docset-gen .PHONY: clean-build clean-build: diff --git a/README.md b/README.md index 3bd8998..e2b8d4d 100644 --- a/README.md +++ b/README.md @@ -20,3 +20,4 @@ To Do ----- - [ ] Now that new `ForceCascadeType` is available, some of the entries in `./SFDashC/supportedtypes.go` can be simplified + - [ ] Allow archiving of multiple versions and fetching pre-releases diff --git a/SFDashC/Info-Combined.plist b/SFDashC/Info-Combined.plist deleted file mode 100644 index 0b18d17..0000000 --- a/SFDashC/Info-Combined.plist +++ /dev/null @@ -1,19 +0,0 @@ - - - - - CFBundleIdentifier - Salesforce - - CFBundleName - Salesforce - DocSetPlatformFamily - sfdc - isDashDocset - - dashIndexFilePath - index.htm - DashDocSetFallbackURL - https://developer.salesforce.com/docs/ - - diff --git a/SFDashC/main.go b/SFDashC/main.go index 43498b2..e02b1d8 100644 --- a/SFDashC/main.go +++ b/SFDashC/main.go @@ -167,7 +167,7 @@ func getEntryType(entry TOCEntry, parentType SupportedType) (SupportedType, erro } childType, err := lookupEntryType(entry) - if err != nil && parentType.CascadeType { + if err != nil && parentType.ShouldCascade() { childType = parentType.CreateChildType() err = nil } diff --git a/SFDashC/structs.go b/SFDashC/structs.go index a2e74ac..dbd8eb2 100644 --- a/SFDashC/structs.go +++ b/SFDashC/structs.go @@ -87,7 +87,7 @@ type SupportedType struct { // Should a namspace be prefixed to the database entry ShowNamespace bool // Indicates that this just contains other nodes and we don't want to index this node - // This is not hereditary + // This type will cascade down one level, but IsContainer itself is not hereditary IsContainer bool // Indicates that this and all nodes underneith should be hidden IsHidden bool @@ -127,6 +127,11 @@ func (suppType SupportedType) matchesID(id string) bool { return false } +// ShouldCascade returns if this type should be cascaded down to the child +func (suppType SupportedType) ShouldCascade() bool { + return suppType.ForceCascadeType || suppType.CascadeType || suppType.IsContainer +} + // CreateChildType returns a child type inheriting the current type func (suppType SupportedType) CreateChildType() SupportedType { // Reset values that do not cascade diff --git a/archive-docset.sh b/archive-docset.sh new file mode 100755 index 0000000..13f2a50 --- /dev/null +++ b/archive-docset.sh @@ -0,0 +1,58 @@ +#! /bin/bash +set -e + +files_dir=./resources +build_dir=./build +out_dir=. +archive_dir=./archive + +deliverable=$1 + +function get_friendly_name { + local deliverable=$1 + local name="$(tr '[:lower:]' '[:upper:]' <<< ${deliverable:0:1})${deliverable:1}" + case "$deliverable" in + "apexcode") + name="Apex" + ;; + "pages") + name="Visualforce" + ;; + esac + + echo $name +} + +function get_icon_name { + local icon="cloud-icon" + case "$1" in + "lightning") + icon="bolt-icon" + ;; + esac + echo $icon +} + +function main { + local name=$(get_friendly_name $deliverable) + local package="$out_dir/Salesforce $name.docset" + local archive_dir="$archive_dir/Salesforce_$name" + local archive="$archive_dir/Salesforce_$name.tgz" + local icon=$(get_icon_name $deliverable) + mkdir -p $archive_dir + + # Generate docset.json + version=$(cat $build_dir/$deliverable-version.txt) + cat $files_dir/docset-$deliverable.json | sed s/VERSION/$version/ > $archive_dir/docset.json + # Generated tgz archive + tar --exclude=".DS_Store" -czf "$archive" "$package" + # Copy icons + cp "$files_dir/$icon.png" "$archive_dir/icon.png" + cp "$files_dir/$icon@2x.png" "$archive_dir/icon@2x.png" + # Copy readme + cp "$files_dir/Archive_Readme.md" "$archive_dir/README.md" + + echo "Finished archive $archive" +} + +main diff --git a/package-docset.sh b/package-docset.sh index ffd381c..4160da4 100755 --- a/package-docset.sh +++ b/package-docset.sh @@ -1,24 +1,57 @@ #! /bin/bash set -e -files_dir=./SFDashC +files_dir=./resources build_dir=./build +out_dir=. -name=$1 -deliverable=$(echo $name | tr '[:upper:]' '[:lower:]') -if [ "$deliverable" == "apex" ]; then - deliverable="apexcode" -fi +deliverable=$1 -package="Salesforce $name.docset" -version=$(cat $build_dir/$deliverable-version.txt) +function get-friendly-name { + local deliverable=$1 + local name="$(tr '[:lower:]' '[:upper:]' <<< ${deliverable:0:1})${deliverable:1}" + case "$deliverable" in + "apexcode") + name="Apex" + ;; + "pages") + name="Visualforce" + ;; + esac -cat $files_dir/docset-$deliverable.json | sed s/VERSION/$version/ > $build_dir/docset-$deliverable.json -mkdir -p "$package/Contents/Resources/Documents" -cp -r $build_dir/atlas.en-us.$deliverable.meta "$package/Contents/Resources/Documents/" -cp $build_dir/*.html "$package/Contents/Resources/Documents/" -cp $build_dir/*.css "$package/Contents/Resources/Documents/" -cp $files_dir/Info-$name.plist "$package/Contents/Info.plist" -cp $build_dir/docSet.dsidx "$package/Contents/Resources/" + echo $name +} -echo "Finished building $package" +function get_icon_name { + local icon="cloud-icon" + case "$1" in + "lightning") + icon="bolt-icon" + ;; + esac + echo $icon +} + +function main { + local name=$(get-friendly-name $deliverable) + local package="$out_dir/Salesforce $name.docset" + local icon=$(get_icon_name $deliverable) + mkdir -p "$package/Contents/Resources/Documents" + + # Copy all meta HTML + cp -r $build_dir/atlas.en-us.$deliverable.meta "$package/Contents/Resources/Documents/" + # Copy HTML and CSS + cp $build_dir/$deliverable.html "$package/Contents/Resources/Documents/" + cp $build_dir/*.css "$package/Contents/Resources/Documents/" + # Copy plsit + cp $files_dir/Info-$name.plist "$package/Contents/Info.plist" + # Copy index + cp $build_dir/docSet.dsidx "$package/Contents/Resources/" + # Copy icons + cp "$files_dir/$icon.png" "$package/icon.png" + cp "$files_dir/$icon@2x.png" "$package/icon@2x.png" + + echo "Finished building $package" +} + +main diff --git a/resources/Archive_Readme.md b/resources/Archive_Readme.md new file mode 100644 index 0000000..e485aea --- /dev/null +++ b/resources/Archive_Readme.md @@ -0,0 +1,13 @@ +Salesforce Apex +=============== + +Created by [ViViDboarder](https://github.com/ViViDboarder) + +## Generation + +* Clone the repo for [docset-sfdc](https://github.com/ViViDboarder/docset-sfdc) +* Run `make` as described in the readme + +## Dependencies + +To avoid redundancy, those are listed on the readme for the other repo diff --git a/SFDashC/Info-Apex.plist b/resources/Info-Apex.plist similarity index 100% rename from SFDashC/Info-Apex.plist rename to resources/Info-Apex.plist diff --git a/SFDashC/Info-Lightning.plist b/resources/Info-Lightning.plist similarity index 100% rename from SFDashC/Info-Lightning.plist rename to resources/Info-Lightning.plist diff --git a/SFDashC/Info-Pages.plist b/resources/Info-Visualforce.plist similarity index 100% rename from SFDashC/Info-Pages.plist rename to resources/Info-Visualforce.plist diff --git a/resources/bolt-icon.png b/resources/bolt-icon.png new file mode 100644 index 0000000..2041d90 Binary files /dev/null and b/resources/bolt-icon.png differ diff --git a/resources/bolt-icon@2x.png b/resources/bolt-icon@2x.png new file mode 100644 index 0000000..df1e421 Binary files /dev/null and b/resources/bolt-icon@2x.png differ diff --git a/resources/cloud-icon.png b/resources/cloud-icon.png new file mode 100644 index 0000000..06765aa Binary files /dev/null and b/resources/cloud-icon.png differ diff --git a/resources/cloud-icon@2x.png b/resources/cloud-icon@2x.png new file mode 100644 index 0000000..6ee10e9 Binary files /dev/null and b/resources/cloud-icon@2x.png differ diff --git a/SFDashC/docset-apexcode.json b/resources/docset-apexcode.json similarity index 100% rename from SFDashC/docset-apexcode.json rename to resources/docset-apexcode.json diff --git a/SFDashC/docset-lightning.json b/resources/docset-lightning.json similarity index 100% rename from SFDashC/docset-lightning.json rename to resources/docset-lightning.json diff --git a/SFDashC/docset-pages.json b/resources/docset-pages.json similarity index 86% rename from SFDashC/docset-pages.json rename to resources/docset-pages.json index f81e33a..7260480 100644 --- a/SFDashC/docset-pages.json +++ b/resources/docset-pages.json @@ -1,7 +1,7 @@ { "name": "Salesforce Visualforce", "version": "VERSION", - "archive": "Salesforce_Pages.tgz", + "archive": "Salesforce_Visualforce.tgz", "author": { "name": "ViViDboarder", "link": "https://github.com/ViViDboarder"