diff --git a/docs/documentation.md b/docs/documentation.md index 1467cdc9..8cd79cca 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -3,7 +3,6 @@ layout: page title: Documentation permalink: /documentation/ --- - # Usage ```html @@ -19,13 +18,18 @@ documentationSearch({ }); ``` +# Examples + +- http://eslint.org/ +- https://bootstrap.algolia.com/ +- https://reactjs.algolia.com/ +- https://babeljs.algolia.com/ # How do I get an `apiKey` and `indexName`? Send us [an email](mailto:docsearch@algolia.com) with the url of the documentation website you would like to add search to. - # How does it work? The JavaScript library is a wrapper on top of our diff --git a/scripts/build-docs b/scripts/build-docs index df11c7e1..a2d02fbb 100755 --- a/scripts/build-docs +++ b/scripts/build-docs @@ -1,26 +1,21 @@ -#!/usr/bin/env bash +#!/bin/sh set -o nounset set -o errexit readonly SOURCE=README.md readonly OUTPUT=docs/documentation.md -readonly SECTIONS=( - 'Usage' - 'How do I get an `apiKey` and `indexName`?' - 'How does it work?' -) +readonly START_TAG="" +readonly END_TAG="" function escape_regex { - echo "$@" | sed -e 's/[]\/$*.^|[]/\\&/g' + echo "$@" | sed -e 's/[]\/\!$*.^|[]/\\&/g' } function extract { - local section=${1} - - echo - sed -n "/^#\s*$(escape_regex $section)\s*$/,/^#[^#]/p" \ - | head -n -1 + sed -n "/^\s*$(escape_regex $START_TAG)\s*$/,/^\s*$(escape_regex $END_TAG)\s*$/p" \ + | sed '$d' \ + | sed -n '2,$p' } function main { @@ -32,9 +27,7 @@ function main { echo "permalink: /documentation/" >> $OUTPUT echo "---" >> $OUTPUT - for section in "${SECTIONS[@]}"; do - cat $SOURCE | extract "$section" >> $OUTPUT - done + cat $SOURCE | extract >> $OUTPUT } main