Skip to content

Commit

Permalink
Merge pull request square#5508 from square/jwilson.0927.titles_in_dok…
Browse files Browse the repository at this point in the history
…ka_pages

Rewrite Dokka-generated markdown to include titles.
  • Loading branch information
squarejesse authored Sep 29, 2019
2 parents b3dcb9b + fdc56a0 commit a8206ac
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions deploy_website.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ cd $DIR
:okhttp-urlconnection:dokka \
:okhttp:dokka

# Dokka filenames like `-http-url/index.md` don't work well with MkDocs <title> tags.
# Assign metadata to the file's first Markdown heading.
# https://www.mkdocs.org/user-guide/writing-your-docs/#meta-data
title_markdown_file() {
TITLE_PATTERN="s/^[#]+ *(.*)/title: \1 - OkHttp/"
echo "---" > "$1.fixed"
cat $1 | sed -E "$TITLE_PATTERN" | grep "title: " | head -n 1 >> "$1.fixed"
echo "---" >> "$1.fixed"
echo >> "$1.fixed"
cat $1 >> "$1.fixed"
mv "$1.fixed" "$1"
}

set +x
for MARKDOWN_FILE in $(find docs/4.x/ -name '*.md'); do
echo $MARKDOWN_FILE
title_markdown_file $MARKDOWN_FILE
done
set -x

# Copy in special files that GitHub wants in the project root.
cat README.md | grep -v 'project website' > docs/index.md
cp CHANGELOG.md docs/changelog.md
Expand Down

0 comments on commit a8206ac

Please sign in to comment.