Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(documentation.md): Fix not working links #67

Merged
merged 1 commit into from
Jan 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Check out our [website][1] to add an outstanding search to your documentation.

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

<!-- START documentation.md -->
<!-- START documentation -->

## Introduction

Expand Down Expand Up @@ -194,7 +194,7 @@ docsearch({

You will find all Algolia API options in its [own documentation][23]

<!-- END documentation.md -->
<!-- END documentation -->

## Development workflow

Expand Down Expand Up @@ -248,6 +248,7 @@ configure the build path of eventmachine with
bundle config build.eventmachine --with-cppflags=-I$(brew --prefix openssl)/include
```

<!-- START links -->

[1]: https://community.algolia.com/docsearch/
[2]: https://img.shields.io/npm/v/docsearch.js.svg?style=flat-square
Expand Down Expand Up @@ -276,3 +277,5 @@ bundle config build.eventmachine --with-cppflags=-I$(brew --prefix openssl)/incl
[25]: https://jekyllrb.com/
[26]: https://www.ruby-lang.org/en/
[27]: http://bundler.io/

<!-- END links -->
15 changes: 10 additions & 5 deletions scripts/build-docs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ set -o errexit

readonly SOURCE=README.md
readonly OUTPUT=docs/documentation.md
readonly START_TAG="<!-- START documentation.md -->"
readonly END_TAG="<!-- END documentation.md -->"

readonly START_DOC_TAG="<!-- START documentation -->"
readonly END_DOC_TAG="<!-- END documentation -->"

readonly START_LINKS_TAG="<!-- START links -->"
readonly END_LINKS_TAG="<!-- END links -->"

function escape_regex {
echo "$@" | sed -e 's/[]\/\!$*.^|[]/\\&/g'
echo "$1" | sed -e 's/[]\/\!$*.^|[]/\\&/g'
}

function extract {
sed -n "/^\s*$(escape_regex $START_TAG)\s*$/,/^\s*$(escape_regex $END_TAG)\s*$/p" \
sed -n "/^\s*$(escape_regex "$1")\s*$/,/^\s*$(escape_regex "$2")\s*$/p" \
| sed '$d' \
| sed -n '2,$p'
}
Expand All @@ -27,7 +31,8 @@ function main {
echo "permalink: /documentation/" >> $OUTPUT
echo "---" >> $OUTPUT

cat $SOURCE | extract >> $OUTPUT
cat $SOURCE | extract "$START_DOC_TAG" "$END_DOC_TAG" >> $OUTPUT
cat $SOURCE | extract "$START_LINKS_TAG" "$END_LINKS_TAG" >> $OUTPUT
}

main