From 656c1da96de8ab863b98d5536fff9a6f116422ae Mon Sep 17 00:00:00 2001 From: setop Date: Wed, 31 May 2023 15:39:56 +0200 Subject: [PATCH] mvp --- cmd.txt | 11 +++++++++++ convert.sh | 14 ++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 cmd.txt create mode 100755 convert.sh diff --git a/cmd.txt b/cmd.txt new file mode 100644 index 0000000..fa23e54 --- /dev/null +++ b/cmd.txt @@ -0,0 +1,11 @@ +mkdir -p tf_aws.docset/Contents/Resources/Documents/ +svn export https://github.com/hashicorp/terraform-provider-aws/trunk/website/docs +wget https://kapeli.com/resources/Info.plist +sed -i -e 's,nginx,tf_aws,' -e 's,Nginx,TF AWS,' Info.plist +mv Info.plist tf_aws.docset/Contents/ +sqlite3 tf_aws.docset/Contents/Resources/docSet.dsidx 'CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT);' +sqlite3 tf_aws.docset/Contents/Resources/docSet.dsidx 'CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path);' +find docs -type f -print0 | xargs -0 -P 3 -I £ bash convert.sh £ tf_aws.docset/Contents/Resources/Documents/£ +find docs -type f -print0 | xargs -0 -I £ awk -vOFS="\t" -vf=£ '$1=="page_title:" {$1=""; print substr($0,8,length($0)-8),index(f,"/r/")?"Resource":"Object",substr(f,1,length(f)-9); nextfile}' £ | awk -vOFS="\t" 'NR==1{$1="aws_provider"}{print NR, $0}' > index.tsv +{ echo '.mode tabs' ; echo '.import index.tsv searchIndex' ; } | sqlite3 tf_aws.docset/Contents/Resources/docSet.dsidx +mv tf_aws.docset ~/.local/share/Zeal/Zeal/docsets/ diff --git a/convert.sh b/convert.sh new file mode 100755 index 0000000..254bb3b --- /dev/null +++ b/convert.sh @@ -0,0 +1,14 @@ +#!/bin/bash -eu + +filepath=$1 +filename=$(basename ${filepath}) +output=$2 +output="${output/.html.markdown}.html" + +printf "${filepath}\r" + +mkdir -p $(dirname ${output}) + +[ -s $output ] && exit 0 + +< $filepath awk '$1 == "page_title:"{$1="title:"} 1' | pandoc -f markdown -t html5 -s > $output